Trait stream_download::source::SourceStream

source ·
pub trait SourceStream: Stream<Item = Result<Bytes, Self::StreamError>> + Unpin + Send + Sync + Sized + 'static {
    type Url: Send;
    type StreamError: Error + Send;

    // Required methods
    fn create(url: Self::Url) -> impl Future<Output = Result<Self>> + Send;
    fn content_length(&self) -> Option<u64>;
    fn seek_range(
        &mut self,
        start: u64,
        end: Option<u64>,
    ) -> impl Future<Output = Result<()>> + Send;
}
Expand description

Represents a remote resource that can be streamed over the network. Streaming over http is implemented via the HttpStream implementation if the http feature is enabled.

The implementation must also implement the Stream trait.

Required Associated Types§

source

type Url: Send

URL of the remote resource.

source

type StreamError: Error + Send

Error type thrown by the underlying stream.

Required Methods§

source

fn create(url: Self::Url) -> impl Future<Output = Result<Self>> + Send

Creates an instance of the stream.

source

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

Returns the size of the remote resource in bytes. The result should be None if the stream is infinite or doesn’t have a known length.

source

fn seek_range( &mut self, start: u64, end: Option<u64>, ) -> impl Future<Output = Result<()>> + Send

Seeks to a specific position in the stream. This method is only called if the requested range has not been downloaded, so this method should jump to the requested position in the stream as quickly as possible.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<C: Client> SourceStream for HttpStream<C>

Available on crate feature http only.
§

type Url = <C as Client>::Url

§

type StreamError = <C as Client>::Error