Skip to content

stdlib.reflect

Runtime Reflection

Generated from v0.60.1. 3 source files, 48 documented symbols.

fields.xi

fn field_count[T]() -> Int

The number of fields in struct T. LIMITED: always 0. Complexity: O(1).

fn field_name[T](i: Int) -> Option[Str]

The name of field i of T. LIMITED: always None. Complexity: O(1).

fn field_type[T](i: Int) -> Option[Str]

The type name of field i of T. LIMITED: always None. Complexity: O(1).

fn field_offset[T](i: Int) -> Option[Int]

The byte offset of field i of T. LIMITED: always None. Complexity: O(1).

fn field_value[T](obj: &T, i: Int) -> Option[Int]

Read field i of obj as an integer. LIMITED: always None. Complexity: O(1).

fn field_names[T]() -> Vec[Str]

All field names in declaration order. LIMITED: always empty. Complexity: O(1).

fn field_types[T]() -> Vec[Str]

All field type names in declaration order. LIMITED: always empty. Complexity: O(1).

fn field_offsets[T]() -> Vec[Int]

All field byte offsets in declaration order. LIMITED: always empty. Complexity: O(1).

fn variant_name[T](v: T) -> Str

The name of enum variant v. LIMITED: the compiler does not expose variant metadata -- returns "unknown". Complexity: O(1).

fn variant_index[T](v: T) -> Int

The index of enum variant v. LIMITED: returns 0. Complexity: O(1).




reflect.xi

fn type_count() -> Int

Number of user types registered in this compilation unit. REAL.

  • Precondition: true
  • Postcondition: result >= 0

fn type_name_by_id(id: Int) -> Str

Name of the type with the given stable id, or "unknown" if out of range. REAL.

  • Precondition: true
  • Postcondition: result.len() >= 0

fn type_id_by_name(name: Str) -> Int

Stable id of the type with the given name, or -1 if not found. REAL.

  • Precondition: true
  • Postcondition: result >= -1

fn type_field_count(id: Int) -> Int

Number of fields of the type with the given id (0 for enums/unknown). REAL.

  • Precondition: true
  • Postcondition: result >= 0

type TypeId

Stable numeric identity of a type.

Field Type
id Int

Derives: Eq, Clone, Hash

fn of[T]() -> TypeId

TypeId of T.

fn type_name[T]() -> Str

Source name of T.

  • Postcondition: result.len() > 0

fn type_size[T]() -> Int

Size of T in bytes.

fn type_align[T]() -> Int

Alignment of T in bytes.

fn downcast_ref[T](value: &Any) -> Option[&T]

Downcasting

fn downcast_mut[T](value: &mut Any) -> Option[&mut T]

Downcast a dyn Any to &mut T, or None on mismatch.

type TypeInfo

Reflected type description (name, size, alignment, fields).

Field Type
name Str
size Int
align Int
kind Int
fields Vec[FieldInfo]
variants Vec[Str]
derives Vec[Str]

Derives: Clone

type FieldInfo

Reflected field description (name, offset, type name).

Field Type
name Str
type_name Str
offset Int

Derives: Clone

fn reflect_type[T]() -> TypeInfo

TypeInfo for T.

fn type_info_by_name(name: Str) -> Option[TypeInfo]

Look up a type by name and return REAL data from the compiler RTTI table: the canonical name and the true field count (materialised as that many placeholder FieldInfo entries so result.fields.len() is exact). LIMITED: size/align are reported as 0, kind defaults to 1 (struct), and per-field names/types are "unknown" -- that metadata is not embedded yet.

fn all_types() -> Vec[TypeInfo]

Enumerate every registered user type with REAL names and field counts. LIMITED: size/align/kind and per-field metadata are placeholders (see above).

fn type_is_primitive[T]() -> Bool

Returns true if T is a primitive type (Int, Float64, Bool, Char, etc.). LIMITED: compiler does not expose this metadata yet -- always returns false. Complexity: O(1).

fn type_is_struct[T]() -> Bool

Returns true if T is a struct type. LIMITED: compiler does not expose this metadata yet -- always returns false. Complexity: O(1).

fn type_is_enum[T]() -> Bool

Returns true if T is an enum type. LIMITED: compiler does not expose this metadata yet -- always returns false. Complexity: O(1).

fn type_is_generic[T]() -> Bool

Returns true if T has generic parameters. LIMITED: compiler does not expose this metadata yet -- always returns false. Complexity: O(1).

fn type_is_sized[T]() -> Bool

Always returns true: all XIOM types are sized (statically known layout). Complexity: O(1).

fn type_kind[T]() -> Str

Returns a human-readable kind string: "primitive", "struct", "enum", or "unknown". LIMITED: compiler does not expose kind metadata yet -- always returns "unknown". Complexity: O(1).

fn type_name_of_value[T](value: &T) -> Str

Returns the type name of the value referenced by value. Delegates to type_name[T](). Complexity: O(1).

fn type_id_of_value[T](value: &T) -> Int

Returns the stable type id of the value referenced by value. Delegates to TypeId.of[T](). Complexity: O(1).

fn type_field_name[T](idx: Int) -> Str

Returns the name of field at index idx in type T, or "unknown". LIMITED: per-field metadata not embedded yet -- always returns "unknown". Complexity: O(1).

fn type_field_offset[T](idx: Int) -> Int

Returns the byte offset of field at index idx in type T, or 0. LIMITED: field offset intrinsic not available yet -- always returns 0. Complexity: O(1).

fn type_total_size[T]() -> Int

Returns the total size of type T in bytes. Alias for type_size[T](). Complexity: O(1).



typeinfo.xi

fn type_name[T]() -> Str

The name of type T. LIMITED: the compiler does not expose generic type names yet -- returns "unknown". Complexity: O(1).

fn type_id[T]() -> Int

A stable numeric id for type T. LIMITED: returns 0. Complexity: O(1).

fn type_size[T]() -> Int

The size of type T in bytes. LIMITED: the layout intrinsics are not emitted yet -- returns 0. Complexity: O(1).

fn type_align[T]() -> Int

The alignment of type T in bytes. LIMITED: returns 0. Complexity: O(1).

fn type_is_primitive[T]() -> Bool

Whether T is a primitive type. LIMITED: always false. Complexity: O(1).

fn type_is_struct[T]() -> Bool

Whether T is a struct type. LIMITED: always false. Complexity: O(1).

fn type_is_enum[T]() -> Bool

Whether T is an enum type. LIMITED: always false. Complexity: O(1).

fn type_is_generic[T]() -> Bool

Whether T is a generic type. LIMITED: always false. Complexity: O(1).

fn type_of[T](value: T) -> Str

The type name of a value. Delegates to type_name[T](). Complexity: O(1).

fn type_variant_count[T]() -> Int

The number of enum variants of T, or 0 when T is not an enum. LIMITED: always 0. Complexity: O(1).

fn type_is_sized[T]() -> Bool

Whether T has a known size. All XIOM types are statically sized, so this is always true. Complexity: O(1).