Skip to main content

ComposedAsyncLockKp

Struct ComposedAsyncLockKp 

Source
pub struct ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> { /* private fields */ }
Expand description

Chained async lock keypath: two or more async keypaths (Root -> V -> V2 -> …). Root is passed at get/get_mut time.

Use AsyncLockKp::then_async to create (or ComposedAsyncLockKp::then_async for more levels). Then call ComposedAsyncLockKp::get or ComposedAsyncLockKp::get_mut with root when you need the value.

Chain any depth: kp1.then_async(kp2).then_async(kp3).then_async(kp4)... then .get(&root).await.

Implementations§

Source§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> 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

pub async fn get(&self, root: Root) -> Option<Value2>

Get through all chained async locks (root is passed here).

Source

pub async fn get_mut(&self, root: MutRoot) -> Option<MutValue2>

Get mutable through all composed locks (root is passed here).

Source

pub fn then_async<Lock3, Mid3, V3, LockValue3, MidValue3, Value3, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>( self, other: AsyncLockKp<V2, Lock3, Mid3, V3, Value2, LockValue3, MidValue3, Value3, MutValue2, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>, ) -> ComposedAsyncLockKp<R, V3, Root, Value3, MutRoot, MutValue3, Self, AsyncLockKp<V2, Lock3, Mid3, V3, Value2, LockValue3, MidValue3, Value3, MutValue2, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>>
where V2: 'static, V3: 'static, Value2: Borrow<V2>, Value3: Borrow<V3>, MutValue2: BorrowMut<V2>, MutValue3: BorrowMut<V3>, LockValue3: Borrow<Lock3>, MidValue3: Borrow<Mid3>, MutLock3: BorrowMut<Lock3>, MutMid3: BorrowMut<Mid3>, G3_1: Fn(Value2) -> Option<LockValue3> + Clone, S3_1: Fn(MutValue2) -> Option<MutLock3> + Clone, L3: AsyncLockLike<Lock3, MidValue3> + AsyncLockLike<Lock3, MutMid3> + Clone, G3_2: Fn(MidValue3) -> Option<Value3> + Clone, S3_2: Fn(MutMid3) -> Option<MutValue3> + Clone, Lock3: Clone,

Chain with another async keypath: a.then_async(b).then_async(c).get(&root).await.

Source

pub fn then<V3, Value3, MutValue3, G3, S3>( self, next_kp: Kp<V2, V3, Value2, Value3, MutValue2, MutValue3, G3, S3>, ) -> AsyncKeyPathThenKp<R, V3, Root, Value3, MutRoot, MutValue3, Self, Kp<V2, V3, Value2, Value3, MutValue2, MutValue3, G3, S3>>
where V2: 'static, V3: 'static, Value2: Borrow<V2>, Value3: Borrow<V3>, MutValue2: BorrowMut<V2>, MutValue3: BorrowMut<V3>, G3: Fn(Value2) -> Option<Value3> + Clone, S3: Fn(MutValue2) -> Option<MutValue3> + Clone,

Chain with a regular crate::Kp (no root at call site). Use .get(&root).await later.

Source

pub fn then_lock<Lock3, Mid3, V3, LockValue3, MidValue3, Value3, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>( self, lock_kp: LockKp<V2, Lock3, Mid3, V3, Value2, LockValue3, MidValue3, Value3, MutValue2, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>, ) -> AsyncLockKpThenLockKp<R, V3, Root, Value3, MutRoot, MutValue3, Self, LockKp<V2, Lock3, Mid3, V3, Value2, LockValue3, MidValue3, Value3, MutValue2, MutLock3, MutMid3, MutValue3, G3_1, S3_1, L3, G3_2, S3_2>>
where V2: 'static, V3: 'static, Value2: Borrow<V2>, Value3: Borrow<V3>, MutValue2: BorrowMut<V2>, MutValue3: BorrowMut<V3>, LockValue3: Borrow<Lock3>, MidValue3: Borrow<Mid3>, MutLock3: BorrowMut<Lock3>, MutMid3: BorrowMut<Mid3>, G3_1: Fn(Value2) -> Option<LockValue3>, S3_1: Fn(MutValue2) -> Option<MutLock3>, L3: LockAccess<Lock3, MidValue3> + LockAccess<Lock3, MutMid3>, G3_2: Fn(MidValue3) -> Option<Value3>, S3_2: Fn(MutMid3) -> Option<MutValue3>,

Chain with a sync crate::lock::LockKp (no root at call site). Use .get(&root).await later.

Trait Implementations§

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

Value type at the end of the keypath.
Source§

type MutValue = MutValue2

Mutable value type at the end of the keypath.
Source§

fn get<'life0, 'async_trait>( &'life0 self, root: Root, ) -> Pin<Box<dyn Future<Output = Option<Value2>> + '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<MutValue2>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

impl<R: Clone, V2: Clone, Root: Clone, Value2: Clone, MutRoot: Clone, MutValue2: Clone, First: Clone, Second: Clone> Clone for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>

Source§

fn clone( &self, ) -> ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>

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

Auto Trait Implementations§

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> Freeze for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: Freeze, Second: Freeze,

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> RefUnwindSafe for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: RefUnwindSafe, Second: RefUnwindSafe, R: RefUnwindSafe, V2: RefUnwindSafe, Root: RefUnwindSafe, Value2: RefUnwindSafe, MutRoot: RefUnwindSafe, MutValue2: RefUnwindSafe,

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> Send for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: Send, Second: Send, R: Send, V2: Send, Root: Send, Value2: Send, MutRoot: Send, MutValue2: Send,

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> Sync for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: Sync, Second: Sync, R: Sync, V2: Sync, Root: Sync, Value2: Sync, MutRoot: Sync, MutValue2: Sync,

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> Unpin for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: Unpin, Second: Unpin, R: Unpin, V2: Unpin, Root: Unpin, Value2: Unpin, MutRoot: Unpin, MutValue2: Unpin,

§

impl<R, V2, Root, Value2, MutRoot, MutValue2, First, Second> UnwindSafe for ComposedAsyncLockKp<R, V2, Root, Value2, MutRoot, MutValue2, First, Second>
where First: UnwindSafe, Second: UnwindSafe, R: UnwindSafe, V2: UnwindSafe, Root: UnwindSafe, Value2: UnwindSafe, MutRoot: UnwindSafe, MutValue2: 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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