pub trait MediaTask: Send {
// Required methods
fn finished(
&mut self,
) -> BoxFuture<'static, Result<MediaTaskStatus, MediaTaskError>>;
fn stop(&mut self) -> Result<MediaTaskStatus, MediaTaskError>;
// Provided method
fn result(&mut self) -> Option<Result<MediaTaskStatus, 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§
Sourcefn finished(
&mut self,
) -> BoxFuture<'static, Result<MediaTaskStatus, MediaTaskError>>
fn finished( &mut self, ) -> BoxFuture<'static, Result<MediaTaskStatus, MediaTaskError>>
Returns a Future that finishes when the running media task finishes for any reason. Should return a future that immediately resolves if this task is finished.
Sourcefn stop(&mut self) -> Result<MediaTaskStatus, MediaTaskError>
fn stop(&mut self) -> Result<MediaTaskStatus, MediaTaskError>
Stops the task normally, signalling to all waiters Ok(MediaTaskStatus::Stopped). Returns the result sent to MediaTask::finished futures, which may be different from Ok(MediaTaskStatus::Stopped). When this function returns, it is good practice to ensure the MediaStream that started this task is also dropped.
Provided Methods§
Sourcefn result(&mut self) -> Option<Result<MediaTaskStatus, MediaTaskError>>
fn result(&mut self) -> Option<Result<MediaTaskStatus, MediaTaskError>>
Returns the result if this task has finished, and None otherwise
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".