KeyPath

Struct KeyPath 

Source
pub struct KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value,
{ /* private fields */ }

Implementations§

Source§

impl<Root, Value, F> KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value,

Source

pub fn new(getter: F) -> KeyPath<Root, Value, F>

Source

pub fn get<'r>(&self, root: &'r Root) -> &'r Value

Source

pub fn chain_arc_mutex_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcMutexKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<Mutex> - functional style Compose first, then apply container at get() time

§Example
let container = ContainerTest { mutex_data: Arc::new(Mutex::new(SomeStruct { data: "test".to_string() })) };
 
// Functional style: compose first, apply container at get()
ContainerTest::mutex_data_r()
    .chain_arc_mutex_at_kp(SomeStruct::data_r())
    .get(&container, |value| println!("Data: {}", value));
Source

pub fn chain_arc_mutex_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcMutexOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<Mutex> - functional style Compose first, then apply container at get() time

§Example
let container = ContainerTest { mutex_data: Arc::new(Mutex::new(SomeStruct { optional_field: Some("test".to_string()) })) };
 
// Functional style: compose first, apply container at get()
ContainerTest::mutex_data_r()
    .chain_arc_mutex_optional_at_kp(SomeStruct::optional_field_fr())
    .get(&container, |value| println!("Value: {}", value));
Source

pub fn chain_arc_rwlock_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcRwLockKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<RwLock> - functional style Compose first, then apply container at get() time (uses read lock)

§Example
let container = ContainerTest { rwlock_data: Arc::new(RwLock::new(SomeStruct { data: "test".to_string() })) };
 
// Functional style: compose first, apply container at get()
ContainerTest::rwlock_data_r()
    .chain_arc_rwlock_at_kp(SomeStruct::data_r())
    .get(&container, |value| println!("Data: {}", value));
Source

pub fn chain_arc_rwlock_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcRwLockOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<RwLock> - functional style Compose first, then apply container at get() time (uses read lock)

§Example
let container = ContainerTest { rwlock_data: Arc::new(RwLock::new(SomeStruct { optional_field: Some("test".to_string()) })) };
 
// Functional style: compose first, apply container at get()
ContainerTest::rwlock_data_r()
    .chain_arc_rwlock_optional_at_kp(SomeStruct::optional_field_fr())
    .get(&container, |value| println!("Value: {}", value));
Source

pub fn chain_arc_mutex_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcMutexWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<Mutex> - functional style Compose first, then apply container at get_mut() time

§Example
ContainerTest::mutex_data_r()
    .chain_arc_mutex_writable_at_kp(SomeStruct::data_w())
    .get_mut(&container, |value| *value = "new".to_string());
Source

pub fn chain_arc_mutex_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcMutexWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>

Chain this keypath with a writable optional inner keypath through Arc<Mutex> - functional style Compose first, then apply container at get_mut() time

§Example
ContainerTest::mutex_data_r()
    .chain_arc_mutex_writable_optional_at_kp(SomeStruct::optional_field_fw())
    .get_mut(&container, |value| *value = "new".to_string());
Source

pub fn chain_arc_rwlock_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcRwLockWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<RwLock> - functional style Compose first, then apply container at get_mut() time (uses write lock)

§Example
ContainerTest::rwlock_data_r()
    .chain_arc_rwlock_writable_at_kp(SomeStruct::data_w())
    .get_mut(&container, |value| *value = "new".to_string());
Source

pub fn chain_arc_rwlock_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcRwLockWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>

Chain this keypath with a writable optional inner keypath through Arc<RwLock> - functional style Compose first, then apply container at get_mut() time (uses write lock)

§Example
ContainerTest::rwlock_data_r()
    .chain_arc_rwlock_writable_optional_at_kp(SomeStruct::optional_field_fw())
    .get_mut(&container, |value| *value = "new".to_string());
Source

pub fn chain_arc_tokio_mutex_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcTokioMutexKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<tokio::sync::Mutex> - functional style (async) Compose first, then apply container at get() time

Source

pub fn chain_arc_tokio_mutex_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioMutexOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<Mutex<InnerValue>>>, G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<tokio::sync::Mutex> - functional style (async)

Source

pub fn chain_arc_tokio_mutex_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioMutexWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<Mutex<InnerValue>>>, G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<tokio::sync::Mutex> - functional style (async)

Source

pub fn chain_arc_tokio_mutex_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioMutexWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<Mutex<InnerValue>>>, G: for<'r> Fn(&'r mut InnerValue) -> Option<&'r mut SubValue>,

Chain this keypath with a writable optional inner keypath through Arc<tokio::sync::Mutex> - functional style (async)

Source

pub fn chain_arc_tokio_rwlock_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcTokioRwLockKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<RwLock<InnerValue>>>, G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<tokio::sync::RwLock> - functional style (async, read lock)

