pub struct JsonSchemaValidatingEncoder { /* private fields */ }Expand description
An encoder that validates an Attestation’s optional payload field
against a provided JSON schema before serializing the entire Attestation.
Implementations§
Source§impl JsonSchemaValidatingEncoder
impl JsonSchemaValidatingEncoder
Sourcepub fn new(schema_value: Value) -> Self
pub fn new(schema_value: Value) -> Self
Creates a new validating encoder which will use the provided schema.
Sourcepub fn encode(&self, att: &Attestation) -> Result<Vec<u8>, StorageError>
pub fn encode(&self, att: &Attestation) -> Result<Vec<u8>, StorageError>
Validates the att.payload against the stored schema (if payload exists)
and then serializes the entire att struct to pretty JSON bytes.
Returns Err if schema validation fails for an existing payload, or if
final JSON serialization fails.
Trait Implementations§
Source§impl Clone for JsonSchemaValidatingEncoder
impl Clone for JsonSchemaValidatingEncoder
Source§fn clone(&self) -> JsonSchemaValidatingEncoder
fn clone(&self) -> JsonSchemaValidatingEncoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for JsonSchemaValidatingEncoder
impl RefUnwindSafe for JsonSchemaValidatingEncoder
impl Send for JsonSchemaValidatingEncoder
impl Sync for JsonSchemaValidatingEncoder
impl Unpin for JsonSchemaValidatingEncoder
impl UnsafeUnpin for JsonSchemaValidatingEncoder
impl UnwindSafe for JsonSchemaValidatingEncoder
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