pub struct CodecShape { /* private fields */ }Expand description
The complete declared shape one codec is rendered for.
§Bounds
The member set is structurally non-empty: a codec over no member writes no byte and reads none, so it could refuse for one reason and would admit every other input — and a codec that cannot refuse is not the validator this home says a codec is.
The rendered refusal’s spelling is carried rather than derived, because it is a type declared in the caller’s own scope and this home may not choose a name there.
Implementations§
Source§impl CodecShape
impl CodecShape
Sourcepub fn declared(
owner: CodecTypePath,
refusal: &str,
assembly: CodecAssembly,
members: Vec<CodecMember>,
) -> Result<Self, CodecError>
pub fn declared( owner: CodecTypePath, refusal: &str, assembly: CodecAssembly, members: Vec<CodecMember>, ) -> Result<Self, CodecError>
Declare one complete shape.
§Errors
Returns CodecIssue::RefusalSpellingNotAnIdentifier where the rendered refusal’s spelling cannot name a rendered item — not one Rust identifier, or a keyword the language already took — then whatever the pass over the offered members established — CodecIssue::MemberSpellingDoubled and CodecIssue::MemberShadowsBinding, which co-establish — then CodecIssue::MembersAbsent where no member was supplied and CodecIssue::MembersUnbounded where the members outgrow the declared magnitude.
Sourcepub const fn owner(&self) -> &CodecTypePath
pub const fn owner(&self) -> &CodecTypePath
The type the codec is written for.
Sourcepub const fn assembly(&self) -> &CodecAssembly
pub const fn assembly(&self) -> &CodecAssembly
The road the decoded members are assembled by.
Sourcepub fn members(&self) -> impl Iterator<Item = &CodecMember>
pub fn members(&self) -> impl Iterator<Item = &CodecMember>
The members, in the order the shape declares them.
§Ordering
This order IS meaning: it is the order the encode road writes and the decode road reads, so the same members supplied in another order are a different byte string for the same value — which is exactly what a canonical encoding may not have two of.
Trait Implementations§
Source§impl Clone for CodecShape
impl Clone for CodecShape
Source§fn clone(&self) -> CodecShape
fn clone(&self) -> CodecShape
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more