Skip to main content

ShapeAlg

Trait ShapeAlg 

Source
pub trait ShapeAlg: Sorts {
Show 18 methods // Required methods fn truth(&self) -> Self::Ty; fn unit(&self) -> Self::Ty; fn text(&self) -> Self::Ty; fn literal(&self, text: &str) -> Self::Ty; fn name_word(&self, words: Words<'_>) -> Self::Ty; fn int(&self, signed: bool, bits: u16) -> Self::Ty; fn float(&self, bits: u16) -> Self::Ty; fn bytes(&self, len: Option<usize>) -> Self::Ty; fn hex(&self, item: Self::Ty) -> Self::Ty; fn decimal(&self, item: Self::Ty) -> Self::Ty; fn base64(&self, item: Self::Ty) -> Self::Ty; fn opt(&self, item: Self::Ty) -> Self::Ty; fn seq(&self, item: Self::Ty) -> Self::Ty; fn map(&self, key: Self::Ty, value: Self::Ty) -> Self::Ty; fn product(&self, fields: Vec<Self::Field>) -> Self::Ty; fn choice(&self, alternatives: Vec<Self::Ty>) -> Self::Ty; fn named(&self, words: Words<'_>, body: Self::Ty) -> Self::Ty; fn reference(&self, words: Words<'_>) -> Self::Ty;
}
Expand description

The shape sort: what data is, and how it is written.

Required Methods§

Source

fn truth(&self) -> Self::Ty

A boolean.

Source

fn unit(&self) -> Self::Ty

The empty value: null, or an absent member.

Source

fn text(&self) -> Self::Ty

Text.

Source

fn literal(&self, text: &str) -> Self::Ty

One fixed piece of text, as a value: content that happens to be constant.

Source

fn name_word(&self, words: Words<'_>) -> Self::Ty

A value whose content is a name, spelled however the interpretation spells names.

What a discriminant carries, and what a choice between names alone is made of. Distinct from ShapeAlg::literal because a name is words and a literal is already text.

Source

fn int(&self, signed: bool, bits: u16) -> Self::Ty

An integer of a stated width and signedness.

Source

fn float(&self, bits: u16) -> Self::Ty

A floating-point number of a stated width.

Source

fn bytes(&self, len: Option<usize>) -> Self::Ty

Opaque bytes, of a stated length when fixed.

Source

fn hex(&self, item: Self::Ty) -> Self::Ty

Written as 0x-prefixed hexadecimal, rather than however the item would appear alone.

Source

fn decimal(&self, item: Self::Ty) -> Self::Ty

Written as decimal digits in text, which is what a width beyond a JSON number requires.

Source

fn base64(&self, item: Self::Ty) -> Self::Ty

Written as base64 text.

Source

fn opt(&self, item: Self::Ty) -> Self::Ty

A value that may be absent.

Source

fn seq(&self, item: Self::Ty) -> Self::Ty

An ordered sequence of one shape.

Source

fn map(&self, key: Self::Ty, value: Self::Ty) -> Self::Ty

An association from one shape to another.

Source

fn product(&self, fields: Vec<Self::Field>) -> Self::Ty

A product of members.

Source

fn choice(&self, alternatives: Vec<Self::Ty>) -> Self::Ty

A choice between alternatives, carrying no discriminant of its own.

Every encoding that does write one is derived from this — see the extension in derived.

Source

fn named(&self, words: Words<'_>, body: Self::Ty) -> Self::Ty

Introduces a name for a shape, so an interpretation can state it once.

A name is an identity, not an instruction: an interpretation that declares types emits one and refers to it, and one that types structurally may spell the shape at each use.

Source

fn reference(&self, words: Words<'_>) -> Self::Ty

Uses a name introduced elsewhere, which is what makes recursion expressible.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§