Skip to main content

Playable

Trait Playable 

Source
pub trait Playable {
    // Required methods
    fn describe(&self) -> Result<PlayableDescriptor>;
    fn render_range(&self, cx: &PlayContext) -> Result<PlayStream>;
    fn freeze(&self, cx: &PlayContext) -> Result<FrozenPlayable>;

    // Provided methods
    fn prepare(&mut self, _cx: &PlayContext) -> Result<()> { ... }
    fn render_preview(&self, cx: &PlayContext) -> Result<PlayStream> { ... }
    fn as_shape(&self) -> PlayableShape { ... }
}
Expand description

Object that can describe, render, and freeze itself into play events.

Required Methods§

Source

fn describe(&self) -> Result<PlayableDescriptor>

Returns the static descriptor for this playable.

Source

fn render_range(&self, cx: &PlayContext) -> Result<PlayStream>

Renders the playable over the context’s time range into a stream.

Source

fn freeze(&self, cx: &PlayContext) -> Result<FrozenPlayable>

Renders and captures the playable into a FrozenPlayable.

Provided Methods§

Source

fn prepare(&mut self, _cx: &PlayContext) -> Result<()>

Prepares the playable for rendering under cx; defaults to a no-op.

Source

fn render_preview(&self, cx: &PlayContext) -> Result<PlayStream>

Renders a preview stream; defaults to Playable::render_range.

Source

fn as_shape(&self) -> PlayableShape

Returns the object shape; defaults to PlayableShape::music_object.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§