pub struct SerializationSchema(/* private fields */);Expand description
SerializationSchema<T>: a parser with its default and the description
of its domain. Clones are the same schema.
Implementations§
Source§impl SerializationSchema
impl SerializationSchema
Sourcepub fn new(
meta: SerializationSchemaMeta,
default_value: Value,
is_equal: Option<SchemaIsEqual>,
accepts: Option<SchemaAccepts>,
parse: impl Fn(&Value) -> Value + 'static,
) -> Self
pub fn new( meta: SerializationSchemaMeta, default_value: Value, is_equal: Option<SchemaIsEqual>, accepts: Option<SchemaAccepts>, parse: impl Fn(&Value) -> Value + 'static, ) -> Self
A schema of your own (JS’s hand-rolled schema: a parse function with
meta, defaultValue and optionally isEqual and accepts). An
accepts given here is declared: it narrows what a union will
choose this schema for.
Sourcepub fn parse(&self, value: &Value) -> Value
pub fn parse(&self, value: &Value) -> Value
Parses an untrusted value; never fails, substituting the default.
Sourcepub fn default_value(&self) -> &Value
pub fn default_value(&self) -> &Value
defaultValue: what parse(undefined) returns, which the compact
form omits.
Sourcepub fn meta(&self) -> &SerializationSchemaMeta
pub fn meta(&self) -> &SerializationSchemaMeta
meta.
Sourcepub fn is_equal(&self) -> Option<&SchemaIsEqual>
pub fn is_equal(&self) -> Option<&SchemaIsEqual>
isEqual, when the schema declares one.
Sourcepub fn accepts(&self) -> Option<&SchemaAccepts>
pub fn accepts(&self) -> Option<&SchemaAccepts>
accepts, when the schema has one.
Sourcepub fn declared_accepts(&self) -> Option<&SchemaAccepts>
pub fn declared_accepts(&self) -> Option<&SchemaAccepts>
declaredAccepts(schema): the accepts a schema’s author wrote,
not one a combinator derived.
Sourcepub fn is(&self, other: &SerializationSchema) -> bool
pub fn is(&self, other: &SerializationSchema) -> bool
Whether self and other are the same schema (===).
Trait Implementations§
Source§impl Clone for SerializationSchema
impl Clone for SerializationSchema
Auto Trait Implementations§
impl !RefUnwindSafe for SerializationSchema
impl !Send for SerializationSchema
impl !Sync for SerializationSchema
impl !UnwindSafe for SerializationSchema
impl Forget for SerializationSchema
impl Freeze for SerializationSchema
impl Move for SerializationSchema
impl Unpin for SerializationSchema
impl UnsafeUnpin for SerializationSchema
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
Mutably borrows from an owned value. Read more