pub struct EventHeader<E = ()> { /* private fields */ }Expand description
The common metadata header of all CLAP events.
All CLAP events have a common header that contains various metadata about them.
Most of that metadata is information used to discover the event’s type: type_id,
space_id and size. This is used internally by the UnknownEvent type to perform
downcasting to concrete types.
All events also carry a sample-accurate timestamp (accessible through time), as well as
some additional event flags (through flags).
Because event headers internally contain type information for the event, the EventHeader
is generic over a specific event type parameter E in order to guarantee that type_id,
space_id and size are coherent with the event’s type.
The generic parameter E can either be a concrete Event type (as returned by the
Event::header method), or () for headers of an undetermined event type (as returned by the
UnknownEvent::header method).
Implementations§
Source§impl<E> EventHeader<E>
impl<E> EventHeader<E>
Sourcepub const fn size(&self) -> u32
pub const fn size(&self) -> u32
Returns the size of this event, in bytes.
This size includes the size of the event header itself.
If you need only the size of the payload, see payload_size.
Sourcepub const fn payload_size(&self) -> u32
pub const fn payload_size(&self) -> u32
Returns the size of this event’s payload, in bytes.
This size does not include the size of the event header itself.
If you need to also account for the size of the payload, see size.
Sourcepub const fn time(&self) -> u32
pub const fn time(&self) -> u32
The timestamp at which this event occurs, in samples.
This timestamp is relative to the frame count of the current process invocation.
Sourcepub const fn set_time(&mut self, time: u32)
pub const fn set_time(&mut self, time: u32)
Sets the timestamp at which this event occurs, in samples.
This timestamp is relative to the frame count of the current process invocation.
Sourcepub const fn with_time(self, time: u32) -> EventHeader<E>
pub const fn with_time(self, time: u32) -> EventHeader<E>
Sets the timestamp at which this event occurs, in samples.
This timestamp is relative to the frame count of the current process invocation.
This method takes and returns ownership of the event header, allowing it to be used in a builder-style pattern.
Sourcepub const fn flags(&self) -> EventFlags
pub const fn flags(&self) -> EventFlags
The event’s flags.
Sourcepub const fn set_flags(&mut self, flags: EventFlags)
pub const fn set_flags(&mut self, flags: EventFlags)
Sets the event’s flags.
Sourcepub const fn with_flags(self, flags: EventFlags) -> EventHeader<E>
pub const fn with_flags(self, flags: EventFlags) -> EventHeader<E>
Sets the event’s flags.
This method takes and returns ownership of the event header, allowing it to be used in a builder-style pattern.
Sourcepub const unsafe fn from_raw_unchecked(
header: &clap_event_header,
) -> &EventHeader<E>
pub const unsafe fn from_raw_unchecked( header: &clap_event_header, ) -> &EventHeader<E>
Gets a shared reference typed event header from a mutable shared to a raw, C-FFI compatible header struct, without performing any checks.
§Safety
The caller must ensure the given header matches the given event type E.
Sourcepub const unsafe fn from_raw_unchecked_mut(
header: &mut clap_event_header,
) -> &mut EventHeader<E>
pub const unsafe fn from_raw_unchecked_mut( header: &mut clap_event_header, ) -> &mut EventHeader<E>
Gets a mutable reference typed event header from a mutable reference to a raw, C-FFI compatible header struct, without performing any checks.
§Safety
The caller must ensure the given header matches the given event type E.
Sourcepub const fn as_raw(&self) -> &clap_event_header
pub const fn as_raw(&self) -> &clap_event_header
Returns this header as a shared reference to a raw, C-FFI compatible header struct.
Sourcepub const unsafe fn as_raw_mut(&mut self) -> &mut clap_event_header
pub const unsafe fn as_raw_mut(&mut self) -> &mut clap_event_header
Returns this header as a mutable reference to a raw, C-FFI compatible header struct.
§Safety
This method allows mutating the event header’s fields, most notably type_, size and
space_id.
Modifying those fields may trigger Undefined Behavior, as it can make other readers of this event treat it as a type or size that it is actually not.
Sourcepub const fn into_raw(self) -> clap_event_header
pub const fn into_raw(self) -> clap_event_header
Returns this header as a raw, C-FFI compatible header struct.
Source§impl EventHeader
impl EventHeader
Sourcepub const fn from_raw(header: &clap_event_header) -> &EventHeader
pub const fn from_raw(header: &clap_event_header) -> &EventHeader
Gets an untyped event header from a raw header.
Sourcepub const fn space_id(&self) -> Option<EventSpaceId>
pub const fn space_id(&self) -> Option<EventSpaceId>
The untyped event space ID, from this untyped event header.
Source§impl<E> EventHeader<E>where
E: Event,
impl<E> EventHeader<E>where
E: Event,
Sourcepub const fn new_core(time: u32, flags: EventFlags) -> EventHeader<E>where
E: for<'a> Event<EventSpace<'a> = CoreEventSpace<'a>>,
pub const fn new_core(time: u32, flags: EventFlags) -> EventHeader<E>where
E: for<'a> Event<EventSpace<'a> = CoreEventSpace<'a>>,
Creates a new header for a specific core event type, containing the given time and flags.
The type_id, space_id and size
members are derived from the E type parameter.
See the event_types module for a list of all the supported core
event types.
Sourcepub const fn new_for_space(
space_id: EventSpaceId<<E as Event>::EventSpace<'_>>,
time: u32,
flags: EventFlags,
) -> EventHeader<E>
pub const fn new_for_space( space_id: EventSpaceId<<E as Event>::EventSpace<'_>>, time: u32, flags: EventFlags, ) -> EventHeader<E>
Sourcepub const fn space_id(&self) -> EventSpaceId<<E as Event>::EventSpace<'static>>
pub const fn space_id(&self) -> EventSpaceId<<E as Event>::EventSpace<'static>>
The typed event space ID from this event header.
Trait Implementations§
Source§impl<E> Clone for EventHeader<E>where
E: Clone,
impl<E> Clone for EventHeader<E>where
E: Clone,
Source§fn clone(&self) -> EventHeader<E>
fn clone(&self) -> EventHeader<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more