Skip to main content

TypePlanCore

Struct TypePlanCore 

Source
pub struct TypePlanCore { /* private fields */ }
Expand description

Type-erased plan data that owns all allocations.

This is what Partial actually stores a reference to. The type safety comes from the TypePlan<T> wrapper at the API boundary.

Users should build plans using TypePlan::<T>::build() which provides type safety.

Implementations§

Source§

impl TypePlanCore

Source

pub unsafe fn from_shape(shape: &'static Shape) -> Result<Arc<Self>, AllocError>

Build a TypePlanCore directly from a shape, with process-global caching.

Under std, one plan is cached per unique shape (&'static Shape) for the lifetime of the process. In no_std, this builds a fresh plan each call.

§Safety

The caller must ensure that the shape is valid and corresponds to a real type. Using an incorrect or maliciously crafted shape can lead to undefined behavior when materializing values.

Source

pub fn root(&self) -> &TypePlanNode

Get the root node.

Source

pub fn root_id(&self) -> NodeId

Get the root node index.

Source

pub fn node(&self, idx: NodeId) -> &TypePlanNode

Get a node by its index.

Source

pub fn field(&self, idx: Idx<FieldPlan>) -> &FieldPlan

Get a field by its index.

Source

pub fn fields(&self, range: SliceRange<FieldPlan>) -> &[FieldPlan]

Get a slice of fields from a range.

Source

pub fn variant(&self, idx: Idx<VariantPlanMeta>) -> &VariantPlanMeta

Get a variant by its index.

Source

pub fn variants(&self, range: SliceRange<VariantPlanMeta>) -> &[VariantPlanMeta]

Get a slice of variants from a range.

Source

pub fn validators( &self, range: SliceRange<PrecomputedValidator>, ) -> &[PrecomputedValidator]

Get a slice of validators from a range.

Source

pub fn struct_field_node( &self, parent: &TypePlanNode, idx: usize, ) -> Option<&TypePlanNode>

Get the child node for a struct field by index. Follows BackRef nodes for recursive types.

Source

pub fn enum_variant_field_node( &self, parent: &TypePlanNode, variant_idx: usize, field_idx: usize, ) -> Option<&TypePlanNode>

Get the child node for an enum variant’s field. Follows BackRef nodes for recursive types.

Source

pub fn list_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for list/array items.

Source

pub fn set_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for set items.

Source

pub fn map_key_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for map keys.

Source

pub fn map_value_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for map values.

Source

pub fn option_inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for Option inner type.

Source

pub fn result_ok_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for Result Ok type.

Source

pub fn result_err_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for Result Err type.

Source

pub fn pointer_pointee_node( &self, parent: &TypePlanNode, ) -> Option<&TypePlanNode>

Get the child node for pointer pointee.

Source

pub fn inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>

Get the child node for shape.inner navigation (used by begin_inner).

Source

pub fn resolve_backref<'a>(&'a self, node: &'a TypePlanNode) -> &'a TypePlanNode

Resolve a BackRef to get the actual node it points to.

Source

pub fn as_struct_plan<'a>( &'a self, node: &'a TypePlanNode, ) -> Option<&'a StructPlan>

Get the StructPlan if a node is a struct type. Follows BackRef nodes for recursive types.

Source

pub fn as_enum_plan<'a>( &'a self, node: &'a TypePlanNode, ) -> Option<&'a EnumPlan>

Get the EnumPlan if a node is an enum type. Follows BackRef nodes for recursive types.

Source

pub fn resolve_backref_id(&self, node_id: NodeId) -> &TypePlanNode

Resolve a BackRef (by node ID) to get the actual node it points to.

Source

pub fn struct_plan_by_id(&self, node_id: NodeId) -> Option<&StructPlan>

Get the StructPlan for a node ID, if it’s a struct type. Follows BackRef nodes for recursive types.

Source

pub fn enum_plan_by_id(&self, node_id: NodeId) -> Option<&EnumPlan>

Get the EnumPlan for a node ID, if it’s an enum type. Follows BackRef nodes for recursive types.

Source

pub fn struct_field_node_id( &self, parent_id: NodeId, idx: usize, ) -> Option<NodeId>

Get the child node ID for a struct field by index. Follows BackRef nodes for recursive types.

Source

pub fn enum_variant_field_node_id( &self, parent_id: NodeId, variant_idx: usize, field_idx: usize, ) -> Option<NodeId>

Get the child node ID for an enum variant’s field. Follows BackRef nodes for recursive types.

Source

pub fn list_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for list/array items.

Source

pub fn set_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for set items.

Source

pub fn map_key_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for map keys.

Source

pub fn map_value_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for map values.

Source

pub fn option_some_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for Option’s Some variant.

Source

pub fn result_nodes_id(&self, parent_id: NodeId) -> Option<(NodeId, NodeId)>

Get the child node IDs for Result’s Ok and Err variants.

Source

pub fn pointer_inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for smart pointer inner type.

Source

pub fn inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>

Get the child node ID for transparent convert inner type.

Trait Implementations§

Source§

impl Debug for TypePlanCore

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.