pub enum Ty {
Text,
Bytes,
Image,
Document,
Json,
List(Box<Ty>),
Record(BTreeMap<String, Ty>),
}Expand description
The shape of a value flowing through a pipeline.
Deliberately small. This exists to catch the mistake that actually happens
when blocks are composed — one block emitting a summary string into another
expecting a list of chunks — not to be a general-purpose type system. A
richer one would need inference, and inference over a language with no
expressions is machinery without a use.
Written and read as a compact string — text, [text], {path: text} —
rather than as a nested tagged object.
Two reasons, and the second is the one that forced it. It reads well in an
error message and in a spec, so one syntax serves the wire, the diagnostics,
and the DSL. And a recursive enum serialized structurally makes serde’s
generic serializer recurse deeply enough to blow rustc’s recursion limit in
the guest crate — which would have meant every block author adding
#![recursion_limit] to work around a detail of this type.
Variants§
Text
A UTF-8 string.
Bytes
Opaque bytes, base64-encoded on the wire.
Image
A handle naming an image the host holds.
Document
A handle naming a paged document.
Json
Any JSON value. The top type: everything is assignable to it.
An escape hatch, and one worth using sparingly — a pipeline of Json
seams typechecks unconditionally, which is the same as not checking.
List(Box<Ty>)
An ordered sequence.
Record(BTreeMap<String, Ty>)
A fixed set of named fields.
A BTreeMap so that two records written in different field orders are
the same type, and so error messages list fields the same way twice.
Implementations§
Source§impl Ty
impl Ty
Sourcepub fn assignable_to(&self, expected: &Ty) -> bool
pub fn assignable_to(&self, expected: &Ty) -> bool
Whether a value of this type can be fed where expected is required.
Not equality: Ty::Json accepts anything, and a record with extra
fields satisfies one that needs fewer. Both directions of that matter —
a block that adds a field should not break its consumer, and a block
that requires a field its producer never emits should fail loudly.