pub struct TypePlan<T: ?Sized> { /* private fields */ }Expand description
Precomputed deserialization plan tree for a type.
Built once from a Shape, this encodes all decisions needed during deserialization
without repeated runtime lookups. The TypePlan owns all its allocations through
internal arenas.
The type parameter T is phantom and provides compile-time type safety:
you cannot accidentally pass a TypePlan<Foo> where TypePlan<Bar> is expected.
There is no public way to erase the type parameter.
Implementations§
Source§impl<'facet, T: Facet<'facet> + ?Sized> TypePlan<T>
impl<'facet, T: Facet<'facet> + ?Sized> TypePlan<T>
Sourcepub fn build() -> Result<Self, AllocError>
pub fn build() -> Result<Self, AllocError>
Build a TypePlan for type T.
The type parameter provides compile-time safety: you cannot accidentally
pass a TypePlan<Foo> where TypePlan<Bar> is expected.
Note: TypePlan can be built for any Facet<'_> type because the SHAPE
is always 'static. The lifetime parameter on Facet only affects the
runtime deserialized values, not the type metadata.
§Example
use facet_reflect::TypePlan;
let plan = TypePlan::<MyStruct>::build()?;Sourcepub fn build_for_format(
_format_namespace: Option<&'static str>,
) -> Result<Self, AllocError>
👎Deprecated since 0.44.0: format namespace no longer needed at build time; use build() instead
pub fn build_for_format( _format_namespace: Option<&'static str>, ) -> Result<Self, AllocError>
Build a TypePlan with format-specific proxy resolution.
Deprecated: Format namespace is no longer needed at build time. TypePlan now stores proxy nodes for all formats, and the format-specific proxy is selected at runtime during deserialization.
This method is kept for API compatibility but is equivalent to build().
Sourcepub fn core(&self) -> Arc<TypePlanCore>
pub fn core(&self) -> Arc<TypePlanCore>
Get a reference to the internal core.
Source§impl<'a, T: Facet<'a> + ?Sized> TypePlan<T>
impl<'a, T: Facet<'a> + ?Sized> TypePlan<T>
Sourcepub fn partial<'facet>(&self) -> Result<Partial<'facet, true>, AllocError>
pub fn partial<'facet>(&self) -> Result<Partial<'facet, true>, AllocError>
Create a borrowing Partial from this plan.
The Partial borrows from this TypePlan and can be used to deserialize values that may borrow from the input.
Sourcepub fn partial_owned(&self) -> Result<Partial<'static, false>, AllocError>
pub fn partial_owned(&self) -> Result<Partial<'static, false>, AllocError>
Create an owned Partial from this plan.
The Partial borrows from this TypePlan. The deserialized value will be fully owned (’static lifetime for borrowed data).