ftl_protocol/protocol/
response.rs1use std::string::ToString;
2
3#[derive(Debug)]
4pub enum FtlResponse {
5 HMAC { hmac_payload: String },
6 Success,
7 Connect { udp_port: u16 },
8 Pong,
9}
10
11impl ToString for FtlResponse {
12 fn to_string(&self) -> String {
13 match self {
14 FtlResponse::HMAC { hmac_payload } => format!("200 {}\n", hmac_payload),
15 FtlResponse::Success => "200\n".to_string(),
16 FtlResponse::Connect { udp_port } => format!("200. Use UDP port {}\n", udp_port),
17 FtlResponse::Pong => "201\n".to_string(),
18 }
19 }
20}
21
22#[cfg(test)]
23mod tests {
24 use crate::protocol::FtlResponse;
25
26 #[test]
27 fn should_success() {
28 let resp = FtlResponse::Success;
29 assert_eq!(resp.to_string(), "200\n".to_string());
30 }
31}