#[non_exhaustive]pub enum ShapeRef {
Show 27 variants
Unit,
Bool,
Char,
I8,
I16,
I32,
I64,
I128,
Isize,
U8,
U16,
U32,
U64,
U128,
Usize,
F32,
F64,
String,
Bytes,
Option(Box<ShapeRef>),
Seq(Box<ShapeRef>),
Array {
item: Box<ShapeRef>,
len: usize,
},
Map {
key: Box<ShapeRef>,
value: Box<ShapeRef>,
},
Tuple(Vec<ShapeRef>),
Union(UnionShape),
Definition(ShapeId),
Opaque(OpaqueShape),
}Expand description
A reference to a shape node.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unit
Unit shape.
Bool
Boolean shape.
Char
Character shape.
I8
i8 shape.
I16
i16 shape.
I32
i32 shape.
I64
i64 shape.
I128
i128 shape.
Isize
isize shape.
U8
u8 shape.
U16
u16 shape.
U32
u32 shape.
U64
u64 shape.
U128
u128 shape.
Usize
usize shape.
F32
f32 shape.
F64
f64 shape.
String
UTF-8 string shape.
Bytes
Serde byte-buffer data-model shape.
Option(Box<ShapeRef>)
Optional value shape.
Seq(Box<ShapeRef>)
Sequence shape.
Array
Fixed-size array shape.
Built-in array implementations follow Serde’s supported lengths of 0 through 32. Manual implementations may construct other lengths for custom representations.
Map
Map shape.
Tuple(Vec<ShapeRef>)
Tuple shape.
Union(UnionShape)
A normalized union of two or more possible value shapes.
Construct unions with ShapeRef::union or ShapeRef::try_union.
Definition(ShapeId)
Named type definition reference.
Opaque(OpaqueShape)
Shape intentionally left opaque.
Implementations§
Source§impl ShapeRef
impl ShapeRef
Sourcepub fn union<I>(alternatives: I) -> Selfwhere
I: IntoIterator<Item = Self>,
pub fn union<I>(alternatives: I) -> Selfwhere
I: IntoIterator<Item = Self>,
Builds a normalized union from one or more possible value shapes.
Nested unions are flattened, duplicate alternatives are removed, and alternatives are sorted into a canonical order. A single distinct alternative is returned directly.
§Panics
Panics when alternatives is empty. Use ShapeRef::try_union when the input may be
empty.
Sourcepub fn try_union<I>(alternatives: I) -> Option<Self>where
I: IntoIterator<Item = Self>,
pub fn try_union<I>(alternatives: I) -> Option<Self>where
I: IntoIterator<Item = Self>,
Tries to build a normalized union from possible value shapes.
Returns None when alternatives is empty. Nested unions are flattened, duplicate
alternatives are removed, and alternatives are sorted into a canonical order. A single
distinct alternative is returned directly.
Sourcepub fn is_signed_integer(&self) -> bool
pub fn is_signed_integer(&self) -> bool
Returns true if this shape contains only signed integers.
Sourcepub fn is_unsigned_integer(&self) -> bool
pub fn is_unsigned_integer(&self) -> bool
Returns true if this shape contains only unsigned integers.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if this shape contains only integers.