Source

pub fn chain_arc_tokio_rwlock_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioRwLockOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<RwLock<InnerValue>>>, G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<tokio::sync::RwLock> - functional style (async, read lock)

Source

pub fn chain_arc_tokio_rwlock_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioRwLockWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<RwLock<InnerValue>>>, G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<tokio::sync::RwLock> - functional style (async, write lock)

Source

pub fn chain_arc_tokio_rwlock_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcTokioRwLockWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<RwLock<InnerValue>>>, G: for<'r> Fn(&'r mut InnerValue) -> Option<&'r mut SubValue>,

Chain this keypath with a writable optional inner keypath through Arc<tokio::sync::RwLock> - functional style (async, write lock)

Source

pub fn then_rwlock<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcRwLockWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
where Value: Borrow<Arc<RwLock<InnerValue>>>, G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Monadic helper: shorthand for chain_arc_rwlock_writable_at_kp when Value is Arc<RwLock> This allows chaining with .then().then().then() pattern for Arc<RwLock> structures

§Example
ContainerTest::rwlock_data_r()
    .then_rwlock(SomeStruct::data_w())
    .then(OtherStruct::field_w())
    .get_mut(&container, |value| *value = "new".to_string());
Source

pub fn to_arc_rwlock_kp<InnerValue>(self) -> KeyPath<Root, Value, F>
where Value: Borrow<Arc<RwLock<InnerValue>>>,

Convert this keypath to an Arc chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

§Example
Container::rwlock_data_r()
    .to_arc_rwlock_kp()
    .chain_arc_rwlock_at_kp(InnerStruct::field_r());
Source

pub fn to_arc_mutex_kp<InnerValue>(self) -> KeyPath<Root, Value, F>
where Value: Borrow<Arc<Mutex<InnerValue>>>,

Convert this keypath to an Arc chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

Source

pub fn to_arc_parking_rwlock_kp<InnerValue>(self) -> KeyPath<Root, Value, F>
where Value: Borrow<Arc<RwLock<RawRwLock, InnerValue>>>,

Convert this keypath to an Arc<parking_lot::RwLock> chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

§Example
Container::rwlock_data_r()
    .to_arc_parking_rwlock_kp()
    .chain_arc_parking_rwlock_at_kp(InnerStruct::field_r());
Source

pub fn to_arc_parking_mutex_kp<InnerValue>(self) -> KeyPath<Root, Value, F>
where Value: Borrow<Arc<Mutex<RawMutex, InnerValue>>>,

Convert this keypath to an Arc<parking_lot::Mutex> chain-ready keypath Returns self, but serves as a marker for intent and enables chaining

Source

pub fn to_arc_rwlock_chain<InnerValue>( self, ) -> ArcRwLockKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) + 'static>
where Value: Borrow<Arc<RwLock<InnerValue>>>, F: 'static, InnerValue: 'static,

Convert this keypath to an Arc chain keypath Creates a chain with an identity inner keypath, ready for further chaining

§Example
Container::rwlock_data_r()
    .to_arc_rwlock_chain()
    .then(InnerStruct::field_r());

Convert this keypath to an Arc chain keypath Creates a chain with an identity inner keypath, ready for further chaining Type inference automatically determines InnerValue from Value

§Example
Container::rwlock_data_r()
    .to_arc_rwlock_chain()
    .then(InnerStruct::field_r());
Source

pub fn to_arc_mutex_chain<InnerValue>( self, ) -> ArcMutexKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) + 'static>
where Value: Borrow<Arc<Mutex<InnerValue>>>, F: 'static, InnerValue: 'static,

Convert this keypath to an Arc chain keypath Creates a chain with an identity inner keypath, ready for further chaining Type inference automatically determines InnerValue from Value

Source

pub fn for_box<Target>( self, ) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_arc<Target>( self, ) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_rc<Target>( self, ) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) + 'static>
where Value: Deref<Target = Target> + 'static, F: 'static,

Source

pub fn for_arc_root( self, ) -> OptionalKeyPath<Arc<Root>, Value, impl for<'r> Fn(&'r Arc<Root>) + 'static>
where F: 'static, Root: 'static, Value: 'static,

Source

pub fn for_box_root( self, ) -> OptionalKeyPath<Box<Root>, Value, impl for<'r> Fn(&'r Box<Root>) + 'static>
where F: 'static, Root: 'static, Value: 'static,

Source

pub fn for_rc_root( self, ) -> OptionalKeyPath<Rc<Root>, Value, impl for<'r> Fn(&'r Rc<Root>) + 'static>
where F: 'static, Root: 'static, Value: 'static,

Source

pub fn for_result<E>( self, ) -> OptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r Result<Root, E>) + 'static>
where F: 'static, Root: 'static, Value: 'static, E: 'static,

