TypeKind

Enum TypeKind 

Source
pub enum TypeKind {
Show 23 variants Bool, I8, I16, I32, I64, I128, U8, U16, U32, U64, U128, F32, F64, Char, String, Unit, Option(Box<TypeKind>), List(Box<TypeKind>), Map { key: Box<TypeKind>, value: Box<TypeKind>, }, Tuple(Vec<TypeKind>), Struct { fields: Vec<Field>, }, Enum { variants: Vec<Variant>, }, TypeRef(String),
}
Expand description

Represents all possible Rust types that can be serialized to RON.

§Trait-Based Design

This enum works alongside the trait system in crate::traits:

  • List represents any type implementing RonList (Vec, VecDeque, custom types)
  • Map represents any type implementing RonMap (HashMap, BTreeMap, custom types)

Custom types implementing these traits will serialize to the same TypeKind variants, allowing the validation and LSP systems to work uniformly.

Variants§

§

Bool

§

I8

§

I16

§

I32

§

I64

§

I128

§

U8

§

U16

§

U32

§

U64

§

U128

§

F32

§

F64

§

Char

§

String

§

Unit

§

Option(Box<TypeKind>)

§

List(Box<TypeKind>)

List/sequence type - represents any type implementing RonList.

This includes Vec<T>, VecDeque<T>, HashSet<T>, BTreeSet<T>, arrays, and any custom types implementing RonList.

§

Map

Map/dictionary type - represents any type implementing RonMap.

This includes HashMap<K, V>, BTreeMap<K, V>, and any custom types implementing RonMap.

Fields

§value: Box<TypeKind>
§

Tuple(Vec<TypeKind>)

§

Struct

Fields

§fields: Vec<Field>
§

Enum

Fields

§variants: Vec<Variant>
§

TypeRef(String)

Reference to another schema by fully-qualified type path.

Implementations§

Source§

impl TypeKind

Source

pub fn inner_type(&self) -> Option<&TypeKind>

Get inner type for Option or List.

Source

pub fn map_types(&self) -> Option<(&TypeKind, &TypeKind)>

Get key/value types for Map.

Source

pub fn tuple_types(&self) -> Option<&[TypeKind]>

Get tuple element types.

Source

pub fn struct_fields(&self) -> Option<&[Field]>

Get struct fields.

Source

pub fn enum_variants(&self) -> Option<&[Variant]>

Get enum variants.

Source

pub fn type_ref_path(&self) -> Option<&str>

Get TypeRef path.

Source

pub fn is_primitive(&self) -> bool

Check if this is a primitive type (no nested types).

Trait Implementations§

Source§

impl Clone for TypeKind

Source§

fn clone(&self) -> TypeKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeKind

Source§

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

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

impl Display for TypeKind

Source§

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

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

impl FromRon for TypeKind

Source§

fn from_ast(expr: &Expr<'_>) -> Result<Self>

Core method: deserialize from an AST expression. Read more
Source§

fn from_ron_value(value: Value) -> Result<Self>

Construct this type from a RON Value. Read more
Source§

fn from_ron(s: &str) -> Result<Self>

Parse a RON string and construct this type. Read more
Source§

fn from_ron_reader<R: Read>(reader: R) -> Result<Self>

Read RON from a reader and construct this type.
Source§

impl PartialEq for TypeKind

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToRon for TypeKind

Source§

fn to_ast(&self) -> Result<Expr<'static>>

Convert this value to a RON AST expression. Read more
Source§

fn to_ron(&self) -> Result<String>

Convert this value to a pretty-printed RON string (default format).
Source§

fn to_ron_with(&self, config: &FormatConfig) -> Result<String>

Convert this value to a RON string with custom formatting. Read more
Source§

fn to_ron_value(&self) -> Result<Value>

Convert this value to a RON Value (via AST).
Source§

impl StructuralPartialEq for TypeKind

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.