Skip to main content

StreamType

Trait StreamType 

Source
pub trait StreamType: MaybeSend + 'static {
    type Config: Default + MaybeSend;
    type Events: Clone + MaybeSend + MaybeSync + 'static;
    type Source: Source;

    // Required method
    fn create(
        config: Self::Config,
    ) -> impl Future<Output = Result<Self::Source, SourceError>>;

    // Provided method
    fn event_bus(config: &Self::Config) -> Option<Self::Events> { ... }
}
Expand description

Defines a stream type and how to create it.

This trait is implemented by marker types (Hls, File) in their respective crates. The implementation provides the config type and source type.

On wasm32, Send/Sync bounds are relaxed via MaybeSend/MaybeSync.

Required Associated Types§

Source

type Config: Default + MaybeSend

Configuration for this stream type.

Source

type Events: Clone + MaybeSend + MaybeSync + 'static

Event bus type carried by the stream config.

Concrete stream types set this to kithara_events::EventBus. Audio::new() constrains T::Events = EventBus to extract it.

Source

type Source: Source

Source implementing Source.

Required Methods§

Source

fn create( config: Self::Config, ) -> impl Future<Output = Result<Self::Source, SourceError>>

Create the source from configuration.

May also start background tasks (downloader) internally.

Provided Methods§

Source

fn event_bus(config: &Self::Config) -> Option<Self::Events>

Extract the event bus from config (if set).

Used by Audio::new() to share a single bus across the stream and the audio pipeline.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§