torrust_tracker/shared/bit_torrent/tracker/http/
mod.rs

1pub mod client;
2
3use percent_encoding::NON_ALPHANUMERIC;
4
5pub type ByteArray20 = [u8; 20];
6
7#[must_use]
8pub fn percent_encode_byte_array(bytes: &ByteArray20) -> String {
9    percent_encoding::percent_encode(bytes, NON_ALPHANUMERIC).to_string()
10}
11
12pub struct InfoHash(ByteArray20);
13
14impl InfoHash {
15    #[must_use]
16    pub fn new(vec: &[u8]) -> Self {
17        let mut byte_array_20: ByteArray20 = Default::default();
18        byte_array_20.clone_from_slice(vec);
19        Self(byte_array_20)
20    }
21
22    #[must_use]
23    pub fn bytes(&self) -> ByteArray20 {
24        self.0
25    }
26}