tcp_request/response/response_binary/
impl.rs

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
use super::r#type::TcpResponseBinary;
use crate::response::{r#trait::ResponseTrait, response_text::r#type::TcpResponseText};

impl ResponseTrait for TcpResponseBinary {
    type OutputText = TcpResponseText;
    type OutputBinary = TcpResponseBinary;

    #[inline]
    fn from(response: &[u8]) -> Self
    where
        Self: Sized,
    {
        response.to_vec()
    }

    #[inline]
    fn binary(&self) -> Self::OutputBinary {
        self.clone()
    }

    #[inline]
    fn text(&self) -> TcpResponseText {
        let data: String = String::from_utf8_lossy(&self).to_string();
        data
    }
}