pub trait Document: Serialize + DeserializeOwned {
const SCHEMA: &'static str;
const LIMITS: ParseLimits;
// Required method
fn schema(&self) -> &str;
// Provided methods
fn parse(bytes: &[u8]) -> Result<Self, DocumentError> { ... }
fn canonical(&self) -> Result<Vec<u8>, CanonicalError> { ... }
fn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>
where Self: PartialEq { ... }
fn record_digest(&self) -> Result<ContentDigest, CanonicalError>
where Self: PartialEq { ... }
}Expand description
A Rustev document with a schema string and a limit set.
Required Associated Constants§
Sourceconst LIMITS: ParseLimits
const LIMITS: ParseLimits
The limit set its bytes are scanned against (spec 002, 3.2.5).
Required Methods§
Provided Methods§
Sourcefn parse(bytes: &[u8]) -> Result<Self, DocumentError>
fn parse(bytes: &[u8]) -> Result<Self, DocumentError>
Scan, deserialize and check the schema string.
Sourcefn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>where
Self: PartialEq,
fn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>where
Self: PartialEq,
The record canonical bytes (spec 004, 5.6): the canonical bytes, with finite fractional numbers written in shortest round-trip form.
Sourcefn record_digest(&self) -> Result<ContentDigest, CanonicalError>where
Self: PartialEq,
fn record_digest(&self) -> Result<ContentDigest, CanonicalError>where
Self: PartialEq,
sha256(SCHEMA || 0x00 || record canonical bytes) (spec 004, 3.1.6).
Equal to the identity of an identified document.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".