Skip to main content

EventList

Struct EventList 

Source
pub struct EventList { /* private fields */ }
Expand description

The events of a show, in increasing order of their timestamps.

The list does not implement FromIterator and Extend: they cannot report that memory could not be allocated. Add events with append or insert instead, which do.

Implementations§

Source§

impl EventList

Source

pub const fn new() -> Self

An empty event list.

Source

pub fn from_buffer(body: &[u8]) -> Result<Self, EventListError>

The events encoded in the body of an event list block. Trailing bytes that do not form a complete event are ignored.

§Errors

Returns EventListError::Corrupted if the events are not sorted by timestamp.

Source

pub fn from_binary_file( file: &BinaryFile<'_>, ) -> Result<Option<Self>, EventListError>

The event list of a show file, or None if the show file has no event list.

§Errors

Returns an error if the event list block is truncated or its events are not sorted by timestamp.

Source

pub const fn len(&self) -> usize

The number of events in the list.

Source

pub const fn is_empty(&self) -> bool

Whether the list has no events.

Source

pub const fn capacity(&self) -> usize

The number of events that the list can hold without allocating.

Source

pub fn as_slice(&self) -> &[Event]

The events of the list.

Source

pub fn iter(&self) -> Iter<'_, Event> ⓘ

An iterator over the events of the list.

Source

pub fn get(&self, index: usize) -> Option<&Event>

The event at the given index, or None if there is no such event.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Event>

The event at the given index, or None if there is no such event. Changing its timestamp may make the list unsorted; see sort.

Source

pub fn clear(&mut self)

Removes all events from the list.

Source

pub fn append(&mut self, event: Event) -> Result<(), EventListError>

Appends an event to the end of the list.

§Errors

Returns EventListError::OutOfOrder if the event is earlier than the last event of the list, and EventListError::OutOfMemory if memory could not be allocated. The list is left intact then.

Source

pub fn insert(&mut self, event: Event) -> Result<(), EventListError>

Inserts an event after the last event whose timestamp is not later than that of the event.

§Errors

Returns EventListError::OutOfMemory if memory could not be allocated; the list is left intact then.

Source

pub fn remove(&mut self, index: usize) -> Option<Event>

Removes the event at the given index and returns it, or returns None if there is no such event.

Source

pub fn is_sorted(&self) -> bool

Whether the events are sorted by timestamp.

Source

pub fn sort(&mut self)

Sorts the events by timestamp. Events with equal timestamps keep their order.

Source

pub fn add_pyro_off_events( &mut self, duration_msec: u32, ) -> Result<(), EventListError>

Makes every pyro ignition last at most the given duration, in milliseconds: an off event is added after every on event whose channel is not turned off by then. A later off event of the channel is removed then. Off events that would come after u32::MAX are placed there.

§Errors

Returns EventListError::OutOfMemory if memory could not be allocated; the list is left intact then.

Source

pub fn adjust_timestamps_by_type( &mut self, event_type: EventType, delta_msec: i32, )

Moves the events of the given type by the given number of milliseconds, and sorts the list. Timestamps are clamped to the range of u32.

Trait Implementations§

Source§

impl Clone for EventList

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

impl Debug for EventList

Source§

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

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

impl Default for EventList

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for EventList

Source§

impl Hash for EventList

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> IntoIterator for &'a EventList

Source§

type Item = &'a Event

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Event>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for EventList

Source§

type Item = Event

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Event>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for EventList

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EventList

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.