#[non_exhaustive]pub enum ScalarType {
Show 21 variants
Unit,
Bool,
Char,
Str,
String,
CowStr,
F32,
F64,
U8,
U16,
U32,
U64,
U128,
USize,
I8,
I16,
I32,
I64,
I128,
ISize,
ConstTypeId,
}Expand description
All scalar types supported out of the box by facet.
This enum allows identifying whether a Shape represents a known scalar type
(primitives, strings, network addresses, etc.), which is useful for serializers,
deserializers, and introspection code.
§Example
use facet_core::{Facet, ScalarType};
assert_eq!(u32::SHAPE.scalar_type(), Some(ScalarType::U32));
assert_eq!(bool::SHAPE.scalar_type(), Some(ScalarType::Bool));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unit
Unit tuple ().
Bool
Primitive type bool.
Char
Primitive type char.
Str
Primitive type str (or &str).
String
alloc::string::String.
CowStr
alloc::borrow::Cow<'_, str>.
F32
Primitive type f32.
F64
Primitive type f64.
U8
Primitive type u8.
U16
Primitive type u16.
U32
Primitive type u32.
U64
Primitive type u64.
U128
Primitive type u128.
USize
Primitive type usize.
I8
Primitive type i8.
I16
Primitive type i16.
I32
Primitive type i32.
I64
Primitive type i64.
I128
Primitive type i128.
ISize
Primitive type isize.
ConstTypeId
facet_core::ConstTypeId.
Implementations§
Source§impl ScalarType
impl ScalarType
Sourcepub fn try_from_shape(shape: &Shape) -> Option<Self>
pub fn try_from_shape(shape: &Shape) -> Option<Self>
Infer the scalar type from a shape definition.
Returns Some(ScalarType) if the shape represents a known scalar type,
or None for non-scalar types like structs, enums, lists, or maps.
Trait Implementations§
Source§impl Clone for ScalarType
impl Clone for ScalarType
Source§fn clone(&self) -> ScalarType
fn clone(&self) -> ScalarType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more