pub trait Source:
Send
+ Sized
+ 'static {
type MediaType: MediaType;
// Required methods
fn capabilities(
&mut self,
) -> impl Future<Output = Result<Vec<<Self::MediaType as MediaType>::ConfigRange>>> + Send;
fn negotiate_config(
&mut self,
available: Vec<<Self::MediaType as MediaType>::ConfigRange>,
) -> impl Future<Output = Result<<Self::MediaType as MediaType>::Config>> + Send;
fn next_event(
&mut self,
) -> impl Future<Output = Result<SourceEvent<Self::MediaType>>> + Send;
// Provided methods
fn boxed(self) -> BoxedSource<Self::MediaType> { ... }
fn boxed_cancel_safe(self) -> BoxedSourceCancelSafe<Self::MediaType>
where Self: NextEventIsCancelSafe { ... }
}Required Associated Types§
Required Methods§
fn capabilities( &mut self, ) -> impl Future<Output = Result<Vec<<Self::MediaType as MediaType>::ConfigRange>>> + Send
Sourcefn negotiate_config(
&mut self,
available: Vec<<Self::MediaType as MediaType>::ConfigRange>,
) -> impl Future<Output = Result<<Self::MediaType as MediaType>::Config>> + Send
fn negotiate_config( &mut self, available: Vec<<Self::MediaType as MediaType>::ConfigRange>, ) -> impl Future<Output = Result<<Self::MediaType as MediaType>::Config>> + Send
Provide a list of available configurations ranges. Upstream sources then filter out invalid/incompatible
configs until the “root” source then decides on the streaming config, which is then returned down the source
stack. This must always be called before trying to call Source::next_event.
§Cancel safety
This method should never be considered cancel safe, as it may leave some sources in the stack configured and others not.
Sourcefn next_event(
&mut self,
) -> impl Future<Output = Result<SourceEvent<Self::MediaType>>> + Send
fn next_event( &mut self, ) -> impl Future<Output = Result<SourceEvent<Self::MediaType>>> + Send
Fetch the next event from the source. This method should be called as much as possible to allow source to drive their internal logic without having to rely on extra tasks.
Should return SourceEvent::RenegotiationNeeded when called before negotiate_config.
§Cancel safety
The cancel safety of this method is marked using the NextEventIsCancelSafe trait
Provided Methods§
Sourcefn boxed(self) -> BoxedSource<Self::MediaType>
fn boxed(self) -> BoxedSource<Self::MediaType>
Erase the type of this source
Sourcefn boxed_cancel_safe(self) -> BoxedSourceCancelSafe<Self::MediaType>where
Self: NextEventIsCancelSafe,
fn boxed_cancel_safe(self) -> BoxedSourceCancelSafe<Self::MediaType>where
Self: NextEventIsCancelSafe,
Erase the type of this source, keeping the information that the next_event future is cancel safe
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.