Trait BlockingResponse

Source
pub trait BlockingResponse:
    Read
    + Send
    + Sync
    + 'static {
    // Required methods
    fn status(&self) -> u16;
    fn content_length(&self) -> Option<u64>;
    fn get_header(&self, header: &str) -> Result<Vec<String>>;
    fn text(&mut self) -> Result<String>;
    fn bytes(&mut self) -> Result<Vec<u8>>;

    // Provided method
    fn describe(&self, f: &mut Formatter<'_>) -> Result { ... }
}
Available on crate feature blocking only.
Expand description

Trait for blocking HTTP responses.

This trait provides methods for accessing the data in an HTTP response and extends io::Read to allow streaming the response body.

§Response Method Receivers

Note that the BlockingResponse trait uses &mut self receivers for content reading methods (text(), bytes(), etc.) to ensure object safety and dyn compatibility. This differs from the main nyquest crate which uses consuming self receivers.

Backend implementors should design their implementations with the understanding that these methods may be called only once per response instance, even though the signature allows multiple calls. The nyquest facade enforces this by consuming the response.

Required Methods§

Source

fn status(&self) -> u16

Returns the HTTP status code of this response.

Source

fn content_length(&self) -> Option<u64>

Returns the content-length of the response body, if known.

Source

fn get_header(&self, header: &str) -> Result<Vec<String>>

Gets all values for the specified header.

Source

fn text(&mut self) -> Result<String>

Reads the response body as text.

Source

fn bytes(&mut self) -> Result<Vec<u8>>

Reads the response body as bytes.

Provided Methods§

Source

fn describe(&self, f: &mut Formatter<'_>) -> Result

Provides a textual description of this response.

Implementors§