pub struct Registry<T: Resource, I: TypedId, F: IdentityHandlerFactory<I>> {
    identity: F::Filter,
    pub(crate) data: RwLock<Storage<T, I>>,
    backend: Backend,
}

Fields§

§identity: F::Filter§data: RwLock<Storage<T, I>>§backend: Backend

Implementations§

source§

impl<T: Resource, I: TypedId, F: IdentityHandlerFactory<I>> Registry<T, I, F>

source

pub(crate) fn new(backend: Backend, factory: &F) -> Self

source

pub(crate) fn without_backend(factory: &F, kind: &'static str) -> Self

source§

impl<T: Resource, I: TypedId + Copy, F: IdentityHandlerFactory<I>> Registry<T, I, F>

source

pub(crate) fn prepare( &self, id_in: <F::Filter as IdentityHandler<I>>::Input ) -> FutureId<'_, I, T>

source

pub(crate) fn read<'a, A: Access<T>>( &'a self, _token: &'a mut Token<'_, A> ) -> (RwLockReadGuard<'a, Storage<T, I>>, Token<'a, T>)

Acquire read access to this Registry’s contents.

The caller must present a mutable reference to a Token<A>, for some type A that comes before this Registry’s resource type T in the lock ordering. A Token<Root> grants permission to lock any field; see Token::root.

Once the read lock is acquired, return a new Token<T>, along with a read guard for this Registry’s Storage, which can be indexed by id to get at the actual resources.

The borrow checker ensures that the caller cannot again access its Token<A> until it has dropped both the guard and the Token<T>.

See the Hub type for more details on locking.

source

pub(crate) fn write<'a, A: Access<T>>( &'a self, _token: &'a mut Token<'_, A> ) -> (RwLockWriteGuard<'a, Storage<T, I>>, Token<'a, T>)

Acquire write access to this Registry’s contents.

The caller must present a mutable reference to a Token<A>, for some type A that comes before this Registry’s resource type T in the lock ordering. A Token<Root> grants permission to lock any field; see Token::root.

Once the lock is acquired, return a new Token<T>, along with a write guard for this Registry’s Storage, which can be indexed by id to get at the actual resources.

The borrow checker ensures that the caller cannot again access its Token<A> until it has dropped both the guard and the Token<T>.

See the Hub type for more details on locking.

source

pub fn unregister_locked(&self, id: I, guard: &mut Storage<T, I>) -> Option<T>

Unregister the resource at id.

The caller must prove that it already holds a write lock for this Registry by passing a mutable reference to this Registry’s storage, obtained from the write guard returned by a previous call to write, as the guard parameter.

source

pub(crate) fn unregister<'a, A: Access<T>>( &self, id: I, _token: &'a mut Token<'_, A> ) -> (Option<T>, Token<'a, T>)

Unregister the resource at id and return its value, if any.

The caller must present a mutable reference to a Token<A>, for some type A that comes before this Registry’s resource type T in the lock ordering.

This returns a Token<T>, but it’s almost useless, because it doesn’t return a lock guard to go with it: its only effect is to make the token you passed to this function inaccessible. However, the Token<T> can be used to satisfy some functions’ bureacratic expectations that you will have one available.

The borrow checker ensures that the caller cannot again access its Token<A> until it has dropped both the guard and the Token<T>.

See the Hub type for more details on locking.

source

pub fn label_for_resource(&self, id: I) -> String

Trait Implementations§

source§

impl<T: Debug + Resource, I: Debug + TypedId, F: Debug + IdentityHandlerFactory<I>> Debug for Registry<T, I, F>where F::Filter: Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, I, F> !RefUnwindSafe for Registry<T, I, F>

§

impl<T, I, F> Send for Registry<T, I, F>where I: Send, T: Send, <F as IdentityHandlerFactory<I>>::Filter: Send,

§

impl<T, I, F> Sync for Registry<T, I, F>where I: Send + Sync, T: Send + Sync, <F as IdentityHandlerFactory<I>>::Filter: Sync,

§

impl<T, I, F> Unpin for Registry<T, I, F>where I: Unpin, T: Unpin, <F as IdentityHandlerFactory<I>>::Filter: Unpin,

§

impl<T, I, F> UnwindSafe for Registry<T, I, F>where I: UnwindSafe, T: UnwindSafe, <F as IdentityHandlerFactory<I>>::Filter: UnwindSafe,

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> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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

§

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> WasmNotSend for Twhere T: Send,

source§

impl<T> WasmNotSync for Twhere T: Sync,