Skip to main content

SchemaType

Enum SchemaType 

Source
pub enum SchemaType {
Show 38 variants Ref { id: TypeId, metadata: MetadataEnvelope, }, Bool { metadata: MetadataEnvelope, }, S8 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, S16 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, S32 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, S64 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, U8 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, U16 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, U32 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, U64 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, F32 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, F64 { restrictions: Option<NumericRestrictions>, metadata: MetadataEnvelope, }, Char { metadata: MetadataEnvelope, }, String { metadata: MetadataEnvelope, }, Record { fields: Vec<NamedFieldType>, metadata: MetadataEnvelope, }, Variant { cases: Vec<VariantCaseType>, metadata: MetadataEnvelope, }, Enum { cases: Vec<String>, metadata: MetadataEnvelope, }, Flags { flags: Vec<String>, metadata: MetadataEnvelope, }, Tuple { elements: Vec<SchemaType>, metadata: MetadataEnvelope, }, List { element: Box<SchemaType>, metadata: MetadataEnvelope, }, FixedList { element: Box<SchemaType>, length: u32, metadata: MetadataEnvelope, }, Map { key: Box<SchemaType>, value: Box<SchemaType>, metadata: MetadataEnvelope, }, Option { inner: Box<SchemaType>, metadata: MetadataEnvelope, }, Result { spec: ResultSpec, metadata: MetadataEnvelope, }, Text { restrictions: TextRestrictions, metadata: MetadataEnvelope, }, Binary { restrictions: BinaryRestrictions, metadata: MetadataEnvelope, }, Path { spec: PathSpec, metadata: MetadataEnvelope, }, Url { restrictions: UrlRestrictions, metadata: MetadataEnvelope, }, Uuid { metadata: MetadataEnvelope, }, Datetime { metadata: MetadataEnvelope, }, Duration { metadata: MetadataEnvelope, }, Quantity { spec: QuantitySpec, metadata: MetadataEnvelope, }, Union { spec: UnionSpec, metadata: MetadataEnvelope, }, Secret { spec: SecretSpec, metadata: MetadataEnvelope, }, QuotaToken { spec: QuotaTokenSpec, metadata: MetadataEnvelope, }, PermissionCard { spec: PermissionCardSpec, metadata: MetadataEnvelope, }, Future { inner: Option<Box<SchemaType>>, metadata: MetadataEnvelope, }, Stream { inner: Option<Box<SchemaType>>, metadata: MetadataEnvelope, },
}
Expand description

One schema type in the recursive in-memory representation.

Every variant carries a MetadataEnvelope so docs / aliases / examples / deprecation / role can attach to any node, not only to registered defs or named positions. Use SchemaType::metadata / SchemaType::metadata_mut for ergonomic access regardless of variant.

Recursive positions hold owned, boxed children (rather than indices) so consumers can walk and pattern-match the schema directly without chasing indices into a flat node list. The WIT-shaped flat form is reconstructed on demand by super::wit.

Closed sum types come in two shapes that differ by how the decoder learns which branch a value belongs to:

Variants§

§

Ref

Reference to a named definition in the enclosing super::SchemaGraph.

Fields

§

Bool

Fields

§

S8

Fields

§

S16

Fields

§

S32

Fields

§

S64

Fields

§

U8

Fields

§

U16

Fields

§

U32

Fields

§

U64

Fields

§

F32

Fields

§

F64

Fields

§

Char

Fields

§

String

Fields

§

Record

Fields

§

Variant

§

Enum

Fields

§cases: Vec<String>
§

Flags

Fields

§flags: Vec<String>
§

Tuple

Fields

§elements: Vec<SchemaType>
§

List

Fields

§element: Box<SchemaType>
§

FixedList

Fields

§element: Box<SchemaType>
§length: u32
§

Map

Fields

§

Option

Fields

§

Result

Fields

§

Text

Fields

§restrictions: TextRestrictions
§

Binary

Fields

§restrictions: BinaryRestrictions
§

Path

Fields

§

Url

Fields

§restrictions: UrlRestrictions
§

Uuid

Fields

§

Datetime

Fields

§

