forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasserts.rs
More file actions
23 lines (19 loc) · 720 Bytes
/
asserts.rs
File metadata and controls
23 lines (19 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use aquatic_udp_protocol::{Response, TransactionId};
pub fn get_error_response_message(response: &Response) -> Option<String> {
match response {
Response::Error(error_response) => Some(error_response.message.to_string()),
_ => None,
}
}
pub fn is_connect_response(response: &Response, transaction_id: TransactionId) -> bool {
match response {
Response::Connect(connect_response) => connect_response.transaction_id == transaction_id,
_ => false,
}
}
pub fn is_ipv4_announce_response(response: &Response) -> bool {
matches!(response, Response::AnnounceIpv4(_))
}
pub fn is_scrape_response(response: &Response) -> bool {
matches!(response, Response::Scrape(_))
}