pub trait Valuable {
// Required methods
fn as_value(&self) -> Value<'_>;
fn visit(&self, visit: &mut dyn Visit);
// Provided method
fn visit_slice(slice: &[Self], visit: &mut dyn Visit)
where Self: Sized { ... }
}
Expand description
A type that can be converted to a Value
.
Valuable
types are inspected by defining a Visit
implementation and
using it when calling Valuable::visit
. See Visit
documentation for
more details.
The Valuable
procedural macro makes implementing Valuable
easy. Users
can add add #[derive(Valuable)]
to their types.
Valuable
provides implementations for many Rust primitives and standard
library types.
Types implementing Valuable
may also implement one of the more specific
traits: Structable
, Enumerable
, Listable
, and Mappable
. These traits
should be implemented when the type is a nested container of other Valuable
types.
Required Methods§
Sourcefn visit(&self, visit: &mut dyn Visit)
fn visit(&self, visit: &mut dyn Visit)
Calls the relevant method on Visit
to extract data from self
.
This method is used to extract type-specific data from the value and is
intended to be an implementation detail. For example, Vec
implements
visit
by calling visit_value()
on each of its elements. Structs
implement visit
by calling visit_named_fields()
or
visit_unnamed_fields()
.
Usually, users will call the visit
function instead.
Provided Methods§
Sourcefn visit_slice(slice: &[Self], visit: &mut dyn Visit)where
Self: Sized,
fn visit_slice(slice: &[Self], visit: &mut dyn Visit)where
Self: Sized,
Calls Visit::visit_primitive_slice()
with self
.
This method is an implementation detail used to optimize visiting primitive slices.
Trait Implementations§
Implementations on Foreign Types§
Source§impl Valuable for AtomicBool
impl Valuable for AtomicBool
Source§impl Valuable for AtomicIsize
impl Valuable for AtomicIsize
Source§impl Valuable for AtomicUsize
impl Valuable for AtomicUsize
Source§impl Valuable for NonZeroI16
impl Valuable for NonZeroI16
Source§impl Valuable for NonZeroI32
impl Valuable for NonZeroI32
Source§impl Valuable for NonZeroI64
impl Valuable for NonZeroI64
Source§impl Valuable for NonZeroI128
impl Valuable for NonZeroI128
Source§impl Valuable for NonZeroIsize
impl Valuable for NonZeroIsize
Source§impl Valuable for NonZeroU16
impl Valuable for NonZeroU16
Source§impl Valuable for NonZeroU32
impl Valuable for NonZeroU32
Source§impl Valuable for NonZeroU64
impl Valuable for NonZeroU64
Source§impl Valuable for NonZeroU128
impl Valuable for NonZeroU128
Source§impl Valuable for NonZeroUsize
impl Valuable for NonZeroUsize
Source§impl<K: Valuable, V: Valuable> Valuable for BTreeMap<K, V>
Available on crate feature alloc
only.
impl<K: Valuable, V: Valuable> Valuable for BTreeMap<K, V>
alloc
only.Source§impl<K: Valuable, V: Valuable, S> Valuable for HashMap<K, V, S>
Available on crate feature std
only.
impl<K: Valuable, V: Valuable, S> Valuable for HashMap<K, V, S>
std
only.Source§impl<T0, T1, T2> Valuable for (T0, T1, T2)
impl<T0, T1, T2> Valuable for (T0, T1, T2)
Source§impl<T0, T1, T2, T3> Valuable for (T0, T1, T2, T3)
impl<T0, T1, T2, T3> Valuable for (T0, T1, T2, T3)
Source§impl<T0, T1, T2, T3, T4> Valuable for (T0, T1, T2, T3, T4)
impl<T0, T1, T2, T3, T4> Valuable for (T0, T1, T2, T3, T4)
Source§impl<T0, T1, T2, T3, T4, T5> Valuable for (T0, T1, T2, T3, T4, T5)
impl<T0, T1, T2, T3, T4, T5> Valuable for (T0, T1, T2, T3, T4, T5)
Source§impl<T0, T1, T2, T3, T4, T5, T6> Valuable for (T0, T1, T2, T3, T4, T5, T6)
impl<T0, T1, T2, T3, T4, T5, T6> Valuable for (T0, T1, T2, T3, T4, T5, T6)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7)
impl<T0, T1, T2, T3, T4, T5, T6, T7> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
Source§impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Valuable for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
Source§impl<T: Valuable + Eq + Hash, H: BuildHasher> Valuable for HashSet<T, H>
Available on crate feature std
only.
impl<T: Valuable + Eq + Hash, H: BuildHasher> Valuable for HashSet<T, H>
std
only.Source§impl<T: Valuable> Valuable for LinkedList<T>
Available on crate feature alloc
only.
impl<T: Valuable> Valuable for LinkedList<T>
alloc
only.Source§impl<T: Valuable> Valuable for Arc<[T]>
Available on non-valuable_no_atomic_cas
and crate feature alloc
only.
impl<T: Valuable> Valuable for Arc<[T]>
valuable_no_atomic_cas
and crate feature alloc
only.Source§impl<T: ?Sized + Valuable> Valuable for Arc<T>
Available on non-valuable_no_atomic_cas
and crate feature alloc
only.
impl<T: ?Sized + Valuable> Valuable for Arc<T>
valuable_no_atomic_cas
and crate feature alloc
only.