Skip to main content

Crate facet_reflect

Crate facet_reflect 

Source
Expand description

§facet-reflect

Coverage Status crates.io documentation MIT/Apache-2.0 licensed Discord

Whereas the core facet crate provides essential traits like Facet itself, and data structures like Type, StructType, Field, etc., facet-reflect uses that information about the shape of types to allow:

  • Read-only access to already-initialized values (via Peek)
  • Construction of values from scratch (via Partial)

This allows, respectively, serialization and deserialization, without risking breaking invariants in types that implement Facet.

§Sponsors

Thanks to all individual sponsors:

GitHub Sponsors Patreon

…along with corporate sponsors:

AWS Zed Depot

…without whom this work could not exist.

§Special thanks

The facet logo was drawn by Misiasart.

§License

Licensed under either of:

at your option.

Modules§

deferred_materialization
Deferred Materialization

Macros§

debug
Forwards to tracing::debug when the tracing feature is enabled
trace
Forwards to tracing::trace when the tracing feature is enabled

Structs§

AllocError
Error returned when allocating memory for a shape fails.
CovariantPeek
A covariant wrapper around Peek for types that can safely shrink lifetimes.
DuplicateFieldError
Error when building a resolution.
FieldInfo
Information about a single field in a resolution.
FieldItem
A field item with runtime state for serialization.
FieldIter
An iterator over all the fields of a struct or enum. See HasFields::fields
FieldPath
A path through the type tree to a field.
FieldsForSerializeIter
An iterator over the fields of a struct or enum that should be serialized. See HasFields::fields_for_serialize
Guard
A guard structure to manage memory allocation and deallocation.
HeapValue
A type-erased value stored on the heap
OwnedPeek
An Owned version of a Peek used for custom serialization
Partial
A type-erased, heap-allocated, partially-initialized value.
Peek
A read-only view into a value with runtime type information.
PeekDynamicValue
Lets you read from a dynamic value (implements read-only operations for DynamicValue types)
PeekDynamicValueArrayIter
Iterator over array elements in a dynamic value
PeekDynamicValueObjectIter
Iterator over object entries in a dynamic value
PeekEnum
Lets you read from an enum (implements read-only enum operations)
PeekList
Lets you read from a list (implements read-only facet_core::ListVTable proxies)
PeekListIter
Iterator over a PeekList
PeekListLike
Lets you read from a list, array or slice
PeekListLikeIter
Iterator over a PeekListLike
PeekMap
Lets you read from a map (implements read-only facet_core::MapVTable proxies)
PeekMapIter
Iterator over key-value pairs in a PeekMap
PeekNdArray
Lets you read from an n-dimensional array (implements read-only facet_core::NdArrayVTable proxies)
PeekOption
Lets you read from an option (implements read-only option operations)
PeekPointer
Represents a pointer that can be peeked at during memory inspection.
PeekResult
Lets you read from a result (implements read-only result operations)
PeekSet
Lets you read from a set
PeekSetIter
Iterator over values in a PeekSet
PeekStruct
Lets you read from a struct (implements read-only struct operations)
PeekTuple
Lets you read from a tuple
Poke
A mutable view into a value with runtime type information.
PokeEnum
Lets you mutate an enum’s fields.
PokeList
Lets you mutate a list (implements mutable facet_core::ListVTable proxies)
PokeListIter
Iterator over a PokeList
PokeStruct
Lets you mutate a struct’s fields.
ReflectError
Error that occurred during reflection, with path context.
Resolution
One possible “shape” the flattened type could take.
ShapeMismatchError
Error returned when materializing a HeapValue to the wrong type.
Span
Source span with offset and length.
TupleType
Local representation of a tuple type for peek operations
TypePlan
Precomputed deserialization plan tree for a type.
TypePlanCore
Type-erased plan data that owns all allocations.
ValueId
A unique identifier for a peek value
VariantSelection
Records that a specific enum field has a specific variant selected.

Enums§

DeserStrategy
Precomputed deserialization strategy with all data needed to execute it.
FieldCategory
Category of a field for format-aware field lookup.
FieldKey
A key for field lookup in schemas and solvers.
ListLikeDef
Fields for types which act like lists
MatchResult
Result of matching input fields against a resolution.
PathSegment
A segment in a field path.
ReflectErrorKind
Specific kinds of reflection errors.
ScalarType
All scalar types supported out of the box by facet.
StrideError
Error that can occur when trying to access an n-dimensional array as strided
TrackerKind
A kind-only version of Tracker
VariantError
Error that can occur when trying to determine variant information

Traits§

HasFields
Trait for types that have field methods

Functions§

get_metadata_container_value_shape
Extract the inner value shape from a metadata container.
peek_enum
Returns the enum definition if the shape represents an enum, None otherwise
peek_enum_repr
Returns the enum representation if the shape represents an enum, None otherwise
peek_enum_variants
Returns the enum variants if the shape represents an enum, None otherwise

Type Aliases§

DomKeyPath
A path of serialized keys for probing (DOM-aware). Each key includes the category (attribute vs element) for DOM formats.
KeyPath
A path of serialized key names for probing (flat formats). Unlike FieldPath which tracks the internal type structure (including variant selections), KeyPath only tracks the keys as they appear in the serialized format.
NodeId
Type alias for node indices in the TypePlan.
TupleField
Field index and associated peek value