pub struct Segment {
    pub element: Box<dyn Element>,
    pub timing: Timing,
    pub name: Option<String>,
}
Expand description

A (type-erased) Element spanning a Timing interval.

Fields§

§element: Box<dyn Element>

The element this segment represents.

§timing: Timing

The timing interval this segment spans.

§name: Option<String>

An optional name. When being rendered, this segment’s Rng are seeded with a combined hash of this name as well as the segment’s parent seed.

Implementations§

source§

impl Segment

source

pub fn new(composition_type: impl Element, timing: impl Into<Timing>) -> Segment

Creates a new Segment from a Element which starts/ends according to timing.

source

pub fn named( name: String, composition_type: impl Element, timing: impl Into<Timing> ) -> Segment

Creates a new Segment from a Element which starts/ends according to timing, and seeded by its name. Useful if you want certain segments to be repeated/reproduced (i.e. be rendered with the same Rng)

source

pub fn element_as<Element: Element>(&self) -> Option<&Element>

Gets the contained element if its type matches type Element, otherwise, None is returned.

Trait Implementations§

source§

impl Debug for Segment

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl RangeBounds<i32> for &Segment

source§

fn start_bound(&self) -> Bound<&i32>

Start index bound. Read more
source§

fn end_bound(&self) -> Bound<&i32>

End index bound. Read more
1.35.0 · source§

fn contains<U>(&self, item: &U) -> bool
where T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,

Returns true if item is contained in the range. Read more
source§

impl RangeBounds<i32> for Segment

source§

fn start_bound(&self) -> Bound<&i32>

Start index bound. Read more
source§

fn end_bound(&self) -> Bound<&i32>

End index bound. Read more
1.35.0 · source§

fn contains<U>(&self, item: &U) -> bool
where T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,

Returns true if item is contained in the range. Read more
source§

impl<'a, T: Element> TryFrom<&'a Segment> for SegmentRef<'a, T>

§

type Error = ConversionError

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Segment) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Segment

§

impl !Send for Segment

§

impl !Sync for Segment

§

impl Unpin for Segment

§

impl !UnwindSafe for Segment

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, R> RangeOps<T> for R
where T: PartialOrd, R: RangeBounds<T>,

source§

fn is_empty(&self) -> bool

Checks if an interval is empty.
source§

fn is_before(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval ends before the start of another.
source§

fn is_after(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval starts after the end of another.
source§

fn is_disjoint_from(&self, other: &impl RangeBounds<T>) -> bool

Checks if an interval has no overlap with another.
source§

fn intersects(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval has some overlap with another.
source§

fn contains_range(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval contains another.
source§

fn is_contained_by(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval is contained by another.
source§

fn begins_within(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval starts within another.
source§

fn ends_within(&self, other: &impl RangeBounds<T>) -> bool

Checks if this interval ends within another.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V