pub struct ShapeBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ShapeBuilder
impl ShapeBuilder
Sourcepub const fn for_sized<T>(type_identifier: &'static str) -> Self
pub const fn for_sized<T>(type_identifier: &'static str) -> Self
Create a new builder for a sized type.
The id and layout are derived from the type parameter.
Sourcepub const fn for_unsized<T: ?Sized>(type_identifier: &'static str) -> Self
pub const fn for_unsized<T: ?Sized>(type_identifier: &'static str) -> Self
Create a new builder for an unsized type.
Sourcepub const fn vtable(self, vtable: VTableErased) -> Self
pub const fn vtable(self, vtable: VTableErased) -> Self
Set the vtable (type-erased).
Sourcepub const fn vtable_direct(self, vtable: &'static VTableDirect) -> Self
pub const fn vtable_direct(self, vtable: &'static VTableDirect) -> Self
Set the vtable from a direct vtable reference.
Sourcepub const fn vtable_indirect(self, vtable: &'static VTableIndirect) -> Self
pub const fn vtable_indirect(self, vtable: &'static VTableIndirect) -> Self
Set the vtable from an indirect vtable reference.
Sourcepub const fn type_ops(self, type_ops: TypeOps) -> Self
pub const fn type_ops(self, type_ops: TypeOps) -> Self
Set the per-type operations (drop, default, clone) using the erased enum.
For generic containers, use this to provide the monomorphized operations while sharing the main vtable across all instantiations.
Sourcepub const fn type_ops_direct(self, type_ops: &'static TypeOpsDirect) -> Self
pub const fn type_ops_direct(self, type_ops: &'static TypeOpsDirect) -> Self
Set per-type operations for concrete types (uses thin pointers).
Use this for scalars, String, and derived structs/enums.
Sourcepub const fn type_ops_indirect(self, type_ops: &'static TypeOpsIndirect) -> Self
pub const fn type_ops_indirect(self, type_ops: &'static TypeOpsIndirect) -> Self
Set per-type operations for generic containers (uses wide pointers).
Use this for Vec<T>, Option<T>, Arc<T>, etc.
Sourcepub const fn add_marker_trait(self, trait_flag: MarkerTraits) -> Self
pub const fn add_marker_trait(self, trait_flag: MarkerTraits) -> Self
Add a marker trait flag.
Sourcepub const fn marker_traits(self, traits: MarkerTraits) -> Self
pub const fn marker_traits(self, traits: MarkerTraits) -> Self
Set all marker traits at once using combined bitflags.
Sourcepub const fn unwind_safe(self) -> Self
pub const fn unwind_safe(self) -> Self
Mark type as implementing UnwindSafe.
Sourcepub const fn ref_unwind_safe(self) -> Self
pub const fn ref_unwind_safe(self) -> Self
Mark type as implementing RefUnwindSafe.
Sourcepub const fn type_params(self, type_params: &'static [TypeParam]) -> Self
pub const fn type_params(self, type_params: &'static [TypeParam]) -> Self
Set the type parameters.
Sourcepub const fn attributes(self, attributes: &'static [Attr]) -> Self
pub const fn attributes(self, attributes: &'static [Attr]) -> Self
Set the attributes.
Sourcepub const fn inner(self, inner: &'static Shape) -> Self
pub const fn inner(self, inner: &'static Shape) -> Self
Set the inner shape (for transparent/newtype wrappers).
Sourcepub const fn builder_shape(self, builder: &'static Shape) -> Self
pub const fn builder_shape(self, builder: &'static Shape) -> Self
Set the builder shape for immutable collections.
If set, deserializers will build the value using the builder shape,
then convert to the target type. Used for immutable collections like
Bytes (builds through BytesMut) or Arc<[T]> (builds through Vec<T>).
Sourcepub const fn type_name(self, type_name: TypeNameFn) -> Self
pub const fn type_name(self, type_name: TypeNameFn) -> Self
Set the type name function for formatting generic type names.
For generic types like Vec<T>, this function formats the full name
including type parameters (e.g., Vec<String>).
Sourcepub const fn proxy(self, proxy: &'static ProxyDef) -> Self
pub const fn proxy(self, proxy: &'static ProxyDef) -> Self
Set the container-level proxy for custom serialization/deserialization.
When a proxy is set, the type will be serialized/deserialized through the proxy type instead of directly.
Sourcepub const fn variance(self, variance: fn(&'static Shape) -> Variance) -> Self
pub const fn variance(self, variance: fn(&'static Shape) -> Variance) -> Self
Set the variance function for this type.
For derived types, use Shape::computed_variance which walks fields.
For leaf types, use Variance::COVARIANT, Variance::INVARIANT, etc.
Sourcepub const fn flags(self, flags: ShapeFlags) -> Self
pub const fn flags(self, flags: ShapeFlags) -> Self
Set the flags for this shape.
Sourcepub const fn untagged(self) -> Self
pub const fn untagged(self) -> Self
Mark this enum as untagged.
Untagged enums serialize their content directly without any discriminant.
Sourcepub const fn tag(self, tag: &'static str) -> Self
pub const fn tag(self, tag: &'static str) -> Self
Set the tag field name for internally/adjacently tagged enums.