Adapt this keypath to work with Result<Root, E> instead of Root This unwraps the Result and applies the keypath to the Ok value

Source

pub fn to_optional( self, ) -> OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) + 'static>
where F: 'static,

Convert a KeyPath to OptionalKeyPath for chaining This allows non-optional keypaths to be chained with then()

Source

pub fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Option

Source

pub fn with_result<Callback, R, E>( &self, result: &Result<Root, E>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Result

Source

pub fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Box

Source

pub fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc

Source

pub fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Rc

Source

pub fn with_refcell<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a RefCell

Source

pub fn with_mutex<Callback, R>( &self, mutex: &Mutex<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Mutex

Source

pub fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an RwLock

Source

pub fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<RwLock>

Source

pub fn with_arc_mutex<Callback, R>( &self, arc_mutex: &Arc<Mutex<Root>>, f: Callback, ) -> Option<R>
where F: Clone, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<Mutex>

Source

pub fn for_tagged<Tag>( self, ) -> KeyPath<Tagged<Root, Tag>, Value, impl for<'r> Fn(&'r Tagged<Root, Tag>) + 'static>
where Tagged<Root, Tag>: Deref<Target = Root>, F: 'static, Root: 'static, Value: 'static, Tag: 'static,

Adapt this keypath to work with Tagged<Root, Tag> instead of Root This unwraps the Tagged wrapper and applies the keypath to the inner value

Source

pub fn with_tagged<Tag, Callback, R>( &self, tagged: &Tagged<Root, Tag>, f: Callback, ) -> R
where Tagged<Root, Tag>: Deref<Target = Root>, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Tagged This avoids cloning by working with references directly

Source

pub fn for_option( self, ) -> OptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r Option<Root>) + 'static>
where F: 'static, Root: 'static, Value: 'static,

Adapt this keypath to work with Option instead of Root This converts the KeyPath to an OptionalKeyPath and unwraps the Option

Source

pub fn iter<'r, T>(&self, root: &'r Root) -> Option<Iter<'r, T>>
where Value: AsRef<[T]> + 'r,

Get an iterator over a Vec when Value is Vec Returns Some(iterator) if the value is a Vec, None otherwise

Source

pub fn extract_from_slice<'r>(&self, slice: &'r [Root]) -> Vec<&'r Value>

Extract values from a slice of owned values Returns a Vec of references to the extracted values

Source

pub fn extract_from_ref_slice<'r>(&self, slice: &'r [&Root]) -> Vec<&'r Value>

Extract values from a slice of references Returns a Vec of references to the extracted values

Source

pub fn then<SubValue, G>( self, next: KeyPath<Value, SubValue, G>, ) -> KeyPath<Root, SubValue, impl for<'r> Fn(&'r Root)>
where G: for<'r> Fn(&'r Value) -> &'r SubValue + 'static, F: 'static, Value: 'static,

Chain this keypath with another keypath Returns a KeyPath that chains both keypaths

Source

pub fn chain_optional<SubValue, G>( self, next: OptionalKeyPath<Value, SubValue, G>, ) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root)>
where G: for<'r> Fn(&'r Value) -> Option<&'r SubValue> + 'static, F: 'static, Value: 'static,

Chain this keypath with an optional keypath Returns an OptionalKeyPath that chains both keypaths

Source§

impl<Root, Value, F> KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value,

Source

pub fn with_arc_rwlock_direct<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<RwLock> This is a convenience method that works directly with Arc<RwLock>

Source

pub fn with_arc_mutex_direct<Callback, R>( &self, arc_mutex: &Arc<Mutex<Root>>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<Mutex> This is a convenience method that works directly with Arc<Mutex>

Source§

impl<Root, InnerValue, F> KeyPath<Root, Arc<Mutex<RawMutex, InnerValue>>, F>
where F: for<'r> Fn(&'r Root) -> &'r Arc<Mutex<RawMutex, InnerValue>>,

Source

pub fn chain_arc_parking_mutex_at_kp<SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcParkingMutexKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<parking_lot::Mutex> - functional style

Source

pub fn then_arc_parking_mutex_optional_at_kp<SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingMutexOptionalKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<parking_lot::Mutex>

Source

pub fn chain_arc_parking_mutex_writable_at_kp<SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingMutexWritableKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<parking_lot::Mutex>

Source

pub fn then_arc_parking_mutex_writable_optional_at_kp<SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingMutexWritableOptionalKeyPathChain<Root, InnerValue, SubValue, F, G>

Chain this keypath with a writable optional inner keypath through Arc<parking_lot::Mutex>

Source§

impl<Root, InnerValue, F> KeyPath<Root, Arc<RwLock<RawRwLock, InnerValue>>, F>
where F: for<'r> Fn(&'r Root) -> &'r Arc<RwLock<RawRwLock, InnerValue>>,

