forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.rs
More file actions
29 lines (26 loc) · 1 KB
/
request.rs
File metadata and controls
29 lines (26 loc) · 1 KB
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
28
29
//! UDP request types.
//!
//! Torrust Tracker uses the [`aquatic_udp_protocol`](https://crates.io/crates/aquatic_udp_protocol)
//! crate to parse and serialize UDP requests.
//!
//! Some of the type in this module are wrappers around the types in the
//! `aquatic_udp_protocol` crate.
use aquatic_udp_protocol::AnnounceRequest;
use crate::shared::bit_torrent::info_hash::InfoHash;
/// Wrapper around [`AnnounceRequest`](aquatic_udp_protocol::request::AnnounceRequest).
pub struct AnnounceWrapper {
/// [`AnnounceRequest`](aquatic_udp_protocol::request::AnnounceRequest) to wrap.
pub announce_request: AnnounceRequest,
/// Info hash of the torrent.
pub info_hash: InfoHash,
}
impl AnnounceWrapper {
/// Creates a new [`AnnounceWrapper`] from an [`AnnounceRequest`].
#[must_use]
pub fn new(announce_request: &AnnounceRequest) -> Self {
AnnounceWrapper {
announce_request: announce_request.clone(),
info_hash: InfoHash(announce_request.info_hash.0),
}
}
}