bt_a2dp::media_task

Trait MediaTask

Source
pub trait MediaTask: Send {
    // Required methods
    fn finished(&mut self) -> BoxFuture<'static, Result<(), MediaTaskError>>;
    fn stop(&mut self) -> Result<(), MediaTaskError>;

    // Provided method
    fn result(&mut self) -> Option<Result<(), MediaTaskError>> { ... }
}
Expand description

MediaTasks represent a media stream being actively processed (sent or received from a peer). They are are created by MediaTaskRunner::start. Typically a MediaTask will run a background task that is active until dropped or MediaTask::stop is called.

Required Methods§

Source

fn finished(&mut self) -> BoxFuture<'static, Result<(), MediaTaskError>>

Returns a Future that finishes when the running media task finshes for any reason. Should return a future that immediately resolves if this task is finished.

Source

fn stop(&mut self) -> Result<(), MediaTaskError>

Stops the task normally, signalling to all waiters Ok(()). Returns the result sent to MediaTask::finished futures, which may be different from Ok(()). When this function returns, is is good practice to ensure the MediaStream that started this task is also dropped.

Provided Methods§

Source

fn result(&mut self) -> Option<Result<(), MediaTaskError>>

Returns the result if this task has finished, and None otherwise

Implementors§