Skip to main content

TypePlan

Struct TypePlan 

Source
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>

Source

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()?;
Source

pub 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

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().

Source

pub fn core(&self) -> Arc<TypePlanCore>

Get a reference to the internal core.

Source

pub fn root(&self) -> &TypePlanNode

Get the root node.

Source§

impl<'a, T: Facet<'a> + ?Sized> TypePlan<T>

Source

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.

Source

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

Trait Implementations§

Source§

impl<T: Debug + ?Sized> Debug for TypePlan<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TypePlan<T>
where T: ?Sized,

§

impl<T> RefUnwindSafe for TypePlan<T>
where T: ?Sized,

§

impl<T> Send for TypePlan<T>
where T: ?Sized,

§

impl<T> Sync for TypePlan<T>
where T: ?Sized,

§

impl<T> Unpin for TypePlan<T>
where T: ?Sized,

§

impl<T> UnsafeUnpin for TypePlan<T>
where T: ?Sized,

§

impl<T> UnwindSafe for TypePlan<T>
where T: ?Sized,

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.