pub struct Record<'a> { /* private fields */ }Expand description
One OCMF record, borrowed from the text it was read from.
Implementations§
Source§impl<'a> Record<'a>
impl<'a> Record<'a>
Sourcepub fn parse(src: &'a str) -> Result<Self, ParseError>
pub fn parse(src: &'a str) -> Result<Self, ParseError>
Reads a record under Profile::Interop and the default Limits.
§Errors
ParseError when the record cannot be read at all. Under Interop,
departures from the specification are collected into
Record::deviations rather than raised.
Sourcepub fn parse_with(
src: &'a str,
profile: Profile,
limits: &Limits,
) -> Result<Self, ParseError>
pub fn parse_with( src: &'a str, profile: Profile, limits: &Limits, ) -> Result<Self, ParseError>
Reads a record under an explicit profile and limits.
§Errors
ParseError::Deviates when the profile refuses something the record
does, and the other variants when it cannot be read at all.
Sourcepub fn signed_bytes(&self) -> &'a [u8] ⓘ
pub fn signed_bytes(&self) -> &'a [u8] ⓘ
The bytes the signature covers, as a slice of the input.
Never reconstructed, never re-serialised, never normalised.
Sourcepub fn payload_text(&self) -> &'a str
pub fn payload_text(&self) -> &'a str
The payload section as text.
Sourcepub fn signature_text(&self) -> &'a str
pub fn signature_text(&self) -> &'a str
The signature section as text.
Sourcepub const fn signature(&self) -> &SignatureSection<'a>
pub const fn signature(&self) -> &SignatureSection<'a>
The typed signature section.
Sourcepub fn embedded_public_key(&self) -> Option<&'a str>
pub fn embedded_public_key(&self) -> Option<&'a str>
The withdrawn fourth section’s contents, when the record carries one.
Sourcepub fn deviations(&self) -> &[Deviation]
pub fn deviations(&self) -> &[Deviation]
Every departure from the specification found while reading this record.
Sourcepub fn payload_digest(&self) -> [u8; 32]
Available on crate feature digest only.
pub fn payload_digest(&self) -> [u8; 32]
digest only.SHA-256 of Record::signed_bytes — the record’s identity.
Not the identity of the record text: ECDSA signatures are malleable
and DER admits non-canonical encodings, so one payload can appear under
many distinct SD values that all verify. Deduplicating on the text
therefore stores the same reading twice, and in a billing pipeline that
is a double charge. Key on this.
Source§impl Record<'_>
impl Record<'_>
Sourcepub fn summary(&self) -> RecordSummary
pub fn summary(&self) -> RecordSummary
A serialisable report about this record.
The record itself travels verbatim in
RecordSummary::record; everything else is derived. See the module
docs for why this is not impl Serialize for Record.