pub struct HttpResponseBinary { /* private fields */ }Expand description
A struct representing an HTTP response.
This struct contains all the components of an HTTP response: the HTTP version, status code, status text, headers, and body. It is used to model and manipulate HTTP responses within the application.
§Fields
http_version: A string representing the HTTP version (e.g., “HTTP/1.1”).status_code: The HTTP status code (e.g., 200 for OK, 404 for Not Found).status_text: A string containing the status text associated with the status code (e.g., “OK”, “Not Found”).headers: AHashMap<String, String>containing the headers of the response, where each key is the header name (e.g., “Content-Type”), and the value is the corresponding header value.body: AVec<u8>representing the body of the HTTP response, which contains the content being returned.
Implementations§
Source§impl HttpResponseBinary
impl HttpResponseBinary
Sourcepub fn get_http_version(&self) -> HttpVersion
pub fn get_http_version(&self) -> HttpVersion
Retrieves the HTTP version associated with this response.
§Returns
HttpVersion: The HTTP version (e.g., HTTP/1.1, HTTP/2, etc.) used for the response.
Sourcepub fn get_status_code(&self) -> StatusCodeUsize
pub fn get_status_code(&self) -> StatusCodeUsize
Retrieves the HTTP status code associated with this response.
§Returns
StatusCodeUsize: The HTTP status code as a usize (e.g., 200 for OK, 404 for Not Found).
Sourcepub fn get_status_text(&self) -> String
pub fn get_status_text(&self) -> String
Retrieves the status text associated with the HTTP status code.
§Returns
String: The human-readable status text (e.g., “OK” for status code 200, “Not Found” for status code 404).
Sourcepub fn get_headers(&self) -> HttpHeaderMap
pub fn get_headers(&self) -> HttpHeaderMap
Retrieves the headers of the HTTP response.
§Returns
HttpHeaderMap: A map of header names and their corresponding values as key-value pairs.
Sourcepub fn get_body(&self) -> HttpBodyVec
pub fn get_body(&self) -> HttpBodyVec
Retrieves the body content of the HTTP response.
§Returns
HttpBodyVec: The body of the response in binary form (could be raw bytes, a stream, etc.).
Trait Implementations§
Source§impl Clone for HttpResponseBinary
impl Clone for HttpResponseBinary
Source§fn clone(&self) -> HttpResponseBinary
fn clone(&self) -> HttpResponseBinary
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HttpResponseBinary
impl Debug for HttpResponseBinary
Source§impl Default for HttpResponseBinary
impl Default for HttpResponseBinary
Source§impl ResponseTrait for HttpResponseBinary
Implements the ResponseTrait trait for HttpResponseBinary.
impl ResponseTrait for HttpResponseBinary
Implements the ResponseTrait trait for HttpResponseBinary.
This implementation specifies the associated types for binary and text representations of HTTP responses, enabling seamless conversion and handling of HTTP response data.
§Associated Types
OutputText: Specifies the text representation of an HTTP response (HttpResponseText).OutputBinary: Specifies the binary representation of an HTTP response (HttpResponseBinary).
type OutputText = HttpResponseText
type OutputBinary = HttpResponseBinary
Source§fn from(response: &[u8]) -> Selfwhere
Self: Sized,
fn from(response: &[u8]) -> Selfwhere
Self: Sized,
Parses a raw HTTP response into the associated type
Output. Read moreSource§fn binary(&self) -> Self::OutputBinary
fn binary(&self) -> Self::OutputBinary
Transforms the HTTP response into a binary representation. Read more
Source§fn text(&self) -> HttpResponseText
fn text(&self) -> HttpResponseText
Transforms the HTTP response into a text representation. Read more
Auto Trait Implementations§
impl Freeze for HttpResponseBinary
impl RefUnwindSafe for HttpResponseBinary
impl Send for HttpResponseBinary
impl Sync for HttpResponseBinary
impl Unpin for HttpResponseBinary
impl UnwindSafe for HttpResponseBinary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more