Skip to main content

EventHeader

Struct EventHeader 

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

Source

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.

Source

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.

Source

pub const fn type_id(&self) -> u16

The raw event type ID.

Source

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.

Source

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.

Source

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.

Source

pub const fn flags(&self) -> EventFlags

The event’s flags.

Source

pub const fn set_flags(&mut self, flags: EventFlags)

Sets the event’s flags.

Source

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.

Source

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.

Source

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.

Source

pub const fn as_raw(&self) -> &clap_event_header

Returns this header as a shared reference to a raw, C-FFI compatible header struct.

Source

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.

Source

pub const fn into_raw(self) -> clap_event_header

Returns this header as a raw, C-FFI compatible header struct.

Source§

impl EventHeader

Source

pub const fn from_raw(header: &clap_event_header) -> &EventHeader

Gets an untyped event header from a raw header.

Source

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,

Source

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.

Source

pub const fn new_for_space( space_id: EventSpaceId<<E as Event>::EventSpace<'_>>, time: u32, flags: EventFlags, ) -> EventHeader<E>

Creates a new header for a specific event type, of a given custom event space, containing the given time and flags.

The type_id and size members are derived from the E type parameter.

Source

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,

Source§

fn clone(&self) -> EventHeader<E>

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<E> Copy for EventHeader<E>
where E: Copy,

Source§

impl<E> Debug for EventHeader<E>

Source§

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

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

impl<E> Default for EventHeader<E>
where E: for<'a> Event<EventSpace<'a> = CoreEventSpace<'a>>,

Source§

fn default() -> EventHeader<E>

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

impl<E> Eq for EventHeader<E>

Source§

impl<E> Ord for EventHeader<E>

Source§

fn cmp(&self, other: &EventHeader<E>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl<E> PartialEq for EventHeader<E>

Source§

fn eq(&self, other: &EventHeader<E>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<E> PartialOrd for EventHeader<E>

Source§

fn partial_cmp(&self, other: &EventHeader<E>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

§

impl<E> Freeze for EventHeader<E>
where PhantomData<E>: Freeze,

§

impl<E> RefUnwindSafe for EventHeader<E>

§

impl<E> Send for EventHeader<E>
where PhantomData<E>: Send,

§

impl<E> Sync for EventHeader<E>
where PhantomData<E>: Sync,

§

impl<E> Unpin for EventHeader<E>
where PhantomData<E>: Unpin,

§

impl<E> UnsafeUnpin for EventHeader<E>

§

impl<E> UnwindSafe for EventHeader<E>

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.