pub struct EventTypeId { /* private fields */ }Expand description
Stable identifier for an event type. Pairs Rust’s
std::any::TypeId (the bus’s downcast key) with a string
name (what :describe-events prints). Hash / Eq use the
TypeId only – two registrations with the same struct but
different names would collide on the bus side, which is the
behaviour we want. Nothing detects such a duplicate: registering the same
type twice with register_event! fails to compile (conflicting Event
impls), but two types sharing a name both land in
EVENT_DESCRIPTORS, and the by-name lookups return whichever the linker
placed first.
§Examples
use std::any::TypeId;
use lattice_protocol::event_registry::EventTypeId;
struct Indexed;
let a = EventTypeId::of::<Indexed>("my-plugin.indexed");
let b = EventTypeId::new(TypeId::of::<Indexed>(), "another-name");
assert_eq!(a, b); // identity is the Rust type, not the name
assert_eq!(a.name(), "my-plugin.indexed");
assert_eq!(a.rust_type_id(), TypeId::of::<Indexed>());Implementations§
Source§impl EventTypeId
impl EventTypeId
Trait Implementations§
Source§impl Clone for EventTypeId
impl Clone for EventTypeId
Source§fn clone(&self) -> EventTypeId
fn clone(&self) -> EventTypeId
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for EventTypeId
Source§impl Debug for EventTypeId
impl Debug for EventTypeId
impl Eq for EventTypeId
Source§impl Hash for EventTypeId
impl Hash for EventTypeId
Auto Trait Implementations§
impl Freeze for EventTypeId
impl RefUnwindSafe for EventTypeId
impl Send for EventTypeId
impl Sync for EventTypeId
impl Unpin for EventTypeId
impl UnsafeUnpin for EventTypeId
impl UnwindSafe for EventTypeId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.