Skip to main content

Event

Trait Event 

Source
pub unsafe trait Event:
    Sized
    + AsRef<UnknownEvent>
    + 'static {
    type EventSpace<'a>: EventSpace<'a>;

    const TYPE_ID: u16;

    // Provided methods
    fn flags(&self) -> EventFlags { ... }
    fn set_flags(&mut self, flags: EventFlags) { ... }
    fn with_flags(self, flags: EventFlags) -> Self { ... }
    fn time(&self) -> u32 { ... }
    fn set_time(&mut self, time: u32) { ... }
    fn with_time(self, time: u32) -> Self { ... }
    fn header(&self) -> &EventHeader<Self> { ... }
    fn header_mut(&mut self) -> &mut EventHeader<Self> { ... }
    fn as_unknown(&self) -> &UnknownEvent { ... }
    fn raw_header(&self) -> &clap_event_header { ... }
    unsafe fn raw_header_mut(&mut self) -> &mut clap_event_header { ... }
}
Expand description

A specific event type.

§Safety

This trait allows casting to and from pointers to raw event headers. This means implementers of this trait must enforce the following:

  • The EventSpace type must be the EventSpace implementation that it belongs to;
  • TYPE_ID must match the event ID from its type.
  • The type must be ABI-compatible with the matching raw, C-FFI compatible event type.
  • All instances of this type must be initialized and valid.

Required Associated Constants§

Source

const TYPE_ID: u16

The raw event type identifier for this event type.

This MUST match the identifier defined in the CLAP specification for this event.

Required Associated Types§

Source

type EventSpace<'a>: EventSpace<'a>

The event space this event type is a part of.

Provided Methods§

Source

fn flags(&self) -> EventFlags

Returns the EventFlags of this event.

Source

fn set_flags(&mut self, flags: EventFlags)

Sets the EventFlags of this event.

Source

fn with_flags(self, flags: EventFlags) -> Self

Builds an event with the given EventFlags, and returns it.

This is useful to use in a builder-style pattern.

Source

fn time(&self) -> u32

Returns the time stamp of this event, in samples.

Source

fn set_time(&mut self, time: u32)

Sets the time stamp of this event, in samples.

Source

fn with_time(self, time: u32) -> Self

Builds an event with the given time stamp, and returns it.

This is useful to use in a builder-style pattern.

Source

fn header(&self) -> &EventHeader<Self>

Returns a shared, immutable reference to this event’s header.

Source

fn header_mut(&mut self) -> &mut EventHeader<Self>

Returns an exclusive, mutable reference to this event’s header.

Source

fn as_unknown(&self) -> &UnknownEvent

Returns this event as a type-erased UnknownEvent.

Source

fn raw_header(&self) -> &clap_event_header

Returns a shared, immutable reference to the raw, C-FFI compatible representation of this header’s event.

Source

unsafe fn raw_header_mut(&mut self) -> &mut clap_event_header

Returns an exclusive, mutable reference to the raw, C-FFI compatible representation of this header’s event.

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Event for Midi2Event

Source§

const TYPE_ID: u16 = CLAP_EVENT_MIDI2

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for MidiEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_MIDI

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for MidiSysExEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_MIDI_SYSEX

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for NoteChokeEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_NOTE_CHOKE

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for NoteEndEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_NOTE_END

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for NoteExpressionEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_NOTE_EXPRESSION

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for NoteOffEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_NOTE_OFF

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for NoteOnEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_NOTE_ON

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for ParamGestureBeginEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_PARAM_GESTURE_BEGIN

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for ParamGestureEndEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_PARAM_GESTURE_END

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for ParamModEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_PARAM_MOD

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for ParamValueEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_PARAM_VALUE

Source§

type EventSpace<'a> = CoreEventSpace<'a>

Source§

impl Event for TransportEvent

Source§

const TYPE_ID: u16 = CLAP_EVENT_TRANSPORT

Source§

type EventSpace<'a> = CoreEventSpace<'a>