[−][src]Struct saphir::SyncResponse
A Structure which represent a fully mutable http response
Methods
impl SyncResponse
[src]
pub fn new() -> Self
[src]
pub fn status<T>(&mut self, status: T) -> &mut SyncResponse where
StatusCode: HttpTryFrom<T>,
[src]
StatusCode: HttpTryFrom<T>,
Set the HTTP status for this response.
This function will configure the HTTP status code of the Response
that
will be returned from Builder::build
.
By default this is 200
.
Examples
let response = SyncResponse::new() .status(200) .build_response() .unwrap();
pub fn version(&mut self, version: Version) -> &mut SyncResponse
[src]
Set the HTTP version for this response.
This function will configure the HTTP version of the Response
that
will be returned from Builder::build
.
By default this is HTTP/1.1
Examples
let response = SyncResponse::new() .version(Version::HTTP_2) .build_response() .unwrap();
pub fn header<K, V>(&mut self, key: K, value: V) -> &mut SyncResponse where
HeaderName: HttpTryFrom<K>,
HeaderValue: HttpTryFrom<V>,
[src]
HeaderName: HttpTryFrom<K>,
HeaderValue: HttpTryFrom<V>,
Appends a header to this response builder.
This function will append the provided key/value as a header to the
internal HeaderMap
being constructed. Essentially this is equivalent
to calling HeaderMap::append
.
Examples
let response = SyncResponse::new() .header("Content-Type", "text/html") .header("X-Custom-Foo", "bar") .build_response() .unwrap();
pub fn parsed_header(&mut self, headers: Headers) -> &mut SyncResponse
[src]
A convinient function to constuct the response headers from a Headers struct
pub fn extension<T>(&mut self, extension: T) -> &mut SyncResponse where
T: Any + Send + Sync + 'static,
[src]
T: Any + Send + Sync + 'static,
Adds an extension to this builder
Examples
let response = SyncResponse::new() .extension("My Extension") .build_response() .unwrap(); assert_eq!(response.extensions().get::<&'static str>(), Some(&"My Extension"));
pub fn cookie(&mut self, cookie: Cookie<'static>) -> &mut SyncResponse
[src]
Set a cookie with the Set-Cookie header
pub fn body<B: 'static + ToBody>(&mut self, body: B) -> &mut SyncResponse
[src]
Adds a body to a response
Examples
let response = SyncResponse::new() .body("this is a payload") .build_response() .unwrap();
pub fn build_response(self) -> Result<Response<Body>, Error>
[src]
Auto Trait Implementations
impl !RefUnwindSafe for SyncResponse
impl !Send for SyncResponse
impl !Sync for SyncResponse
impl Unpin for SyncResponse
impl !UnwindSafe for SyncResponse
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[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.
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>,