pub struct Store<Object> { /* private fields */ }
Expand description
A reference object store implementation
Note
You must call Store::clear_for_disconnect
before the object store is
dropped. Otherwise, the object store will panic.
Implementations§
source§impl<O> Store<O>
impl<O> Store<O>
sourcepub fn clear_for_disconnect<Ctx>(&mut self, server_ctx: &mut Ctx::ServerContext)where
Ctx: Client,
O: AnyObject + Object<Ctx>,
pub fn clear_for_disconnect<Ctx>(&mut self, server_ctx: &mut Ctx::ServerContext)where Ctx: Client, O: AnyObject + Object<Ctx>,
Remove all objects from the store. MUST be called before the store is
dropped, to ensure on_disconnect
is called for all objects.
Trait Implementations§
source§impl<O: AnyObject> EventSource<StoreUpdate> for Store<O>
impl<O: AnyObject> EventSource<StoreUpdate> for Store<O>
source§impl<O: AnyObject> Store<O> for Store<O>
impl<O: AnyObject> Store<O> for Store<O>
§type ByType<'a, T>
where
O: 'a,
T: MonoObject + 'a = impl Iterator<Item = (u32, &'a T)> + 'a
type ByType<'a, T> where O: 'a, T: MonoObject + 'a = impl Iterator<Item = (u32, &'a T)> + 'a
Type of iterator returned by
by_type
§type IdsByType<'a, T>
where
O: 'a,
T: 'static = impl Iterator<Item = u32> + 'a
type IdsByType<'a, T> where O: 'a, T: 'static = impl Iterator<Item = u32> + 'a
Type of iterator returned by
ids_by_type_mut
source§fn insert<T: Into<O> + 'static>(
&mut self,
object_id: u32,
object: T
) -> Result<&mut T, T>
fn insert<T: Into<O> + 'static>( &mut self, object_id: u32, object: T ) -> Result<&mut T, T>
Insert object into the store with the given ID. Returns a unique
reference to the inserted object if successful, Err(T) if
the ID is already in use. Read more
source§fn insert_with_state<T: Into<O> + MonoObject + 'static>(
&mut self,
object_id: u32,
object: T
) -> Result<(&mut T, &mut T::SingletonState), T>
fn insert_with_state<T: Into<O> + MonoObject + 'static>( &mut self, object_id: u32, object: T ) -> Result<(&mut T, &mut T::SingletonState), T>
Insert object into the store with the given ID. Returns a unique
reference to the inserted object and its singleton state if
successful, Err(T) if the ID is already in use.
source§fn allocate<T: Into<O> + 'static>(
&mut self,
object: T
) -> Result<(u32, &mut T), T>
fn allocate<T: Into<O> + 'static>( &mut self, object: T ) -> Result<(u32, &mut T), T>
Allocate a new ID for the client, associate
object
for it. This is for
inserting server allocated objects.
According to the wayland spec, the ID must start from 0xff000000source§fn remove(&mut self, object_id: u32) -> Option<O>
fn remove(&mut self, object_id: u32) -> Option<O>
Remove an object from the store. Returns the removed object if it is
found.
source§fn get_state<T: MonoObject>(&self) -> Option<&T::SingletonState>
fn get_state<T: MonoObject>(&self) -> Option<&T::SingletonState>
Returns the singleton state associated with an object type. Returns
None
if no object of that type is in the store, or if the
object type does not have a singleton state. Read moresource§fn get_state_mut<T: MonoObject>(&mut self) -> Option<&mut T::SingletonState>
fn get_state_mut<T: MonoObject>(&mut self) -> Option<&mut T::SingletonState>
See
Store::get_state
source§fn get_with_state<T: MonoObject>(
&self,
id: u32
) -> Result<(&T, &T::SingletonState), GetError>
fn get_with_state<T: MonoObject>( &self, id: u32 ) -> Result<(&T, &T::SingletonState), GetError>
Get a reference an object with its associated singleton state Read more
source§fn get_with_state_mut<'a, T: MonoObject>(
&'a mut self,
id: u32
) -> Result<(&'a mut T, &'a mut T::SingletonState), GetError>
fn get_with_state_mut<'a, T: MonoObject>( &'a mut self, id: u32 ) -> Result<(&'a mut T, &'a mut T::SingletonState), GetError>
Get a unique reference to an object with its associated singleton
state Read more
source§fn get<T: 'static>(&self, object_id: u32) -> Result<&T, GetError>
fn get<T: 'static>(&self, object_id: u32) -> Result<&T, GetError>
Get a reference to an object from the store, and cast it down to the
concrete type.
source§fn get_mut<T: 'static>(&mut self, id: u32) -> Result<&mut T, GetError>
fn get_mut<T: 'static>(&mut self, id: u32) -> Result<&mut T, GetError>
Get a unique reference to an object from the store, and cast it down
to the concrete type.
source§fn try_insert_with(&mut self, id: u32, f: impl FnOnce() -> O) -> Option<&mut O>
fn try_insert_with(&mut self, id: u32, f: impl FnOnce() -> O) -> Option<&mut O>
Try to insert an object into the store with the given ID, the object
is created by calling the closure
f
. f
is never called
if the ID already exists in the store.source§fn try_insert_with_state<T: Into<O> + MonoObject + 'static>(
&mut self,
id: u32,
f: impl FnOnce(&mut T::SingletonState) -> T
) -> Option<(&mut T, &mut T::SingletonState)>
fn try_insert_with_state<T: Into<O> + MonoObject + 'static>( &mut self, id: u32, f: impl FnOnce(&mut T::SingletonState) -> T ) -> Option<(&mut T, &mut T::SingletonState)>
Try to insert an object into the store with the given ID, the object
is created by calling the closure
f
with the singleton state
that’s associated with the object type. f
is never called
if the ID already exists in the store.source§fn by_type<T: MonoObject>(&self) -> Self::ByType<'_, T>
fn by_type<T: MonoObject>(&self) -> Self::ByType<'_, T>
Returns an iterator for all objects in the store with a specific
type.
source§fn ids_by_type<T: 'static>(&self) -> Self::IdsByType<'_, T>
fn ids_by_type<T: 'static>(&self) -> Self::IdsByType<'_, T>
Returns an iterator that yields all the object IDs for objects in the
store with a specific type.
Auto Trait Implementations§
impl<Object> !RefUnwindSafe for Store<Object>
impl<Object> !Send for Store<Object>
impl<Object> !Sync for Store<Object>
impl<Object> Unpin for Store<Object>where Object: Unpin,
impl<Object> !UnwindSafe for Store<Object>
Blanket Implementations§
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,
source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,
source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.