pub struct Response<B = Bytes> { /* private fields */ }Expand description
HTTP response with status, headers, and body.
Implementations§
Source§impl<B> Response<B>
impl<B> Response<B>
Sourcepub fn new(status: u16, headers: HashMap<String, String>, body: B) -> Self
pub fn new(status: u16, headers: HashMap<String, String>, body: B) -> Self
Creates a new response.
Sourcepub fn into_parts(self) -> (u16, HashMap<String, String>, B)
pub fn into_parts(self) -> (u16, HashMap<String, String>, B)
Consume into (status, headers, body).
Sourcepub const fn is_success(&self) -> bool
pub const fn is_success(&self) -> bool
Status is 2xx.
Sourcepub const fn is_redirection(&self) -> bool
pub const fn is_redirection(&self) -> bool
Status is 3xx.
Sourcepub const fn is_client_error(&self) -> bool
pub const fn is_client_error(&self) -> bool
Status is 4xx.
Sourcepub const fn is_server_error(&self) -> bool
pub const fn is_server_error(&self) -> bool
Status is 5xx.
Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Response<B>where
B: Freeze,
impl<B> RefUnwindSafe for Response<B>where
B: RefUnwindSafe,
impl<B> Send for Response<B>where
B: Send,
impl<B> Sync for Response<B>where
B: Sync,
impl<B> Unpin for Response<B>where
B: Unpin,
impl<B> UnwindSafe for Response<B>where
B: UnwindSafe,
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