Skip to main content

AsyncKeyPathLike

Trait AsyncKeyPathLike 

Source
pub trait AsyncKeyPathLike<Root, MutRoot> {
    type Value;
    type MutValue;

    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 self,
        root: Root,
    ) -> Pin<Box<dyn Future<Output = Option<Self::Value>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_mut<'life0, 'async_trait>(
        &'life0 self,
        root: MutRoot,
    ) -> Pin<Box<dyn Future<Output = Option<Self::MutValue>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for async keypaths (both AsyncLockKp and ComposedAsyncLockKp) so composition can be any depth.

§Why MutRoot? (RwLock/Mutex interior mutability)

RwLock and Mutex provide interior mutability—their lock() / write() methods take &self, so you can mutate through an immutable reference. For async lock keypaths, the mutation happens inside the lock; you do not need a mutable root. MutRoot exists for composition with sync keypaths (e.g. Kp) that may require &mut along the path. When the path goes entirely through locks (RwLock/Mutex), Root and MutRoot are typically the same type (e.g. &Root for both).

Required Associated Types§

Source

type Value

Value type at the end of the keypath.

Source

type MutValue

Mutable value type at the end of the keypath.

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 self, root: Root, ) -> Pin<Box<dyn Future<Output = Option<Self::Value>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the value at the end of the keypath.

Source

fn get_mut<'life0, 'async_trait>( &'life0 self, root: MutRoot, ) -> Pin<Box<dyn Future<Output = Option<Self::MutValue>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get mutable access to the value at the end of the keypath.

Implementors§

Source§

impl<R, Lock, Mid, V, Root, LockValue, MidValue, Value, MutRoot, MutLock, MutMid, MutValue, G1, S1, L, G2, S2> AsyncKeyPathLike<Root, MutRoot> for AsyncLockKp<R, Lock, Mid, V, Root, LockValue, MidValue, Value, MutRoot, MutLock, MutMid, MutValue, G1, S1, L, G2, S2>
where Root: Borrow<R>, LockValue: Borrow<Lock>, MidValue: Borrow<Mid>, Value: Borrow<V>, MutRoot: BorrowMut<R>, MutLock: BorrowMut<Lock>, MutMid: BorrowMut<Mid>, MutValue: BorrowMut<V>, G1: Fn(Root) -> Option<LockValue> + Clone, S1: Fn(MutRoot) -> Option<MutLock> + Clone, L: AsyncLockLike<Lock, MidValue> + AsyncLockLike<Lock, MutMid> + Clone, G2: Fn(MidValue) -> Option<Value> + Clone, S2: Fn(MutMid) -> Option<MutValue> + Clone, Lock: Clone,

Source§

type Value = Value

Source§

type MutValue = MutValue

Source§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> AsyncKeyPathLike<Root, MutRoot> for AsyncLockKpThenLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: AsyncKeyPathLike<Root, MutRoot>, Second: SyncKeyPathLike<First::Value, Value2, First::MutValue, MutValue2>,

Source§

type Value = Value2

Source§

type MutValue = MutValue2

Source§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> AsyncKeyPathLike<Root, MutRoot> for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: AsyncKeyPathLike<Root, MutRoot>, Second: AsyncKeyPathLike<First::Value, First::MutValue, Value = Value2, MutValue = MutValue2>,

Source§

type Value = Value2

Source§

type MutValue = MutValue2

Source§

impl<R, V, V2, Root, Value, Value2, MutRoot, MutValue, MutValue2, First, Second> AsyncKeyPathLike<Root, MutRoot> for KpThenAsyncKeyPath<R, V, V2, Root, Value, Value2, MutRoot, MutValue, MutValue2, First, Second>
where First: SyncKeyPathLike<Root, Value, MutRoot, MutValue>, Second: AsyncKeyPathLike<Value, MutValue, Value = Value2, MutValue = MutValue2>,

Source§

type Value = Value2

Source§

type MutValue = MutValue2