KeyPaths

Enum KeyPaths 

Source
pub enum KeyPaths<Root, Value> {
    Readable(Rc<dyn for<'a> Fn(&'a Root) -> &'a Value>),
    ReadableEnum {
        extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>,
        embed: Rc<dyn Fn(Value) -> Root>,
    },
    FailableReadable(Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>),
    Writable(Rc<dyn for<'a> Fn(&'a mut Root) -> &'a mut Value>),
    FailableWritable(Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>),
    WritableEnum {
        extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>,
        extract_mut: Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>,
        embed: Rc<dyn Fn(Value) -> Root>,
    },
}

Variants§

§

Readable(Rc<dyn for<'a> Fn(&'a Root) -> &'a Value>)

§

ReadableEnum

Fields

§extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>
§embed: Rc<dyn Fn(Value) -> Root>
§

FailableReadable(Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>)

§

Writable(Rc<dyn for<'a> Fn(&'a mut Root) -> &'a mut Value>)

§

FailableWritable(Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>)

§

WritableEnum

Fields

§extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>
§extract_mut: Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>
§embed: Rc<dyn Fn(Value) -> Root>

Implementations§

Source§

impl<Root, Value> KeyPaths<Root, Value>

Source

pub fn readable( get: impl for<'a> Fn(&'a Root) -> &'a Value + 'static, ) -> KeyPaths<Root, Value>

Source

pub fn writable( get_mut: impl for<'a> Fn(&'a mut Root) -> &'a mut Value + 'static, ) -> KeyPaths<Root, Value>

Source

pub fn failable_readable( get: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, ) -> KeyPaths<Root, Value>

Source

pub fn failable_writable( get_mut: impl for<'a> Fn(&'a mut Root) -> Option<&'a mut Value> + 'static, ) -> KeyPaths<Root, Value>

Source

pub fn readable_enum( embed: impl Fn(Value) -> Root + 'static, extract: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, ) -> KeyPaths<Root, Value>

Source

pub fn writable_enum( embed: impl Fn(Value) -> Root + 'static, extract: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, extract_mut: impl for<'a> Fn(&'a mut Root) -> Option<&'a mut Value> + 'static, ) -> KeyPaths<Root, Value>

Source§

impl<Root, Value> KeyPaths<Root, Value>

Source

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

Get an immutable reference if possible

Source

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

Get a mutable reference if possible

Source

pub fn embed(&self, value: Value) -> Option<Root>
where Value: Clone,

Source

pub fn embed_mut(&self, value: Value) -> Option<Root>
where Value: Clone,

Source

pub fn iter<'a, T>( &'a self, root: &'a Root, ) -> Option<<&'a Value as IntoIterator>::IntoIter>
where &'a Value: IntoIterator<Item = &'a T>, T: 'a,

Iter over immutable references if Value: IntoIterator

Source

pub fn iter_mut<'a, T>( &'a self, root: &'a mut Root, ) -> Option<<&'a mut Value as IntoIterator>::IntoIter>
where &'a mut Value: IntoIterator<Item = &'a mut T>, T: 'a,

Iter over mutable references if &mut Value: IntoIterator

Source

pub fn into_iter<T>( self, root: Root, ) -> Option<<Value as IntoIterator>::IntoIter>
where Value: IntoIterator<Item = T> + Clone,

Consume root and iterate if Value: IntoIterator

Source§

impl<Root, Mid> KeyPaths<Root, Mid>
where Root: 'static, Mid: 'static,

Source

pub fn compose<Value>(self, mid: KeyPaths<Mid, Value>) -> KeyPaths<Root, Value>
where Value: 'static,

Auto Trait Implementations§

§

impl<Root, Value> Freeze for KeyPaths<Root, Value>

§

impl<Root, Value> !RefUnwindSafe for KeyPaths<Root, Value>

§

impl<Root, Value> !Send for KeyPaths<Root, Value>

§

impl<Root, Value> !Sync for KeyPaths<Root, Value>

§

impl<Root, Value> Unpin for KeyPaths<Root, Value>

§

impl<Root, Value> !UnwindSafe for KeyPaths<Root, Value>

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.