Source

pub fn chain_arc_parking_rwlock_at_kp<SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> ArcParkingRwLockKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> &'r SubValue,

Chain this keypath with an inner keypath through Arc<parking_lot::RwLock> - functional style

Source

pub fn then_arc_parking_rwlock_optional_at_kp<SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingRwLockOptionalKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r InnerValue) -> Option<&'r SubValue>,

Chain this keypath with an optional inner keypath through Arc<parking_lot::RwLock>

Source

pub fn chain_arc_parking_rwlock_writable_at_kp<SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingRwLockWritableKeyPathChain<Root, InnerValue, SubValue, F, G>
where G: for<'r> Fn(&'r mut InnerValue) -> &'r mut SubValue,

Chain this keypath with a writable inner keypath through Arc<parking_lot::RwLock>

Source

pub fn then_arc_parking_rwlock_writable_optional_at_kp<SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> ArcParkingRwLockWritableOptionalKeyPathChain<Root, InnerValue, SubValue, F, G>

Chain this keypath with a writable optional inner keypath through Arc<parking_lot::RwLock>

Source§

impl<Root, Value, F> KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value + 'static, Root: 'static, Value: Any + 'static,

Source

pub fn to_partial(self) -> PartialKeyPath<Root>

Convert to PartialKeyPath (hides Value type)

Source

pub fn to(self) -> PartialKeyPath<Root>

Alias for to_partial() - converts to PartialKeyPath

Trait Implementations§

Source§

impl<Root, Value, F> Clone for KeyPath<Root, Value, F>
where Root: Clone, Value: Clone, F: Clone + for<'r> Fn(&'r Root) -> &'r Value,

Source§

fn clone(&self) -> KeyPath<Root, Value, F>

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
Source§

impl<Root, Value, F> Debug for KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value,

Source§

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

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

impl<Root, Value, F> Display for KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value,

Source§

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

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

impl<Root, Value, F> From<KeyPath<Root, Value, F>> for KP<Root>
where F: for<'r> Fn(&'r Root) -> &'r Value + 'static, Root: 'static, Value: Any + 'static,

Source§

fn from(kp: RustKeyPath<Root, Value, F>) -> Self

Converts to this type from the input type.
Source§

impl<Root, Value, F> WithContainer<Root, Value> for KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value + Clone,

Source§

fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc
Source§

fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Box
Source§

fn with_box_mut<Callback, R>(&self, _boxed: &mut Box<Root>, _f: Callback) -> R
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Box
Source§

fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Rc
Source§

fn with_result<Callback, R, E>( &self, result: &Result<Root, E>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Result
Source§

fn with_result_mut<Callback, R, E>( &self, _result: &mut Result<Root, E>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Result
Source§

fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Option
Source§

fn with_option_mut<Callback, R>( &self, _option: &mut Option<Root>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an Option
Source§

fn with_refcell<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a RefCell
Source§

fn with_refcell_mut<Callback, R>( &self, _refcell: &RefCell<Root>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a RefCell
Source§

fn with_tagged<Callback, R, Tag>( &self, tagged: &Tagged<Root, Tag>, f: Callback, ) -> R
where Tagged<Root, Tag>: Deref<Target = Root>, Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Tagged
Source§

fn with_mutex<Callback, R>(&self, mutex: &Mutex<Root>, f: Callback) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Mutex
Source§

fn with_mutex_mut<Callback, R>( &self, _mutex: &mut Mutex<Root>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Mutex
Source§

fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an RwLock
Source§

fn with_rwlock_mut<Callback, R>( &self, _rwlock: &mut RwLock<Root>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an RwLock
Source§

fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
where Callback: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<RwLock>
Source§

fn with_arc_rwlock_mut<Callback, R>( &self, _arc_rwlock: &Arc<RwLock<Root>>, _f: Callback, ) -> Option<R>
where Callback: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an Arc<RwLock>

Auto Trait Implementations§

§

impl<Root, Value, F> Freeze for KeyPath<Root, Value, F>
where F: Freeze,

§

impl<Root, Value, F> RefUnwindSafe for KeyPath<Root, Value, F>
where F: RefUnwindSafe, Root: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Root, Value, F> Send for KeyPath<Root, Value, F>
where F: Send, Root: Send, Value: Send,

§

impl<Root, Value, F> Sync for KeyPath<Root, Value, F>
where F: Sync, Root: Sync, Value: Sync,

§

impl<Root, Value, F> Unpin for KeyPath<Root, Value, F>
where F: Unpin, Root: Unpin, Value: Unpin,

§

impl<Root, Value, F> UnwindSafe for KeyPath<Root, Value, F>
where F: UnwindSafe, Root: UnwindSafe, Value: 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.