Skip to main content

MusicObject

Trait MusicObject 

Source
pub trait MusicObject:
    Send
    + Sync
    + Any {
    // Required methods
    fn kind(&self) -> &'static str;
    fn duration(&self) -> Time;
    fn voices<'a>(&'a self, offset: Time, out: &mut Vec<TimedAtom<'a>>);
    fn clone_box(&self) -> Box<dyn MusicObject>;
    fn as_any(&self) -> &dyn Any;
}
Expand description

A playable musical structure that can report its span and flatten to atoms.

Implementors are the concrete node types (Note, Rest, Par, Seq, and the larger forms) that compose a Music tree.

Required Methods§

Source

fn kind(&self) -> &'static str

Returns a stable, human-readable tag for this object kind.

Source

fn duration(&self) -> Time

Returns the total duration this object occupies.

Source

fn voices<'a>(&'a self, offset: Time, out: &mut Vec<TimedAtom<'a>>)

Appends the timed atoms produced by this object, shifted by offset.

Source

fn clone_box(&self) -> Box<dyn MusicObject>

Clones this object into a fresh boxed trait object.

Source

fn as_any(&self) -> &dyn Any

Returns this object as a &dyn Any for downcasting.

Trait Implementations§

Source§

impl Clone for Box<dyn MusicObject>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§