pub struct OptionalKeyPath<Root, Value, F>{ /* private fields */ }Implementations§
Source§impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
pub fn new(getter: F) -> Self
pub fn get<'r>(&self, root: &'r Root) -> Option<&'r Value>
Sourcepub fn chain_arc_mutex_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: KeyPath<InnerValue, SubValue, G>,
) -> OptionalArcMutexKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_mutex_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> OptionalArcMutexKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with an inner keypath through Arc<Mutex
§Example
let container = ContainerTest { mutex_data: Some(Arc::new(Mutex::new(SomeStruct { data: "test".to_string() }))) };
// Functional style: compose first, apply container at get()
ContainerTest::mutex_data_fr()
.chain_arc_mutex_at_kp(SomeStruct::data_r())
.get(&container, |value| println!("Data: {}", value));Sourcepub fn chain_arc_mutex_optional_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcMutexOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_mutex_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcMutexOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with an optional inner keypath through Arc<Mutex
§Example
let container = ContainerTest { mutex_data: Some(Arc::new(Mutex::new(SomeStruct { optional_field: Some("test".to_string()) }))) };
// Functional style: compose first, apply container at get()
ContainerTest::mutex_data_fr()
.chain_arc_mutex_optional_at_kp(SomeStruct::optional_field_fr())
.get(&container, |value| println!("Value: {}", value));Sourcepub fn chain_arc_rwlock_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: KeyPath<InnerValue, SubValue, G>,
) -> OptionalArcRwLockKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_rwlock_at_kp<InnerValue, SubValue, G>( self, inner_keypath: KeyPath<InnerValue, SubValue, G>, ) -> OptionalArcRwLockKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with an inner keypath through Arc<RwLock
§Example
let container = ContainerTest { rwlock_data: Some(Arc::new(RwLock::new(SomeStruct { data: "test".to_string() }))) };
// Functional style: compose first, apply container at get()
ContainerTest::rwlock_data_fr()
.chain_arc_rwlock_at_kp(SomeStruct::data_r())
.get(&container, |value| println!("Data: {}", value));Sourcepub fn chain_arc_rwlock_optional_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcRwLockOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_rwlock_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: OptionalKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcRwLockOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with an optional inner keypath through Arc<RwLock
§Example
let container = ContainerTest { rwlock_data: Some(Arc::new(RwLock::new(SomeStruct { optional_field: Some("test".to_string()) }))) };
// Functional style: compose first, apply container at get()
ContainerTest::rwlock_data_fr()
.chain_arc_rwlock_optional_at_kp(SomeStruct::optional_field_fr())
.get(&container, |value| println!("Value: {}", value));Sourcepub fn chain_arc_mutex_writable_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: WritableKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcMutexWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_mutex_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcMutexWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with a writable inner keypath through Arc<Mutex
§Example
let container = ContainerTest { mutex_data: Some(Arc::new(Mutex::new(SomeStruct { data: "test".to_string() }))) };
// Functional style: compose first, apply container at get_mut()
ContainerTest::mutex_data_fr()
.chain_arc_mutex_writable_at_kp(SomeStruct::data_w())
.get_mut(&container, |value| *value = "new".to_string());Sourcepub fn chain_arc_mutex_writable_optional_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcMutexWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_mutex_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcMutexWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with a writable optional inner keypath through Arc<Mutex
§Example
let container = ContainerTest { mutex_data: Some(Arc::new(Mutex::new(SomeStruct { optional_field: Some("test".to_string()) }))) };
// Functional style: compose first, apply container at get_mut()
ContainerTest::mutex_data_fr()
.chain_arc_mutex_writable_optional_at_kp(SomeStruct::optional_field_fw())
.get_mut(&container, |value| *value = "new".to_string());Sourcepub fn chain_arc_rwlock_writable_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: WritableKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcRwLockWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_rwlock_writable_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcRwLockWritableKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with a writable inner keypath through Arc<RwLock
§Example
let container = ContainerTest { rwlock_data: Some(Arc::new(RwLock::new(SomeStruct { data: "test".to_string() }))) };
// Functional style: compose first, apply container at get_mut()
ContainerTest::rwlock_data_fr()
.chain_arc_rwlock_writable_at_kp(SomeStruct::data_w())
.get_mut(&container, |value| *value = "new".to_string());Sourcepub fn chain_arc_rwlock_writable_optional_at_kp<InnerValue, SubValue, G>(
self,
inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>,
) -> OptionalArcRwLockWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
pub fn chain_arc_rwlock_writable_optional_at_kp<InnerValue, SubValue, G>( self, inner_keypath: WritableOptionalKeyPath<InnerValue, SubValue, G>, ) -> OptionalArcRwLockWritableOptionalKeyPathChain<Root, Value, InnerValue, SubValue, F, G>
Chain this optional keypath with a writable optional inner keypath through Arc<RwLock
§Example
let container = ContainerTest { rwlock_data: Some(Arc::new(RwLock::new(SomeStruct { optional_field: Some("test".to_string()) }))) };
// Functional style: compose first, apply container at get_mut()
ContainerTest::rwlock_data_fr()
.chain_arc_rwlock_writable_optional_at_kp(SomeStruct::optional_field_fw())
.get_mut(&container, |value| *value = "new".to_string());pub fn then<SubValue, G>( self, next: OptionalKeyPath<Value, SubValue, G>, ) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> Option<&'r SubValue>>
pub fn for_box<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_arc<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_rc<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
Sourcepub fn for_option(
self,
) -> OptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r Option<Root>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
pub fn for_option(
self,
) -> OptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r Option<Root>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
Adapt this keypath to work with Option
Sourcepub fn for_result<E>(
self,
) -> OptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r Result<Root, E>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
E: 'static,
pub fn for_result<E>(
self,
) -> OptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r Result<Root, E>) -> Option<&'r Value> + '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
Sourcepub fn to_arc_rwlock_kp<InnerValue>(self) -> Self
pub fn to_arc_rwlock_kp<InnerValue>(self) -> Self
Convert this optional keypath to an Arc
Sourcepub fn to_arc_mutex_kp<InnerValue>(self) -> Self
pub fn to_arc_mutex_kp<InnerValue>(self) -> Self
Convert this optional keypath to an Arc
Sourcepub fn to_arc_rwlock_chain<InnerValue>(
self,
) -> OptionalArcRwLockKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) -> &'r InnerValue + 'static>
pub fn to_arc_rwlock_chain<InnerValue>( self, ) -> OptionalArcRwLockKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) -> &'r InnerValue + 'static>
Convert this optional keypath to an Arc
Sourcepub fn to_arc_mutex_chain<InnerValue>(
self,
) -> OptionalArcMutexKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) -> &'r InnerValue + 'static>
pub fn to_arc_mutex_chain<InnerValue>( self, ) -> OptionalArcMutexKeyPathChain<Root, Value, InnerValue, InnerValue, F, impl for<'r> Fn(&'r InnerValue) -> &'r InnerValue + 'static>
Convert this optional keypath to an Arc
pub fn for_arc_root(
self,
) -> OptionalKeyPath<Arc<Root>, Value, impl for<'r> Fn(&'r Arc<Root>) -> Option<&'r Value> + 'static>where
Value: Sized + 'static,
F: 'static,
Root: 'static,
pub fn for_rc_root(
self,
) -> OptionalKeyPath<Rc<Root>, Value, impl for<'r> Fn(&'r Rc<Root>) -> Option<&'r Value> + 'static>where
Value: Sized + 'static,
F: 'static,
Root: 'static,
Sourcepub fn with_option<Callback, R>(
&self,
option: &Option<Root>,
f: Callback,
) -> Option<R>
pub fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Option
Sourcepub fn with_mutex<Callback, R>(
&self,
mutex: &Mutex<Root>,
f: Callback,
) -> Option<R>
pub fn with_mutex<Callback, R>( &self, mutex: &Mutex<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside a Mutex
Sourcepub fn with_rwlock<Callback, R>(
&self,
rwlock: &RwLock<Root>,
f: Callback,
) -> Option<R>
pub fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an RwLock
Sourcepub fn with_arc_rwlock<Callback, R>(
&self,
arc_rwlock: &Arc<RwLock<Root>>,
f: Callback,
) -> Option<R>
pub fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Arc<RwLock
Sourcepub fn with_arc_rwlock_direct<Callback, R>(
&self,
arc_rwlock: &Arc<RwLock<Root>>,
f: Callback,
) -> Option<R>
pub fn with_arc_rwlock_direct<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Arc<RwLock
Source§impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
Sourcepub fn to_partial(self) -> PartialOptionalKeyPath<Root>
pub fn to_partial(self) -> PartialOptionalKeyPath<Root>
Convert to PartialOptionalKeyPath (hides Value type)
Sourcepub fn to_any(self) -> AnyKeyPath
pub fn to_any(self) -> AnyKeyPath
Convert to AnyKeyPath (hides both Root and Value types)
Sourcepub fn to(self) -> PartialOptionalKeyPath<Root>
pub fn to(self) -> PartialOptionalKeyPath<Root>
Convert to PartialOptionalKeyPath (alias for to_partial())
Trait Implementations§
Source§impl<Root: Clone, Value: Clone, F> Clone for OptionalKeyPath<Root, Value, F>
impl<Root: Clone, Value: Clone, F> Clone for OptionalKeyPath<Root, Value, F>
Source§fn clone(&self) -> OptionalKeyPath<Root, Value, F>
fn clone(&self) -> OptionalKeyPath<Root, Value, F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more