FailableCombinedKeyPath

Struct FailableCombinedKeyPath 

Source
pub struct FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, WriteFn: for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static, OwnedFn: Fn(Root) -> Option<Value> + 'static,
{ /* private fields */ }
Expand description

FailableCombinedKeyPath - A keypath that supports readable, writable, and owned access patterns

This keypath type combines the functionality of OptionalKeyPath, WritableOptionalKeyPath, and adds owned access. It’s useful when you need all three access patterns for the same field.

Implementations§

Source§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, WriteFn: for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static, OwnedFn: Fn(Root) -> Option<Value> + 'static,

Source

pub fn new( readable: ReadFn, writable: WriteFn, owned: OwnedFn, ) -> FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>

Create a new FailableCombinedKeyPath with all three access patterns

Source

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

Get an immutable reference to the value (readable access)

Source

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

Get a mutable reference to the value (writable access)

Source

pub fn get_failable_owned(&self, root: Root) -> Option<Value>

Get an owned value (owned access) - consumes the root

Source

pub fn to_optional(self) -> OptionalKeyPath<Root, Value, ReadFn>

Convert to OptionalKeyPath (loses writable and owned capabilities)

Source

pub fn to_writable_optional( self, ) -> WritableOptionalKeyPath<Root, Value, WriteFn>

Convert to WritableOptionalKeyPath (loses owned capability)

Source

pub fn then<SubValue, SubReadFn, SubWriteFn, SubOwnedFn>( self, next: FailableCombinedKeyPath<Value, SubValue, SubReadFn, SubWriteFn, SubOwnedFn>, ) -> FailableCombinedKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) + 'static, impl for<'r> Fn(&'r mut Root) + 'static, impl Fn(Root) + 'static>
where SubReadFn: for<'r> Fn(&'r Value) -> Option<&'r SubValue> + 'static, SubWriteFn: for<'r> Fn(&'r mut Value) -> Option<&'r mut SubValue> + 'static, SubOwnedFn: Fn(Value) -> Option<SubValue> + 'static, ReadFn: 'static, WriteFn: 'static, OwnedFn: 'static, Value: 'static, Root: 'static, SubValue: 'static,

Compose this keypath with another FailableCombinedKeyPath Returns a new FailableCombinedKeyPath that chains both keypaths

Source

pub fn chain_optional<SubValue, SubReadFn>( self, next: OptionalKeyPath<Value, SubValue, SubReadFn>, ) -> FailableCombinedKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) + 'static, impl for<'r> Fn(&'r mut Root) + 'static, impl Fn(Root) + 'static>
where SubReadFn: for<'r> Fn(&'r Value) -> Option<&'r SubValue> + 'static, ReadFn: 'static, WriteFn: 'static, OwnedFn: 'static, Value: 'static, Root: 'static, SubValue: 'static,

Compose with OptionalKeyPath (readable only) Returns a FailableCombinedKeyPath that uses the readable from OptionalKeyPath and creates dummy writable/owned closures that return None

Source§

impl FailableCombinedKeyPath<(), (), fn(&()) -> Option<&()>, fn(&mut ()) -> Option<&mut ()>, fn(()) -> Option<()>>

Source

pub fn failable_combined<Root, Value, ReadFn, WriteFn, OwnedFn>( readable: ReadFn, writable: WriteFn, owned: OwnedFn, ) -> FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, WriteFn: for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static, OwnedFn: Fn(Root) -> Option<Value> + 'static,

Create a FailableCombinedKeyPath with all three access patterns

Trait Implementations§

Source§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> Clone for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where Root: Clone, Value: Clone, ReadFn: Clone + for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static, WriteFn: Clone + for<'r> Fn(&'r mut Root) -> Option<&'r mut Value> + 'static, OwnedFn: Clone + Fn(Root) -> Option<Value> + 'static,

Source§

fn clone( &self, ) -> FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>

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<Root, Value, ReadFn, WriteFn, OwnedFn> Freeze for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: Freeze, WriteFn: Freeze, OwnedFn: Freeze,

§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> RefUnwindSafe for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: RefUnwindSafe, WriteFn: RefUnwindSafe, OwnedFn: RefUnwindSafe, Root: RefUnwindSafe, Value: RefUnwindSafe,

§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> Send for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: Send, WriteFn: Send, OwnedFn: Send, Root: Send, Value: Send,

§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> Sync for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: Sync, WriteFn: Sync, OwnedFn: Sync, Root: Sync, Value: Sync,

§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> Unpin for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: Unpin, WriteFn: Unpin, OwnedFn: Unpin, Root: Unpin, Value: Unpin,

§

impl<Root, Value, ReadFn, WriteFn, OwnedFn> UnwindSafe for FailableCombinedKeyPath<Root, Value, ReadFn, WriteFn, OwnedFn>
where ReadFn: UnwindSafe, WriteFn: UnwindSafe, OwnedFn: 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, 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.