Skip to main content

SeekableStream

Trait SeekableStream 

Source
pub trait SeekableStream:
    AsyncRead
    + Unpin
    + Debug
    + Send
    + Sync
    + DynClone {
    // Required methods
    fn reset<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn len(&self) -> Option<u64>;

    // Provided methods
    fn is_empty(&self) -> Option<bool> { ... }
    fn buffer_size(&self) -> usize { ... }
}
Expand description

Enable a type implementing AsyncRead to be consumed as if it were a Stream of Bytes.

Required Methods§

Source

fn reset<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Resets the stream position to the beginning.

Source

fn len(&self) -> Option<u64>

Returns the total length of the stream in bytes, if known.

§Notes

TransportPolicy implementations will most often want to send a content-length header when len returns Some but use transfer-encoding: chunked when len returns None.

Provided Methods§

Source

fn is_empty(&self) -> Option<bool>

Returns true if the stream is empty, if known.

Source

fn buffer_size(&self) -> usize

Returns the size of the buffer to use when reading from the stream.

Trait Implementations§

Source§

impl<'clone> Clone for Box<dyn SeekableStream + 'clone>

Source§

fn clone(&self) -> Box<dyn SeekableStream + 'clone>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn SeekableStream + Send + 'clone>

Source§

fn clone(&self) -> Box<dyn SeekableStream + Send + 'clone>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn SeekableStream + Sync + 'clone>

Source§

fn clone(&self) -> Box<dyn SeekableStream + Sync + 'clone>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn SeekableStream + Sync + Send + 'clone>

Source§

fn clone(&self) -> Box<dyn SeekableStream + Sync + Send + 'clone>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<Box<dyn SeekableStream>> for Body

Source§

fn from(seekable_stream: Box<dyn SeekableStream>) -> Body

Converts to this type from the input type.
Source§

impl Stream for dyn SeekableStream

Source§

type Item = Result<Bytes, Error>

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut (dyn SeekableStream + 'static)>, cx: &mut Context<'_>, ) -> Poll<Option<<dyn SeekableStream as Stream>::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§