pub struct JsonDesc {
pub to_value: fn(&dyn Any) -> Value,
pub try_value: fn(&dyn Any) -> Result<Value, ModelError>,
pub bytes: fn(&dyn Any) -> Option<Vec<u8>>,
pub equal: Option<fn(&dyn Any, &dyn Any) -> bool>,
pub from_value: fn(&Value, &mut dyn Any) -> Result<(), ModelError>,
pub default: fn(&mut dyn Any) -> Result<(), ModelError>,
pub null_default: bool,
pub structural: bool,
pub staged: (fn() -> Box<dyn Any>, for<'a> fn(&'a dyn Any) -> Option<&'a dyn Any>),
pub replace: fn(&mut dyn Any, &mut dyn Any) -> Result<(), ModelError>,
}Expand description
A type stored whole through its serde form: as one JSON string, last
writer winning (json_model!), or as that form’s
maps, lists and scalars (value_model!).
Fields§
§to_value: fn(&dyn Any) -> ValueThe value’s JSON form.
try_value: fn(&dyn Any) -> Result<Value, ModelError>The value’s JSON form, or why it has none: what its stored text is
written from (json_text).
bytes: fn(&dyn Any) -> Option<Vec<u8>>The value serialised, as compact JSON text: equal texts are equal JSON forms, so two values compare without building either form.
equal: Option<fn(&dyn Any, &dyn Any) -> bool>Whether two values are equal in memory, for a type whose equal values
have equal JSON forms (a derived PartialEq): a diff passes over an
equal pair without serialising either. None when the type has no
such equality; unequal values are still compared by their forms.
from_value: fn(&Value, &mut dyn Any) -> Result<(), ModelError>Put the value of a JSON form into out, an Option of the type. The
stored text is read through it too (json_text).
default: fn(&mut dyn Any) -> Result<(), ModelError>Put the type’s default into out.
null_default: boolnull reads as the default rather than through serde.
structural: boolStored as its JSON form’s maps, lists and scalars
(value_model!) rather than as JSON text.
staged: (fn() -> Box<dyn Any>, for<'a> fn(&'a dyn Any) -> Option<&'a dyn Any>)An empty Option of the type, the value in a filled one, and moving
it out over another.
replace: fn(&mut dyn Any, &mut dyn Any) -> Result<(), ModelError>Auto Trait Implementations§
impl Forget for JsonDesc
impl Freeze for JsonDesc
impl Move for JsonDesc
impl RefUnwindSafe for JsonDesc
impl Send for JsonDesc
impl Sync for JsonDesc
impl Unpin for JsonDesc
impl UnsafeUnpin for JsonDesc
impl UnwindSafe for JsonDesc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more