[−][src]Struct sharp_pencil::wrappers::Response
Response type. It is just one container with a couple of parameters (headers, body, status code etc).
Fields
status_code: u16
The HTTP Status code number
headers: Headers
body: Option<Box<dyn BodyWrite>>
Implementations
impl Response
[src]
pub fn new<T: 'static + BodyWrite>(body: T) -> Response
[src]
Create a Response
. By default, the status code is 200
and content type is "text/html; charset=UTF-8".
Remember to set content length if necessary.
Mostly you should just get a response that is converted
from other types, which set the content length automatically.
For example:
// Content length is set automatically let response = Response::from("Hello");
pub fn new_empty() -> Response
[src]
Create an empty response without body.
pub fn status_name(&self) -> &str
[src]
Get status name.
pub fn content_type(&self) -> Option<&ContentType>
[src]
Returns the response content type if available.
pub fn set_content_type(&mut self, mimetype: &str)
[src]
Set response content type. If the mimetype passed is a
mimetype starting with text/
or something that needs a charset,
the charset(UTF-8) parameter is appended to it.
pub fn content_length(&self) -> Option<usize>
[src]
Returns the response content length if available.
pub fn set_content_length(&mut self, value: usize)
[src]
Set content length.
pub fn set_cookie(&mut self, cookie: SetCookie)
[src]
Sets cookie.
Trait Implementations
impl Debug for Response
[src]
impl<'a> From<&'a [u8]> for Response
[src]
fn from(bytes: &'a [u8]) -> Response
[src]
Convert to response body. The content length is set automatically.
impl<'a> From<&'a str> for Response
[src]
fn from(s: &'a str) -> Response
[src]
Convert to response body. The content length is set automatically.
impl From<File> for Response
[src]
fn from(f: File) -> Response
[src]
Convert to response body. The content length is set automatically if file size is available from metadata.
impl From<String> for Response
[src]
fn from(s: String) -> Response
[src]
Convert a new string to response body. The content length is set automatically.
impl From<Vec<u8>> for Response
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl !Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
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> DebugAny for T where
T: Any + Debug,
[src]
T: Any + Debug,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> UnsafeAny for T where
T: Any,
T: Any,