Crate facet_core

Source
Expand description

Facet logo - a reflection library for Rust   facet-core

Coverage Status free of syn crates.io documentation MIT/Apache-2.0 licensed

Logo by Misiasart

Thanks to all individual and corporate sponsors, without whom this work could not exist:

Ko-fi GitHub Sponsors Patreon Zed built with depot

Defines the core types and traits used throughout the facet ecosystem for runtime reflection:

  • Facet: exposes a SHAPE associated const
  • Shape: The central type that describes the memory layout and capabilities of a type
  • Various vtables that define how to manipulate types at runtime
  • The Def tree, which describes type definitions (structs, enums, etc.)

This crate is foundational to facet’s reflection capabilities, providing the type system that enables runtime type manipulation.

§License

Licensed under either of:

at your option.

Modules§

spez
Auto-deref specialization helpers for the Facet reflection system

Macros§

value_vtable
Creates a ValueVTable for a given type.
value_vtable_inner
Creates a ValueVTable for a given type, see value_vtable! for more details.

Structs§

ArrayDef
Fields for array types
ArrayDefBuilder
Builder for ArrayDef
ArrayVTable
Virtual table for a list-like type (like Vec<T>, but also HashSet<T>, etc.)
ArrayVTableBuilder
Builds a ArrayVTable
BoolAffinity
Definition for boolean scalar affinities
BoolAffinityBuilder
Builder for BoolAffinity
CharAffinity
Definition for character scalar affinities
CharAffinityBuilder
Builder for CharAffinity
ComplexNumberAffinity
Definition for string-like scalar affinities
ComplexNumberAffinityBuilder
Builder for ComplexNumberAffinity
ConstTypeId
TypeId equivalent usable in const contexts.
EmptyAffinity
Definition for empty scalar affinities
EmptyAffinityBuilder
Builder for EmptyAffinity
EnumDef
Fields for enum types
EnumDefBuilder
Builder for EnumDef
Field
Describes a field in a struct or tuple
FieldBuilder
Builder for Field
FieldFlags
Flags that can be applied to fields to modify their behavior
HasherProxy
Provides an implementation of core::hash::Hasher for a given hasher pointer and write function
IpAddrAffinity
Definition for IP address scalar affinities
IpAddrAffinityBuilder
Builder for IpAddrAffinity
ListDef
Fields for list types
ListDefBuilder
Builder for ListDef
ListVTable
Virtual table for a list-like type (like Vec<T>, but also HashSet<T>, etc.)
ListVTableBuilder
Builds a ListVTable
LockGuardVTable
Functions for manipulating a guard
LockResult
Type-erased result of locking a mutex-like smart pointer
MapDef
Fields for map types
MapDefBuilder
Builder for MapDef
MapIterVTable
VTable for an iterator over a map
MapIterVTableBuilder
Builds a MapIterVTable
MapVTable
Virtual table for a Map<K, V>
MapVTableBuilder
Builds a MapVTable
MarkerTraits
Bitflags for common marker traits that a type may implement
NumberAffinity
Definition for number-like scalar affinities
NumberAffinityBuilder
Builder for NumberAffinity
Opaque
Helper type for opaque members
OpaqueAffinity
Definition for opaque scalar affinities
OpaqueAffinityBuilder
Builder for OpaqueAffinity
OptionDef
Describes an Option — including a vtable to query and alter its state, and the inner shape (the T in Option<T>).
OptionDefBuilder
Builder for OptionDef
OptionVTable
Virtual table for Option<T>
OptionVTableBuilder
Builds an OptionVTable
OtherAffinity
Definition for other scalar affinities
OtherAffinityBuilder
Builder for OtherAffinity
PathAffinity
Definition for path scalar affinities
PathAffinityBuilder
Builder for PathAffinity
PtrConst
A type-erased read-only pointer to an initialized value.
PtrMut
A type-erased pointer to an initialized value
PtrUninit
A type-erased pointer to an uninitialized value
ScalarDef
Definition for scalar types
ScalarDefBuilder
Builder for ScalarDef
Shape
Schema for reflection of a type
ShapeBuilder
Builder for Shape
SliceDef
Fields for slice types
SliceDefBuilder
Builder for SliceDef
SliceVTable
Virtual table for a slice-like type (like Vec<T>, but also HashSet<T>, etc.)
SliceVTableBuilder
Builds a SliceVTable
SmartPointerDef
Describes a smart pointer — including a vtable to query and alter its state, and the inner shape (the pointee type in the smart pointer).
SmartPointerDefBuilder
Builder for creating a SmartPointerDef.
SmartPointerFlags
Flags to represent various characteristics of smart pointers
SmartPointerVTable
Functions for interacting with a smart pointer
SmartPointerVTableBuilder
Builder for creating a SmartPointerVTable.
SocketAddrAffinity
Definition for socket address scalar affinities
SocketAddrAffinityBuilder
Builder for SocketAddrAffinity
StringAffinity
Definition for string-like scalar affinities
StringAffinityBuilder
Builder for StringAffinity
Struct
Common fields for struct-like types
StructBuilder
Builder for StructDef
TimeAffinity
Definition for Datetime/Timestamp scalar affinities
TimeAffinityBuilder
Builder for UuidAffinity
TypeNameOpts
Options for formatting the name of a type
TypeParam
Represents a lifetime parameter, e.g., 'a or 'a: 'b + 'c.
UuidAffinity
Definition for UUID and UUID-like scalar affinities
UuidAffinityBuilder
Builder for UuidAffinity
ValueVTable
VTable for common operations that can be performed on any shape
ValueVTableBuilder
Builds a ValueVTable
Variant
Describes a variant of an enum
VariantBuilder
Builder for Variant

