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
EventSpacetype must be theEventSpaceimplementation that it belongs to; TYPE_IDmust 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§
Required Associated Types§
Sourcetype EventSpace<'a>: EventSpace<'a>
type EventSpace<'a>: EventSpace<'a>
The event space this event type is a part of.
Provided Methods§
Sourcefn flags(&self) -> EventFlags
fn flags(&self) -> EventFlags
Returns the EventFlags of this event.
Sourcefn set_flags(&mut self, flags: EventFlags)
fn set_flags(&mut self, flags: EventFlags)
Sets the EventFlags of this event.
Sourcefn with_flags(self, flags: EventFlags) -> Self
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.
Sourcefn with_time(self, time: u32) -> Self
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.
Sourcefn header(&self) -> &EventHeader<Self>
fn header(&self) -> &EventHeader<Self>
Returns a shared, immutable reference to this event’s header.
Sourcefn header_mut(&mut self) -> &mut EventHeader<Self>
fn header_mut(&mut self) -> &mut EventHeader<Self>
Returns an exclusive, mutable reference to this event’s header.
Sourcefn as_unknown(&self) -> &UnknownEvent
fn as_unknown(&self) -> &UnknownEvent
Returns this event as a type-erased UnknownEvent.
Sourcefn raw_header(&self) -> &clap_event_header
fn raw_header(&self) -> &clap_event_header
Returns a shared, immutable reference to the raw, C-FFI compatible representation of this header’s event.
Sourceunsafe fn raw_header_mut(&mut self) -> &mut clap_event_header
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".