forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnection_info.rs
More file actions
29 lines (25 loc) · 772 Bytes
/
connection_info.rs
File metadata and controls
29 lines (25 loc) · 772 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
28
29
pub fn connection_with_invalid_token(bind_address: &str) -> ConnectionInfo {
ConnectionInfo::authenticated(bind_address, "invalid token")
}
pub fn connection_with_no_token(bind_address: &str) -> ConnectionInfo {
ConnectionInfo::anonymous(bind_address)
}
#[derive(Clone)]
pub struct ConnectionInfo {
pub bind_address: String,
pub api_token: Option<String>,
}
impl ConnectionInfo {
pub fn authenticated(bind_address: &str, api_token: &str) -> Self {
Self {
bind_address: bind_address.to_string(),
api_token: Some(api_token.to_string()),
}
}
pub fn anonymous(bind_address: &str) -> Self {
Self {
bind_address: bind_address.to_string(),
api_token: None,
}
}
}