Trait stream_download::source::SourceStream
source · pub trait SourceStream:
TryStream<Ok = Bytes>
+ Stream<Item = Result<Self::Ok, Self::Error>>
+ Unpin
+ Send
+ Sync
+ Sized
+ 'static {
type Params: Send;
type StreamCreationError: DecodeError + Send;
// Required methods
fn create(
params: Self::Params,
) -> impl Future<Output = Result<Self, Self::StreamCreationError>> + Send;
fn content_length(&self) -> Option<u64>;
fn seek_range(
&mut self,
start: u64,
end: Option<u64>,
) -> impl Future<Output = Result<(), Error>> + 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§
sourcetype StreamCreationError: DecodeError + Send
type StreamCreationError: DecodeError + Send
Error type thrown when creating the stream.
Required Methods§
sourcefn create(
params: Self::Params,
) -> impl Future<Output = Result<Self, Self::StreamCreationError>> + Send
fn create( params: Self::Params, ) -> impl Future<Output = Result<Self, Self::StreamCreationError>> + Send
Creates an instance of the stream.
sourcefn content_length(&self) -> Option<u64>
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.
sourcefn seek_range(
&mut self,
start: u64,
end: Option<u64>,
) -> impl Future<Output = Result<(), Error>> + Send
fn seek_range( &mut self, start: u64, end: Option<u64>, ) -> impl Future<Output = Result<(), Error>> + 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 SourceStream for OpenDalStream
Available on crate feature open-dal
only.
impl SourceStream for OpenDalStream
Available on crate feature
open-dal
only.type Params = OpenDalStreamParams
type StreamCreationError = Error
source§impl<C: Client> SourceStream for HttpStream<C>
Available on crate feature http
only.
impl<C: Client> SourceStream for HttpStream<C>
Available on crate feature
http
only.