Struct miniconf::Leaf

source ·
#[repr(transparent)]
pub struct Leaf<T: ?Sized>(pub T);
Expand description

Serialize/Deserialize/Any leaf

This wraps Serialize, Deserialize, and Any into Tree a leaf node.

use miniconf::{json, Leaf, Tree};
let mut s = Leaf(0);
json::set(&mut s, "", b"7").unwrap();
assert!(matches!(*s, 7));

Tuple Fields§

§0: T

Implementations§

source§

impl<T> Leaf<T>

source

pub fn into_inner(self) -> T

Extract just the inner

Trait Implementations§

source§

impl<T: Clone + ?Sized> Clone for Leaf<T>

source§

fn clone(&self) -> Leaf<T>

Returns a copy 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<T: Debug + ?Sized> Debug for Leaf<T>

source§

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

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

impl<T: Default + ?Sized> Default for Leaf<T>

source§

fn default() -> Leaf<T>

Returns the “default value” for a type. Read more
source§

impl<T: ?Sized> Deref for Leaf<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: ?Sized> DerefMut for Leaf<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de, T> Deserialize<'de> for Leaf<T>
where T: Deserialize<'de> + ?Sized,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> From<T> for Leaf<T>

source§

fn from(value: T) -> Self

Converts to this type from the input type.
source§

impl<T: Hash + ?Sized> Hash for Leaf<T>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
source§

impl<T: Ord + ?Sized> Ord for Leaf<T>

source§

fn cmp(&self, other: &Leaf<T>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl<T: PartialEq + ?Sized> PartialEq for Leaf<T>

source§

fn eq(&self, other: &Leaf<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd + ?Sized> PartialOrd for Leaf<T>

source§

fn partial_cmp(&self, other: &Leaf<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T> Serialize for Leaf<T>
where T: Serialize + ?Sized,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Any> TreeAny for Leaf<T>

source§

fn ref_any_by_key<K>(&self, keys: K) -> Result<&dyn Any, Traversal>
where K: Keys,

Obtain a reference to a dyn Any trait object for a leaf node.
source§

fn mut_any_by_key<K>(&mut self, keys: K) -> Result<&mut dyn Any, Traversal>
where K: Keys,

Obtain a mutable reference to a dyn Any trait object for a leaf node.
source§

fn ref_by_key<T: Any, K: IntoKeys>(&self, keys: K) -> Result<&T, Traversal>

Obtain a reference to a leaf of known type by key.
source§

fn mut_by_key<T: Any, K: IntoKeys>( &mut self, keys: K, ) -> Result<&mut T, Traversal>

Obtain a mutable reference to a leaf of known type by key.
source§

impl<'de, T: Deserialize<'de>> TreeDeserialize<'de> for Leaf<T>

source§

fn deserialize_by_key<K, D>( &mut self, keys: K, de: D, ) -> Result<usize, Error<D::Error>>
where K: Keys, D: Deserializer<'de>,

Deserialize a leaf node by its keys. Read more
source§

impl<T: ?Sized> TreeKey for Leaf<T>

source§

fn traverse_all<W: Walk>() -> Result<W, W::Error>

Walk metadata about all paths. Read more
source§

fn traverse_by_key<K, F, E>(keys: K, _func: F) -> Result<usize, Error<E>>
where K: Keys, F: FnMut(usize, Option<&'static str>, NonZero<usize>) -> Result<(), E>,

Traverse from the root to a leaf and call a function for each node. Read more
source§

fn transcode<N, K>(keys: K) -> Result<(N, Node), Traversal>
where K: IntoKeys, N: Transcode + Default,

Transcode keys to a new keys type representation Read more
source§

fn nodes<N, const D: usize>() -> NodeIter<Self, N, D>
where N: Transcode + Default,

Return an iterator over nodes of a given type Read more
source§

impl<T: Serialize + ?Sized> TreeSerialize for Leaf<T>

source§

fn serialize_by_key<K, S>( &self, keys: K, ser: S, ) -> Result<usize, Error<S::Error>>
where K: Keys, S: Serializer,

Serialize a node by keys. Read more
source§

impl<T: Copy + ?Sized> Copy for Leaf<T>

source§

impl<T: Eq + ?Sized> Eq for Leaf<T>

source§

impl<T: ?Sized> StructuralPartialEq for Leaf<T>

Auto Trait Implementations§

§

impl<T> Freeze for Leaf<T>
where T: Freeze + ?Sized,

§

impl<T> RefUnwindSafe for Leaf<T>
where T: RefUnwindSafe + ?Sized,

§

impl<T> Send for Leaf<T>
where T: Send + ?Sized,

§

impl<T> Sync for Leaf<T>
where T: Sync + ?Sized,

§

impl<T> Unpin for Leaf<T>
where T: Unpin + ?Sized,

§

impl<T> UnwindSafe for Leaf<T>
where T: UnwindSafe + ?Sized,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> TreeDeserializeOwned for T
where T: for<'de> TreeDeserialize<'de>,