pub struct Schema {
pub name: String,
pub generics: Vec<String>,
pub fields: Vec<Field>,
pub is_tuple: bool,
}Expand description
Canonical schema description. Field order is preserved exactly as declared; see the module docs for the rationale.
Fields§
§name: StringSchema name. Anonymous schemas declared inline carry an empty string so the canonical form remains deterministic even when hosts forget to pass a name through.
generics: Vec<String>Generic type parameters (e.g. ["T"] for Page<T>). Empty
for monomorphic schemas.
fields: Vec<Field>Fields in declaration order. Reordering invalidates the hash even when each field’s name + type are otherwise identical, because the binary layout’s field offsets are declaration-order dependent.
is_tuple: boolWave T2: marks an anonymous positional record synthesised for
a Tuple<...>. The binary layout, buffer builder, verifier and
codegen treat such a schema exactly like any other record (its
fields carry the synthetic positional names "0", "1", …),
so the whole record/return ABI is reused unchanged. The only
behavioural fork is the host decode: a tuple schema decodes
to a positional Value::Tuple, which JSON projection later emits
as an array, rather than to a branded object.
Serialised only when true, so every pre-T2 (non-tuple) schema’s
canonical bytes — and therefore its ABI hash — stay unchanged.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Build an empty schema with the given name. Convenience ctor
used by tests and by future codegen-side conversions.
Sourcepub fn tuple(name: impl Into<String>, elements: Vec<TypeRepr>) -> Self
pub fn tuple(name: impl Into<String>, elements: Vec<TypeRepr>) -> Self
Wave T2: build an anonymous positional-record schema for a
Tuple<...> from its element types in order. Field names are the
synthetic decimal indices "0", "1", … so the existing
declaration-order layout pass assigns one slot per element; the
is_tuple flag drives positional Value::Tuple host decode.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
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 Schema
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more