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
impl TypePlanCore
Sourcepub unsafe fn from_shape(shape: &'static Shape) -> Result<Arc<Self>, AllocError>
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.
Sourcepub fn fields(&self, range: SliceRange<FieldPlan>) -> &[FieldPlan]
pub fn fields(&self, range: SliceRange<FieldPlan>) -> &[FieldPlan]
Get a slice of fields from a range.
Sourcepub fn variant(&self, idx: Idx<VariantPlanMeta>) -> &VariantPlanMeta
pub fn variant(&self, idx: Idx<VariantPlanMeta>) -> &VariantPlanMeta
Get a variant by its index.
Sourcepub fn variants(&self, range: SliceRange<VariantPlanMeta>) -> &[VariantPlanMeta]
pub fn variants(&self, range: SliceRange<VariantPlanMeta>) -> &[VariantPlanMeta]
Get a slice of variants from a range.
Sourcepub fn validators(
&self,
range: SliceRange<PrecomputedValidator>,
) -> &[PrecomputedValidator]
pub fn validators( &self, range: SliceRange<PrecomputedValidator>, ) -> &[PrecomputedValidator]
Get a slice of validators from a range.
Sourcepub fn struct_field_node(
&self,
parent: &TypePlanNode,
idx: usize,
) -> Option<&TypePlanNode>
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.
Sourcepub fn enum_variant_field_node(
&self,
parent: &TypePlanNode,
variant_idx: usize,
field_idx: usize,
) -> Option<&TypePlanNode>
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.
Sourcepub fn list_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn list_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for list/array items.
Sourcepub fn set_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn set_item_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for set items.
Sourcepub fn map_key_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn map_key_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for map keys.
Sourcepub fn map_value_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn map_value_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for map values.
Sourcepub fn option_inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn option_inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for Option inner type.
Sourcepub fn result_ok_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn result_ok_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for Result Ok type.
Sourcepub fn result_err_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn result_err_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for Result Err type.
Sourcepub fn pointer_pointee_node(
&self,
parent: &TypePlanNode,
) -> Option<&TypePlanNode>
pub fn pointer_pointee_node( &self, parent: &TypePlanNode, ) -> Option<&TypePlanNode>
Get the child node for pointer pointee.
Sourcepub fn inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
pub fn inner_node(&self, parent: &TypePlanNode) -> Option<&TypePlanNode>
Get the child node for shape.inner navigation (used by begin_inner).
Sourcepub fn resolve_backref<'a>(&'a self, node: &'a TypePlanNode) -> &'a TypePlanNode
pub fn resolve_backref<'a>(&'a self, node: &'a TypePlanNode) -> &'a TypePlanNode
Resolve a BackRef to get the actual node it points to.
Sourcepub fn as_struct_plan<'a>(
&'a self,
node: &'a TypePlanNode,
) -> Option<&'a StructPlan>
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.
Sourcepub fn as_enum_plan<'a>(
&'a self,
node: &'a TypePlanNode,
) -> Option<&'a EnumPlan>
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.
Sourcepub fn resolve_backref_id(&self, node_id: NodeId) -> &TypePlanNode
pub fn resolve_backref_id(&self, node_id: NodeId) -> &TypePlanNode
Resolve a BackRef (by node ID) to get the actual node it points to.
Sourcepub fn struct_plan_by_id(&self, node_id: NodeId) -> Option<&StructPlan>
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.
Sourcepub fn enum_plan_by_id(&self, node_id: NodeId) -> Option<&EnumPlan>
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.
Sourcepub fn struct_field_node_id(
&self,
parent_id: NodeId,
idx: usize,
) -> Option<NodeId>
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.
Sourcepub fn enum_variant_field_node_id(
&self,
parent_id: NodeId,
variant_idx: usize,
field_idx: usize,
) -> Option<NodeId>
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.
Sourcepub fn list_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn list_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for list/array items.
Sourcepub fn set_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn set_item_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for set items.
Sourcepub fn map_key_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn map_key_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for map keys.
Sourcepub fn map_value_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn map_value_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for map values.
Sourcepub fn option_some_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn option_some_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for Option’s Some variant.
Sourcepub fn result_nodes_id(&self, parent_id: NodeId) -> Option<(NodeId, NodeId)>
pub fn result_nodes_id(&self, parent_id: NodeId) -> Option<(NodeId, NodeId)>
Get the child node IDs for Result’s Ok and Err variants.
Sourcepub fn pointer_inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn pointer_inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for smart pointer inner type.
Sourcepub fn inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>
pub fn inner_node_id(&self, parent_id: NodeId) -> Option<NodeId>
Get the child node ID for transparent convert inner type.