Struct runa_core::client::Store

source ·
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>

source

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<Object: Debug> Debug for Store<Object>

source§

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

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

impl<Object> Default for Store<Object>

source§

fn default() -> Self

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

impl<Object> Drop for Store<Object>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<O: AnyObject> EventSource<StoreUpdate> for Store<O>

§

type Source = impl Stream<Item = StoreUpdate> + 'static

Type of event stream you get from this event source.
source§

fn subscribe(&self) -> Self::Source

Get a stream of events from the event source.
source§

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 of iterator returned by by_type
§

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>

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>

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>

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 0xff000000
source§

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>

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 more
source§

fn get_state_mut<T: MonoObject>(&mut self) -> Option<&mut T::SingletonState>

source§

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>

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>

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>

Get a unique reference to an object from the store, and cast it down to the concrete type.
source§

fn contains(&self, id: u32) -> bool

Returns whether the store contains a given ID
source§

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)>

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>

Returns an iterator for all objects in the store with a specific type.
source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dstwhere T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dstwhere Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

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>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

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 Twhere U: From<T>,

const: unstable · 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<Src, Dst> LosslessTryInto<Dst> for Srcwhere Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Srcwhere Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
source§

impl<T> OverflowingAs for T

source§

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>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
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> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.