Trait preserves::value::repr::NestedValue
source · pub trait NestedValue:
Sized
+ Debug
+ Clone
+ Eq
+ Hash
+ Ord {
type Embedded: Embeddable;
Show 14 methods
// Required methods
fn wrap(anns: Annotations<Self>, v: Value<Self>) -> Self;
fn annotations(&self) -> &Annotations<Self>;
fn value(&self) -> &Value<Self>;
fn pieces(self) -> (Annotations<Self>, Value<Self>);
fn value_owned(self) -> Value<Self>;
// Provided methods
fn new<V>(v: V) -> Self
where Value<Self>: From<V> { ... }
fn domain<E>(e: E) -> Self
where Self::Embedded: From<E> { ... }
fn symbol(n: &str) -> Self { ... }
fn bytestring<'a, V: Into<Cow<'a, [u8]>>>(v: V) -> Self { ... }
fn value_class(&self) -> ValueClass { ... }
fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result { ... }
fn strip_annotations<M: NestedValue<Embedded = Self::Embedded>>(&self) -> M { ... }
fn copy_via<M: NestedValue, F, Err>(&self, f: &mut F) -> Result<M, Err>
where F: FnMut(&Self::Embedded) -> Result<Value<M>, Err> { ... }
fn foreach_embedded<F, Err>(&self, f: &mut F) -> Result<(), Err>
where F: FnMut(&Self::Embedded) -> Result<(), Err> { ... }
}
Expand description
Required Associated Types§
sourcetype Embedded: Embeddable
type Embedded: Embeddable
Every representation of Preserves values has an associated type: that of the Rust data able to be embedded inside a value.
Required Methods§
sourcefn wrap(anns: Annotations<Self>, v: Value<Self>) -> Self
fn wrap(anns: Annotations<Self>, v: Value<Self>) -> Self
Attaches the given Annotations to the Value.
sourcefn annotations(&self) -> &Annotations<Self>
fn annotations(&self) -> &Annotations<Self>
Retrieves any annotations attached to self
.
sourcefn pieces(self) -> (Annotations<Self>, Value<Self>)
fn pieces(self) -> (Annotations<Self>, Value<Self>)
Consumes self
, yielding its annotations and underlying Value.
sourcefn value_owned(self) -> Value<Self>
fn value_owned(self) -> Value<Self>
Consumes self
, yielding its underlying Value and discarding its annotations.
Provided Methods§
sourcefn domain<E>(e: E) -> Self
fn domain<E>(e: E) -> Self
Embeds e
to a Preserves embedded
value; e
is first converted to Self::Embedded.
sourcefn bytestring<'a, V: Into<Cow<'a, [u8]>>>(v: V) -> Self
fn bytestring<'a, V: Into<Cow<'a, [u8]>>>(v: V) -> Self
Yields a Preserves ByteString
.
sourcefn value_class(&self) -> ValueClass
fn value_class(&self) -> ValueClass
Retrieves the ValueClass of self
.
sourcefn debug_fmt(&self, f: &mut Formatter<'_>) -> Result
fn debug_fmt(&self, f: &mut Formatter<'_>) -> Result
Supplies an opportunity to customize debug formatting for self
. Defaults to writing
@
-prefixed annotations followed by the underlying value.
sourcefn strip_annotations<M: NestedValue<Embedded = Self::Embedded>>(&self) -> M
fn strip_annotations<M: NestedValue<Embedded = Self::Embedded>>(&self) -> M
Yields a deep copy of self
with all annotations (recursively) removed.
sourcefn copy_via<M: NestedValue, F, Err>(&self, f: &mut F) -> Result<M, Err>
fn copy_via<M: NestedValue, F, Err>(&self, f: &mut F) -> Result<M, Err>
Yields a deep copy of self
, mapping embedded values to a new type via f
.
sourcefn foreach_embedded<F, Err>(&self, f: &mut F) -> Result<(), Err>
fn foreach_embedded<F, Err>(&self, f: &mut F) -> Result<(), Err>
Calls f
once for each (recursively) embedded Self::Embedded value in self
.