Struct Segment

Source
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(self, name: String) -> Self

Gives this Segment a name, used to seed its Rng, and returns the new named version. Useful if you want certain segments to be repeated/reproduced (i.e. be rendered with the same Rng).

Source

pub fn unnamed(self) -> Self

Removes the Segment’s a name, if it has one, returning the resulting unnamed segment.

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§

fn is_empty(&self) -> bool
where T: PartialOrd,

🔬This is a nightly-only experimental API. (range_bounds_is_empty)
Returns true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. 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§

fn is_empty(&self) -> bool
where T: PartialOrd,

🔬This is a nightly-only experimental API. (range_bounds_is_empty)
Returns true if the range contains no items. One-sided ranges (RangeFrom, etc) always return false. Read more
Source§

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

Source§

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 Freeze for Segment

§

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>,

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V