Skip to main content

LKp

Struct LKp 

Source
pub struct LKp<Root, MutexValue, InnerValue, SubValue, G, S>{ /* private fields */ }

Implementations§

Source§

impl<Root, MutexValue, InnerValue, SubValue, G, S> LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where MutexValue: Borrow<Arc<Mutex<InnerValue>>>, G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>, S: for<'r> Fn(&'r mut InnerValue) -> Option<&'r mut SubValue>,

Source

pub fn new( outer: Kp<Root, MutexValue>, inner: KpType<InnerValue, SubValue, G, S>, ) -> Self

Create an LKp from two simple keypaths

  • outer: keypath from Root to Arc<Mutex>
  • inner: keypath from InnerValue to SubValue
Source

pub fn then<NextValue, G2, S2>( self, next: KpType<SubValue, NextValue, G2, S2>, ) -> LKp<Root, MutexValue, InnerValue, NextValue, impl for<'r> Fn(&'r InnerValue) -> Option<&'r NextValue>, impl for<'r> Fn(&'r mut InnerValue) -> Option<&'r mut NextValue>>
where InnerValue: 'static, SubValue: 'static, NextValue: 'static, G2: for<'r> Fn(&'r SubValue) -> Option<&'r NextValue>, S2: for<'r> Fn(&'r mut SubValue) -> Option<&'r mut NextValue>,

Source

pub fn get_cloned(&self, root: &Root) -> Option<SubValue>
where SubValue: Clone,

Consider using the fn only when value is of type Rc or Arc else it will clone.

Source

pub fn get_arc(&self, root: &Root) -> Option<Arc<SubValue>>
where SubValue: Clone,

Source

pub fn get_mut<F, SubSubValue>( &self, root: &mut Root, f: F, ) -> Option<SubSubValue>
where F: FnOnce(&mut SubValue) -> SubSubValue,

Source

pub fn get<F, SubSubValue>(&self, root: &Root, f: F) -> Option<SubSubValue>
where F: FnOnce(&SubValue) -> SubSubValue,

Source§

impl<Root, MutexValue, InnerValue, SubValue, G, S> LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where MutexValue: Borrow<Arc<Mutex<InnerValue>>>, G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>, S: for<'r> Fn(&'r mut InnerValue) -> Option<&'r mut SubValue>,

Source

pub fn and_then_with<NextInner, NextValue, G2, S2, F, R>( &self, next_inner: &KpType<NextInner, NextValue, G2, S2>, root: &Root, callback: F, ) -> Option<R>
where SubValue: Borrow<Arc<Mutex<NextInner>>>, G2: for<'r> Fn(&'r NextInner) -> Option<&'r NextValue>, S2: for<'r> Fn(&'r mut NextInner) -> Option<&'r mut NextValue>, F: FnOnce(&NextValue) -> R,

Chain through another mutex layer with callback-based access (safer)

Source

pub fn and_then_with_mut<NextInner, NextValue, G2, S2, F, R>( &self, next_inner: &KpType<NextInner, NextValue, G2, S2>, root: &mut Root, callback: F, ) -> Option<R>
where SubValue: Borrow<Arc<Mutex<NextInner>>>, G2: for<'r> Fn(&'r NextInner) -> Option<&'r NextValue>, S2: for<'r> Fn(&'r mut NextInner) -> Option<&'r mut NextValue>, F: FnOnce(&mut NextValue) -> R,

Mutable version of and_then_with

Trait Implementations§

Source§

impl<Root: Debug, MutexValue: Debug, InnerValue: Debug, SubValue: Debug, G, S> Debug for LKp<Root, MutexValue, InnerValue, SubValue, G, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> Freeze for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: Freeze, S: Freeze,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> RefUnwindSafe for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: RefUnwindSafe, S: RefUnwindSafe, Root: RefUnwindSafe, MutexValue: RefUnwindSafe, InnerValue: RefUnwindSafe, SubValue: RefUnwindSafe,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> Send for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: Send, S: Send, Root: Send, MutexValue: Send, InnerValue: Send, SubValue: Send,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> Sync for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: Sync, S: Sync, Root: Sync, MutexValue: Sync, InnerValue: Sync, SubValue: Sync,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> Unpin for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: Unpin, S: Unpin, Root: Unpin, MutexValue: Unpin, InnerValue: Unpin, SubValue: Unpin,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> UnsafeUnpin for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: UnsafeUnpin, S: UnsafeUnpin,

§

impl<Root, MutexValue, InnerValue, SubValue, G, S> UnwindSafe for LKp<Root, MutexValue, InnerValue, SubValue, G, S>
where G: UnwindSafe, S: UnwindSafe, Root: UnwindSafe, MutexValue: UnwindSafe, InnerValue: UnwindSafe, SubValue: 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> 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, 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.