Skip to main content

ResponseTrait

Trait ResponseTrait 

Source
pub trait ResponseTrait: Send + Debug {
    type OutputText: Clone + Sized;
    type OutputBinary: Clone + Sized;

    // Required methods
    fn text(&self) -> Self::OutputText;
    fn binary(&self) -> Self::OutputBinary;
    fn from(response: &[u8]) -> Self
       where Self: Sized;
}
Expand description

Trait defining the interface for response operations.

Required Associated Types§

Required Methods§

Source

fn text(&self) -> Self::OutputText

Gets the response as text.

§Returns
  • Self::OutputText - The response text content.
Source

fn binary(&self) -> Self::OutputBinary

Gets the response as binary data.

§Returns
  • Self::OutputBinary - The response binary content.
Source

fn from(response: &[u8]) -> Self
where Self: Sized,

Creates a response from raw bytes.

§Arguments
  • &[u8] - The raw response data.
§Returns
  • Self - A new response instance.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ResponseTrait for TcpResponseBinary

ResponseTrait implementation for binary TCP responses.

Source§

impl ResponseTrait for TcpResponseText

ResponseTrait implementation for text TCP responses.