Enums§

Characteristic
A characteristic a shape can have
Def
The definition of a shape: is it more like a struct, a map, a list?
EnumRepr
All possible representations for Rust enums — ie. the type/size of the discriminant
FieldAttribute
An attribute that can be set on a field
FieldError
Errors encountered when calling field_by_index or field_by_name
KnownSmartPointer
Represents common standard library smart pointer kinds
NumberBits
Bit representation of numbers
ParseError
Error returned by ParseFn
ScalarAffinity
Scalar affinity: what a scalar spiritually is: a number, a string, a bool, something else entirely?
Signedness
Represents whether a numeric type is signed or unsigned
StructKind
Describes the kind of struct (useful for deserializing)
TryFromError
Error type for TryFrom conversion failures

Traits§

Facet
Allows querying the Shape of a type, which in turn lets us inspect any fields, build a value of this type progressively, etc.

Functions§

of
Create a TypeId for a type.

Type Aliases§

ArrayGetItemPtrFn
Get pointer to the item at the given index. Panics if out of bounds.
BorrowFn
Tries to obtain a reference to the inner value of the smart pointer.
CloneIntoFn
Function to clone a value into another already-allocated value
CmpFn
Function to compare two values and return their ordering
DebugFn
Function to format a value for debug. If this returns None, the shape did not implement Debug.
DefaultInPlaceFn
Function to set a value to its default in-place
DisplayFn
Function to format a value for display
DowngradeIntoFn
Downgrades a strong pointer to a weak one.
DropInPlaceFn
Function to drop a value
HashFn
Function to hash a value
HasherWriteFn
Function to write bytes to a hasher
InvariantsFn
Function to validate the invariants of a value. If it returns false, the value is considered invalid.
ListGetItemPtrFn
Get pointer to the item at the given index. Panics if out of bounds.
ListInitInPlaceWithCapacityFn
Initialize a list in place with a given capacity
ListLenFn
Get the number of items in the list
ListPushFn
Push an item to the list
LockFn
Acquires a lock on a mutex-like smart pointer
MapContainsKeyFn
Check if the map contains a key
MapGetValuePtrFn
Get pointer to a value for a given key, returns None if not found
MapInitInPlaceWithCapacityFn
Initialize a map in place with a given capacity
MapInsertFn
Insert a key-value pair into the map
MapIterDeallocFn
Deallocate the iterator
MapIterFn
Get an iterator over the map
MapIterNextFn
Get the next key-value pair from the iterator
MapLenFn
Get the number of entries in the map
NewIntoFn
Creates a new smart pointer wrapping the given value. Writes the smart pointer into the given this.
OptionGetValueFn
Get the value contained in an option, if present
OptionInitNoneFn
Initialize an option with None
OptionInitSomeFn
Initialize an option with Some(value)
OptionIsSomeFn
Check if an option contains a value
OptionReplaceWithFn
Replace an existing option with a new value
ParseFn
Function to parse a value from a string.
PartialEqFn
Function to check if two values are partially equal
PartialOrdFn
Function to compare two values and return their ordering if comparable
ReadFn
Acquires a read lock on a reader-writer lock-like smart pointer
SliceGetItemPtrFn
Get pointer to the item at the given index. Panics if out of bounds.
SliceLenFn
Get the number of items in the slice
TryFromFn
Function to try converting from another type
TypeNameFn
A function that formats the name of a type.
UpgradeIntoFn
Tries to upgrade the weak pointer to a strong one.
WriteFn
Acquires a write lock on a reader-writer lock-like smart pointer