#[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<ScalarType>
pub fn try_from_shape(shape: &Shape) -> Option<ScalarType>
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 moreSource§impl Debug for ScalarType
impl Debug for ScalarType
Source§impl Hash for ScalarType
impl Hash for ScalarType
Source§impl Ord for ScalarType
impl Ord for ScalarType
Source§fn cmp(&self, other: &ScalarType) -> Ordering
fn cmp(&self, other: &ScalarType) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ScalarType
impl PartialEq for ScalarType
Source§impl PartialOrd for ScalarType
impl PartialOrd for ScalarType
impl Copy for ScalarType
impl Eq for ScalarType
impl StructuralPartialEq for ScalarType
Auto Trait Implementations§
impl Freeze for ScalarType
impl RefUnwindSafe for ScalarType
impl Send for ScalarType
impl Sync for ScalarType
impl Unpin for ScalarType
impl UnsafeUnpin for ScalarType
impl UnwindSafe for ScalarType
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.