forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
27 lines (21 loc) · 598 Bytes
/
mod.rs
File metadata and controls
27 lines (21 loc) · 598 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pub mod client;
pub mod url_encoding;
use percent_encoding::NON_ALPHANUMERIC;
pub type ByteArray20 = [u8; 20];
#[must_use]
pub fn percent_encode_byte_array(bytes: &ByteArray20) -> String {
percent_encoding::percent_encode(bytes, NON_ALPHANUMERIC).to_string()
}
pub struct InfoHash(ByteArray20);
impl InfoHash {
#[must_use]
pub fn new(vec: &[u8]) -> Self {
let mut byte_array_20: ByteArray20 = Default::default();
byte_array_20.clone_from_slice(vec);
Self(byte_array_20)
}
#[must_use]
pub fn bytes(&self) -> ByteArray20 {
self.0
}
}