[−][src]Struct rocket::response::Stream
Streams a response to a client from an arbitrary Read
er type.
The client is sent a "chunked" response, where the chunk size is at most 4KiB. This means that at most 4KiB are stored in memory while the response is being sent. This type should be used when sending responses that are arbitrarily large in size, such as when streaming from a local socket.
Methods
impl<T: Read> Stream<T>
[src]
pub fn chunked(reader: T, chunk_size: u64) -> Stream<T>
[src]
Create a new stream from the given reader
and sets the chunk size for
each streamed chunk to chunk_size
bytes.
Example
Stream a response from whatever is in stdin
with a chunk size of 10
bytes. Note: you probably shouldn't do this.
use std::io; use rocket::response::Stream; let response = Stream::chunked(io::stdin(), 10);
Trait Implementations
impl<'r, T: Read + 'r> Responder<'r> for Stream<T>
[src]
Sends a response to the client using the "Chunked" transfer encoding. The maximum chunk size is 4KiB.
Failure
If reading from the input stream fails at any point during the response, the response is abandoned, and the response ends abruptly. An error is printed to the console with an indication of what went wrong.
impl<T: Read> From<T> for Stream<T>
[src]
Create a new stream from the given reader
.
Example
Stream a response from whatever is in stdin
. Note: you probably
shouldn't do this.
use std::io; use rocket::response::Stream; let response = Stream::from(io::stdin());
impl<T: Read + Debug> Debug for Stream<T>
[src]
Auto Trait Implementations
impl<T> Send for Stream<T> where
T: Send,
T: Send,
impl<T> Unpin for Stream<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for Stream<T> where
T: Sync,
T: Sync,
impl<T> UnwindSafe for Stream<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Stream<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Typeable for T where
T: Any,
T: Any,
impl<T> IntoCollection<T> for T
[src]
ⓘImportant traits for SmallVec<A>fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
[src]
A: Array<Item = T>,
ⓘImportant traits for SmallVec<A>fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
[src]
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T, I> AsResult<T, I> for T where
I: Input,
[src]
I: Input,