pub enum Term {
Show 18 variants
Truth,
Unit,
Text,
Literal(String),
NameWord(Vec<String>),
Int {
signed: bool,
bits: u16,
},
Float {
bits: u16,
},
Bytes {
len: Option<usize>,
},
Hex(Box<Term>),
Decimal(Box<Term>),
Base64(Box<Term>),
Opt(Box<Term>),
Seq(Box<Term>),
Map(Box<Term>, Box<Term>),
Product(Vec<Member>),
Choice(Vec<Term>),
Named {
words: Vec<String>,
body: Box<Term>,
},
Reference(Vec<String>),
}Expand description
A shape, as a value.
Variants§
Truth
Unit
Text
Literal(String)
NameWord(Vec<String>)
Int
Float
Bytes
Hex(Box<Term>)
Decimal(Box<Term>)
Base64(Box<Term>)
Opt(Box<Term>)
Seq(Box<Term>)
Map(Box<Term>, Box<Term>)
Product(Vec<Member>)
Choice(Vec<Term>)
Named
Reference(Vec<String>)
Implementations§
Source§impl Term
impl Term
Sourcepub fn fold<A>(&self, alg: &A) -> A::Ty
pub fn fold<A>(&self, alg: &A) -> A::Ty
Folds this term into whichever algebra an interpretation provides.
This is the reader: a term written by one host is interpreted by another without either naming the other’s types. Reading and writing are checked against each other, since folding a written term with any interpretation answers what interpreting the original directly does.
Sourcepub fn resolved(&self) -> Self
pub fn resolved(&self) -> Self
Answers with this term, with every reference replaced by the shape its name introduces.
A fold cannot do this: it builds from the leaves upward, so a reference reaches it before the name it uses has been seen. A term holds the whole shape at once, which is what makes a name resolvable — and is why an interpretation that must decide a value, rather than describe one, reads a resolved term.
A name that would resolve into itself is left as a reference, since expanding it never ends.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Term
impl<'de> Deserialize<'de> for Term
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Term
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnsafeUnpin for Term
impl UnwindSafe for Term
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<This> ShapeProgramExt<This> for This
impl<This> ShapeProgramExt<This> for This
Source§fn compile_shape<Program>(
&self,
program: Program,
) -> <Program as ShapeProgramAlg<This>>::Tywhere
Program: ShapeProgramAlg<This>,
fn compile_shape<Program>(
&self,
program: Program,
) -> <Program as ShapeProgramAlg<This>>::Tywhere
Program: ShapeProgramAlg<This>,
Folds a declaration with this interpretation.