Skip to main content

EventIdMap

Struct EventIdMap 

Source
pub struct EventIdMap<E, V>(/* private fields */)
where
    E: Borrow<EventId>;
Available on crate feature state-res only.
Expand description

A map of event IDs to a type V.

Implementations§

Source§

impl<E, V> EventIdMap<E, V>
where E: Borrow<EventId>,

Source

pub fn new() -> EventIdMap<E, V>

Create an empty EventIdMap.

Source

pub fn with_capacity(capacity: usize) -> EventIdMap<E, V>

Create an empty EventIdMap with the given capacity.

Source

pub fn clear(&mut self)

Clears the map, removing all key-value pairs.

Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

Source

pub fn iter(&self) -> EventIdMapIter<'_, E, V>

Gets an iterator over the entries of the map.

Source

pub fn keys(&self) -> EventIdMapKeys<'_, E, V>

Gets an iterator over the keys of the map.

Source

pub fn into_keys(self) -> EventIdMapIntoKeys<E, V>

Gets an iterator over the keys of the map.

Source

pub fn values(&self) -> EventIdMapValues<'_, E, V>

Gets an iterator over the values of the map.

Source

pub fn into_values(self) -> EventIdMapIntoValues<E, V>

Gets an iterator over the values of the map.

Source§

impl<E, V> EventIdMap<E, V>
where E: Borrow<EventId> + Eq + Hash,

Source

pub fn contains_event_id(&self, event_id: &EventId) -> bool

Returns true if the map contains a value for the specified event ID.

Source

pub fn get(&self, event_id: &EventId) -> Option<&V>

Returns a reference to the value corresponding to given event ID.

Source

pub fn get_mut(&mut self, event_id: &EventId) -> Option<&mut V>

Returns a mutable reference to the value corresponding to given event ID.

Source

pub fn get_key_value(&self, event_id: &EventId) -> Option<(&E, &V)>

Returns the key-value pair corresponding to the supplied event ID.

Source

pub fn entry(&mut self, event_id: E) -> EventIdMapEntry<'_, E, V>

Gets the given event ID’s corresponding entry in the map for in-place manipulation.

Source

pub fn insert(&mut self, event_id: E, value: V) -> Option<V>

Inserts a key-value pair into the map.

If the map did not have this event ID present, None is returned.

If the map did have this event ID present, the value is updated, and the old value is returned.

Source

pub fn remove(&mut self, event_id: &EventId) -> Option<V>

Removes an event ID from the map, returning the value at the event ID if the event ID was previously in the map.

Source

pub fn remove_entry(&mut self, event_id: &EventId) -> Option<(E, V)>

Removes an event ID from the map, returning the stored event ID and value if the event ID was previously in the map.

Trait Implementations§

Source§

impl<E, V> Clone for EventIdMap<E, V>
where E: Clone + Borrow<EventId>, V: Clone,

Source§

fn clone(&self) -> EventIdMap<E, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E, V> Debug for EventIdMap<E, V>
where E: Debug + Borrow<EventId>, V: Debug,

Source§

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

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

impl<E, V> Default for EventIdMap<E, V>
where E: Borrow<EventId>,

Source§

fn default() -> EventIdMap<E, V>

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

impl<E, V> Extend<(E, V)> for EventIdMap<E, V>
where E: Borrow<EventId> + Hash + Eq,

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (E, V)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<E, V, const N: usize> From<[(E, V); N]> for EventIdMap<E, V>
where E: Borrow<EventId> + Hash + Eq,

Source§

fn from(value: [(E, V); N]) -> EventIdMap<E, V>

Converts to this type from the input type.
Source§

impl<E, V> FromIterator<(E, V)> for EventIdMap<E, V>
where E: Borrow<EventId> + Hash + Eq,

Source§

fn from_iter<T>(iter: T) -> EventIdMap<E, V>
where T: IntoIterator<Item = (E, V)>,

Creates a value from an iterator. Read more
Source§

impl<E, V> Index<&EventId> for EventIdMap<E, V>
where E: Borrow<EventId> + Hash + Eq,

Source§

type Output = V

The returned type after indexing.
Source§

fn index( &self, event_id: &EventId, ) -> &<EventIdMap<E, V> as Index<&EventId>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, E, V> IntoIterator for &'a EventIdMap<E, V>
where E: Borrow<EventId>,

Source§

type Item = (&'a E, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = EventIdMapIter<'a, E, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a EventIdMap<E, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<E, V> IntoIterator for EventIdMap<E, V>
where E: Borrow<EventId>,

Source§

type Item = (E, V)

The type of the elements being iterated over.
Source§

type IntoIter = EventIdMapIntoIter<E, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <EventIdMap<E, V> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<E, V> Freeze for EventIdMap<E, V>

§

impl<E, V> RefUnwindSafe for EventIdMap<E, V>

§

impl<E, V> Send for EventIdMap<E, V>
where E: Send, V: Send,

§

impl<E, V> Sync for EventIdMap<E, V>
where E: Sync, V: Sync,

§

impl<E, V> Unpin for EventIdMap<E, V>
where E: Unpin, V: Unpin,

§

impl<E, V> UnsafeUnpin for EventIdMap<E, V>

§

impl<E, V> UnwindSafe for EventIdMap<E, V>
where E: UnwindSafe, V: UnwindSafe,

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> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> JsonCastable<CanonicalJsonValue> for T

Source§

impl<T> JsonCastable<Value> for T