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 #[inline]
18 fn from(response: &[u8]) -> Self::OutputText
19 where
20 Self: Sized,
21 {
22 <TcpResponseBinary as ResponseTrait>::from(response).text()
23 }
24
25 /// Gets the text representation of the response.
26 ///
27 /// # Returns
28 ///
29 /// - `Self::OutputText` - The text response data.
30 #[inline]
31 fn text(&self) -> Self::OutputText {
32 self.clone()
33 }
34
35 /// Converts the text response to binary representation.
36 ///
37 /// # Returns
38 ///
39 /// - `TcpResponseBinary` - The binary representation of the response.
40 #[inline]
41 fn binary(&self) -> TcpResponseBinary {
42 self.clone().into_bytes()
43 }
44}