tcp_request/response/response_text/impl.rs
1use crate::*;
2
3/// ResponseTrait implementation for text TCP responses.
4impl ResponseTrait for TcpResponseText {
5 type OutputText = TcpResponseText;
6 type OutputBinary = TcpResponseBinary;
7
8 /// Creates a text response from raw bytes.
9 ///
10 /// # Arguments
11 ///
12 /// - `&[u8]` - The raw response data.
13 ///
14 /// # Returns
15 ///
16 /// - `Self::OutputText` - The text response instance.
17 fn from(response: &[u8]) -> Self::OutputText
18 where
19 Self: Sized,
20 {
21 <TcpResponseBinary as ResponseTrait>::from(response).text()
22 }
23
24 /// Gets the text representation of the response.
25 ///
26 /// # Returns
27 ///
28 /// - `Self::OutputText` - The text response data.
29 fn text(&self) -> Self::OutputText {
30 self.clone()
31 }
32
33 /// Converts the text response to binary representation.
34 ///
35 /// # Returns
36 ///
37 /// - `TcpResponseBinary` - The binary representation of the response.
38 fn binary(&self) -> TcpResponseBinary {
39 self.clone().into_bytes()
40 }
41}