[][src]Struct rocket::response::Stream

pub struct Stream<T: Read>(_, _);

Streams a response to a client from an arbitrary Reader 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]

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.

Returns Ok if a Response could be generated successfully. Otherwise, returns an Err with a failing Status. Read more

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());

Performs the conversion.

impl<T: Read + Debug> Debug for Stream<T>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for Stream<T> where
    T: Send

impl<T> Sync for Stream<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Typeable for T where
    T: Any

Get the TypeId of this object.