[−][src]Struct rouille::ResponseBody
An opaque type that represents the body of a response.
You can't access the inside of this struct, but you can build one by using one of the provided constructors.
Example
use rouille::ResponseBody; let body = ResponseBody::from_string("hello world");
Methods
impl ResponseBody
[src]
pub fn empty() -> ResponseBody
[src]
Builds a ResponseBody
that doesn't return any data.
Example
use rouille::ResponseBody; let body = ResponseBody::empty();
pub fn from_reader<R>(data: R) -> ResponseBody where
R: Read + Send + 'static,
[src]
R: Read + Send + 'static,
Builds a new ResponseBody
that will read the data from a Read
.
Note that this is suboptimal compared to other constructors because the length isn't known in advance.
Example
use std::io; use std::io::Read; use rouille::ResponseBody; let body = ResponseBody::from_reader(io::stdin().take(128));
pub fn from_data<D>(data: D) -> ResponseBody where
D: Into<Vec<u8>>,
[src]
D: Into<Vec<u8>>,
Builds a new ResponseBody
that returns the given data.
Example
use rouille::ResponseBody; let body = ResponseBody::from_data(vec![12u8, 97, 34]);
pub fn from_file(file: File) -> ResponseBody
[src]
Builds a new ResponseBody
that returns the content of the given file.
Example
use std::fs::File; use rouille::ResponseBody; let file = File::open("page.html").unwrap(); let body = ResponseBody::from_file(file);
pub fn from_string<S>(data: S) -> ResponseBody where
S: Into<String>,
[src]
S: Into<String>,
Builds a new ResponseBody
that returns an UTF-8 string.
Example
use rouille::ResponseBody; let body = ResponseBody::from_string("hello world");
pub fn into_reader_and_size(self) -> (Box<dyn Read + Send>, Option<usize>)
[src]
Extracts the content of the response.
Returns the size of the body and the body itself. If the size is None
, then it is
unknown.
Auto Trait Implementations
impl Unpin for ResponseBody
impl !Sync for ResponseBody
impl Send for ResponseBody
impl !UnwindSafe for ResponseBody
impl !RefUnwindSafe for ResponseBody
Blanket Implementations
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> 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,