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§
Sourcefn literal(&self, text: &str) -> Self::Ty
fn literal(&self, text: &str) -> Self::Ty
One fixed piece of text, as a value: content that happens to be constant.
Sourcefn name_word(&self, words: Words<'_>) -> Self::Ty
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.
Sourcefn int(&self, signed: bool, bits: u16) -> Self::Ty
fn int(&self, signed: bool, bits: u16) -> Self::Ty
An integer of a stated width and signedness.
Sourcefn hex(&self, item: Self::Ty) -> Self::Ty
fn hex(&self, item: Self::Ty) -> Self::Ty
Written as 0x-prefixed hexadecimal, rather than however the item would appear alone.
Sourcefn decimal(&self, item: Self::Ty) -> Self::Ty
fn decimal(&self, item: Self::Ty) -> Self::Ty
Written as decimal digits in text, which is what a width beyond a JSON number requires.
Sourcefn map(&self, key: Self::Ty, value: Self::Ty) -> Self::Ty
fn map(&self, key: Self::Ty, value: Self::Ty) -> Self::Ty
An association from one shape to another.
Sourcefn choice(&self, alternatives: Vec<Self::Ty>) -> Self::Ty
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.
Sourcefn named(&self, words: Words<'_>, body: Self::Ty) -> Self::Ty
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".