Duration

Fields

§

Quantity

Fields

§

Union

Fields

§

Secret

Fields

§

QuotaToken

§

PermissionCard

§

Future

Fields

§

Stream

Fields

Implementations§

Source§

impl SchemaType

Source

pub fn metadata(&self) -> &MetadataEnvelope

Per-node metadata envelope (docs / aliases / examples / deprecation / role). Always returns a reference; empty envelopes are the default.

Source

pub fn metadata_mut(&mut self) -> &mut MetadataEnvelope

Mutable access to the per-node metadata envelope.

Source

pub fn with_metadata(self, metadata: MetadataEnvelope) -> SchemaType

Replace this node’s metadata envelope, returning self for chaining.

Source

pub fn numeric_repr(&self) -> Option<NumericRepr>

The numeric representation of this node, if it is a numeric type.

Source

pub fn numeric_restrictions(&self) -> Option<&NumericRestrictions>

The numeric restrictions of this node, if it is a numeric type with restrictions set.

Source

pub fn ref_to(id: TypeId) -> SchemaType

Source

pub fn bool() -> SchemaType

Source

pub fn s8() -> SchemaType

Source

pub fn s16() -> SchemaType

Source

pub fn s32() -> SchemaType

Source

pub fn s64() -> SchemaType

Source

pub fn u8() -> SchemaType

Source

pub fn u16() -> SchemaType

Source

pub fn u32() -> SchemaType

Source

pub fn u64() -> SchemaType

Source

pub fn f32() -> SchemaType

Source

pub fn f64() -> SchemaType

Source

pub fn char() -> SchemaType

Source

pub fn string() -> SchemaType

Source

pub fn uuid() -> SchemaType

Source

pub fn datetime() -> SchemaType

Source

pub fn duration() -> SchemaType

Source

pub fn record(fields: Vec<NamedFieldType>) -> SchemaType

Source

pub fn record_from_fields<N>( fields: impl IntoIterator<Item = (N, SchemaType)>, ) -> SchemaType
where N: Into<String>,

Convenience: build a record whose fields have no metadata.

Source

pub fn variant(cases: Vec<VariantCaseType>) -> SchemaType

Source

pub fn enum(cases: Vec<String>) -> SchemaType

Source

pub fn flags(flags: Vec<String>) -> SchemaType

Source

pub fn tuple(elements: Vec<SchemaType>) -> SchemaType

Source

pub fn list(element: SchemaType) -> SchemaType

Source

pub fn fixed_list(element: SchemaType, length: u32) -> SchemaType

Source

pub fn map(key: SchemaType, value: SchemaType) -> SchemaType

Source

pub fn option(inner: SchemaType) -> SchemaType

Source

pub fn result(spec: ResultSpec) -> SchemaType

Source

pub fn text(restrictions: TextRestrictions) -> SchemaType

Source

pub fn binary(restrictions: BinaryRestrictions) -> SchemaType

Source

pub fn path(spec: PathSpec) -> SchemaType

Source

pub fn url(restrictions: UrlRestrictions) -> SchemaType

Source

pub fn quantity(spec: QuantitySpec) -> SchemaType

Source

pub fn union(spec: UnionSpec) -> SchemaType

Source

pub fn secret(spec: SecretSpec) -> SchemaType

Source

pub fn quota_token(spec: QuotaTokenSpec) -> SchemaType

Source

pub fn permission_card(spec: PermissionCardSpec) -> SchemaType

Source

pub fn future(inner: Option<SchemaType>) -> SchemaType

Source

pub fn stream(inner: Option<SchemaType>) -> SchemaType

Trait Implementations§

Source§

impl Clone for SchemaType

Source§

fn clone(&self) -> SchemaType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SchemaType

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SchemaType, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for SchemaType

Source§

impl FromSchema for SchemaType

Source§

impl IntoSchema for SchemaType

Source§

impl PartialEq for SchemaType

Source§

fn eq(&self, other: &SchemaType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SchemaType

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SchemaType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoTypedSchemaValue for T
where T: IntoSchema + ?Sized,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TupleOrUnit<()> for T

Source§

fn into(self)