pub struct EventList { /* private fields */ }Expand description
Implementations§
Source§impl EventList
impl EventList
Sourcepub fn from_buffer(body: &[u8]) -> Result<Self, EventListError>
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.
Sourcepub fn from_binary_file(
file: &BinaryFile<'_>,
) -> Result<Option<Self>, EventListError>
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.
Sourcepub const fn capacity(&self) -> usize
pub const fn capacity(&self) -> usize
The number of events that the list can hold without allocating.
Sourcepub fn get(&self, index: usize) -> Option<&Event>
pub fn get(&self, index: usize) -> Option<&Event>
The event at the given index, or None if there is no such event.
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Event>
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.
Sourcepub fn append(&mut self, event: Event) -> Result<(), EventListError>
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.
Sourcepub fn insert(&mut self, event: Event) -> Result<(), EventListError>
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.
Sourcepub fn remove(&mut self, index: usize) -> Option<Event>
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.
Sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sorts the events by timestamp. Events with equal timestamps keep their order.
Sourcepub fn add_pyro_off_events(
&mut self,
duration_msec: u32,
) -> Result<(), EventListError>
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.
Sourcepub fn adjust_timestamps_by_type(
&mut self,
event_type: EventType,
delta_msec: i32,
)
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.