[−][src]Struct saphir::response::Response
Struct that wraps a hyper response + some magic
Implementations
impl<T> Response<T>
[src]
pub fn builder() -> Builder
[src]
Creates an instance of a response builder
pub fn new(body: T) -> Self
[src]
Create a new response with T as body
pub fn cookies(&self) -> &CookieJar
[src]
Get the cookies sent by the browsers
pub fn cookies_mut(&mut self) -> &mut CookieJar
[src]
Get the cookies sent by the browsers in a mutable way
pub fn map<F, U>(self, f: F) -> Response<U> where
F: FnOnce(T) -> U,
[src]
F: FnOnce(T) -> U,
Convert a response of T in a response of U
// res is Response<()> let res: Response<String> = res.map(|_ignored_body| "New body".to_string());
Methods from Deref<Target = RawResponse<T>>
pub fn status(&self) -> StatusCode
[src]
Returns the StatusCode
.
Examples
let response: Response<()> = Response::default(); assert_eq!(response.status(), StatusCode::OK);
pub fn status_mut(&mut self) -> &mut StatusCode
[src]
Returns a mutable reference to the associated StatusCode
.
Examples
let mut response: Response<()> = Response::default(); *response.status_mut() = StatusCode::CREATED; assert_eq!(response.status(), StatusCode::CREATED);
pub fn version(&self) -> Version
[src]
Returns a reference to the associated version.
Examples
let response: Response<()> = Response::default(); assert_eq!(response.version(), Version::HTTP_11);
pub fn version_mut(&mut self) -> &mut Version
[src]
Returns a mutable reference to the associated version.
Examples
let mut response: Response<()> = Response::default(); *response.version_mut() = Version::HTTP_2; assert_eq!(response.version(), Version::HTTP_2);
pub fn headers(&self) -> &HeaderMap<HeaderValue>
[src]
Returns a reference to the associated header field map.
Examples
let response: Response<()> = Response::default(); assert!(response.headers().is_empty());
pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>
[src]
Returns a mutable reference to the associated header field map.
Examples
let mut response: Response<()> = Response::default(); response.headers_mut().insert(HOST, HeaderValue::from_static("world")); assert!(!response.headers().is_empty());
pub fn extensions(&self) -> &Extensions
[src]
Returns a reference to the associated extensions.
Examples
let response: Response<()> = Response::default(); assert!(response.extensions().get::<i32>().is_none());
pub fn extensions_mut(&mut self) -> &mut Extensions
[src]
Returns a mutable reference to the associated extensions.
Examples
let mut response: Response<()> = Response::default(); response.extensions_mut().insert("hello"); assert_eq!(response.extensions().get(), Some(&"hello"));
pub fn body(&self) -> &T
[src]
Returns a reference to the associated HTTP body.
Examples
let response: Response<String> = Response::default(); assert!(response.body().is_empty());
pub fn body_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the associated HTTP body.
Examples
let mut response: Response<String> = Response::default(); response.body_mut().push_str("hello world"); assert!(!response.body().is_empty());
Trait Implementations
impl<T> Deref for Response<T>
[src]
type Target = RawResponse<T>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<T> DerefMut for Response<T>
[src]
Auto Trait Implementations
impl<T = Body<Bytes>> !RefUnwindSafe for Response<T>
impl<T> Send for Response<T> where
T: Send,
T: Send,
impl<T> Sync for Response<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Response<T> where
T: Unpin,
T: Unpin,
impl<T = Body<Bytes>> !UnwindSafe for Response<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,