pub struct DynamicTypeBuilder { /* private fields */ }Expand description
XTypes §7.5.4 DynamicTypeBuilder.
Implementations§
Source§impl DynamicTypeBuilder
impl DynamicTypeBuilder
Sourcepub fn descriptor(&self) -> &TypeDescriptor
pub fn descriptor(&self) -> &TypeDescriptor
Current descriptor (read-only view).
Sourcepub fn set_descriptor(
&mut self,
descriptor: TypeDescriptor,
) -> Result<(), DynamicError>
pub fn set_descriptor( &mut self, descriptor: TypeDescriptor, ) -> Result<(), DynamicError>
Sets the descriptor anew (spec §7.5.4.1 SetDescriptor) — only
allowed before build().
§Errors
PreconditionNotMet if build() was already called.
Sourcepub fn add_member(
&mut self,
descriptor: MemberDescriptor,
) -> Result<(), DynamicError>
pub fn add_member( &mut self, descriptor: MemberDescriptor, ) -> Result<(), DynamicError>
Adds a member (spec §7.5.4.1.2 AddMember).
Validates immediately:
- Unique name among the existing members.
- Unique id (only when composite XCDR2-capable).
- The member type is consistent.
- The kind allows members.
index is set automatically if the caller leaves it at 0,
otherwise respected.
§Errors
BuilderConflict on a dup name/id, IllegalOperation if the
kind carries no members.
Sourcepub fn add_struct_member(
&mut self,
name: impl Into<String>,
id: MemberId,
ty: TypeDescriptor,
) -> Result<(), DynamicError>
pub fn add_struct_member( &mut self, name: impl Into<String>, id: MemberId, ty: TypeDescriptor, ) -> Result<(), DynamicError>
Sourcepub fn build(&self) -> Result<DynamicType, DynamicError>
pub fn build(&self) -> Result<DynamicType, DynamicError>
Spec §7.5.4.1.1 Build — finalizes the builder.
Validations:
- all member descriptors consistent
- inheritance cycle via names
- union: discriminator + at least 1 case
- unique labels in a union
§Errors
BuilderConflict / Inconsistent.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DynamicTypeBuilder
impl RefUnwindSafe for DynamicTypeBuilder
impl Send for DynamicTypeBuilder
impl Sync for DynamicTypeBuilder
impl Unpin for DynamicTypeBuilder
impl UnsafeUnpin for DynamicTypeBuilder
impl UnwindSafe for DynamicTypeBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more