tcp_request/response/trait.rs
1use crate::*;
2
3/// Trait defining the interface for response operations.
4pub trait ResponseTrait: Send + Debug {
5 type OutputText: Clone + Sized;
6 type OutputBinary: Clone + Sized;
7
8 /// Gets the response as text.
9 ///
10 /// # Returns
11 ///
12 /// - `Self::OutputText` - The response text content.
13 fn text(&self) -> Self::OutputText;
14
15 /// Gets the response as binary data.
16 ///
17 /// # Returns
18 ///
19 /// - `Self::OutputBinary` - The response binary content.
20 fn binary(&self) -> Self::OutputBinary;
21
22 /// Creates a response from raw bytes.
23 ///
24 /// # Arguments
25 ///
26 /// - `&[u8]` - The raw response data.
27 ///
28 /// # Returns
29 ///
30 /// - `Self` - A new response instance.
31 fn from(response: &[u8]) -> Self
32 where
33 Self: Sized;
34}