Skip to main content

CodecShape

Struct CodecShape 

Source
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

Source

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.

Source

pub const fn owner(&self) -> &CodecTypePath

The type the codec is written for.

Source

pub fn refusal(&self) -> &str

The spelling the rendered decode refusal is declared under.

Source

pub const fn assembly(&self) -> &CodecAssembly

The road the decoded members are assembled by.

Source

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.

Source

pub fn count(&self) -> usize

How many members the shape declares; structurally at least one.

Trait Implementations§

Source§

impl Clone for CodecShape

Source§

fn clone(&self) -> CodecShape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodecShape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CodecShape

Source§

impl Hash for CodecShape

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CodecShape

Source§

fn eq(&self, other: &CodecShape) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CodecShape

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.