Struct NestedClassBuilder
pub struct NestedClassBuilder { /* private fields */ }Expand description
Builder for creating NestedClass table entries.
NestedClassBuilder provides a fluent API for creating entries in the NestedClass
metadata table, which defines hierarchical relationships between nested types and
their enclosing types.
§Purpose
The NestedClass table serves several key functions:
- Type Hierarchy: Defines which types are nested within other types
- Visibility Scoping: Establishes access rules for nested types
- Enclosing Context: Links nested types to their containing types
- Namespace Resolution: Enables proper type resolution within nested contexts
- Compilation Support: Provides context for type compilation and loading
§Builder Pattern
The builder provides a fluent interface for constructing NestedClass entries:
let nesting_token = NestedClassBuilder::new()
.nested_class(inner_row)
.enclosing_class(outer_row)
.build(&mut assembly)?;§Validation
The builder enforces the following constraints:
- Nested Class Required: A nested class token must be provided
- Enclosing Class Required: An enclosing class token must be provided
- Token Validation: Both tokens must be valid TypeDef tokens
- Relationship Validation: Prevents invalid nesting scenarios (self-nesting, etc.)
§Integration
NestedClass entries integrate with other metadata structures:
- TypeDef: Both nested and enclosing types must be TypeDef entries
- Type Registry: Establishes relationships in the type system
- Visibility Rules: Nested types inherit accessibility from their context
Implementations§
§impl NestedClassBuilder
impl NestedClassBuilder
pub fn new() -> Self
pub fn new() -> Self
Creates a new NestedClassBuilder instance.
Returns a builder with all fields unset, ready for configuration through the fluent API methods.
§Examples
let builder = NestedClassBuilder::new();pub fn nested_class(self, nested_class_row: u32) -> Self
pub fn nested_class(self, nested_class_row: u32) -> Self
Sets the row index of the nested type.
The nested type must be a valid TypeDef row index or placeholder that represents the type being nested within the enclosing type.
§Arguments
nested_class_row- Row index (or placeholder) of the TypeDef for the nested type
§Examples
let inner_token = TypeDefBuilder::new()
.name("InnerClass")
.flags(TypeAttributes::NESTED_PUBLIC | TypeAttributes::CLASS)
.build(&mut assembly)?;
let builder = NestedClassBuilder::new()
.nested_class(inner_token.placeholder());pub fn enclosing_class(self, enclosing_class_row: u32) -> Self
pub fn enclosing_class(self, enclosing_class_row: u32) -> Self
Sets the row index of the enclosing type.
The enclosing type must be a valid TypeDef row index or placeholder that represents the type containing the nested type.
§Arguments
enclosing_class_row- Row index (or placeholder) of the TypeDef for the enclosing type
§Examples
let outer_token = TypeDefBuilder::new()
.name("OuterClass")
.public_class()
.build(&mut assembly)?;
let builder = NestedClassBuilder::new()
.enclosing_class(outer_token.placeholder());pub fn build(self, assembly: &mut CilAssembly) -> Result<ChangeRefRc>
pub fn build(self, assembly: &mut CilAssembly) -> Result<ChangeRefRc>
Builds the NestedClass entry and adds it to the assembly.
This method validates all required fields, verifies the type tokens are valid TypeDef tokens, validates the nesting relationship, creates the NestedClass table entry, and returns the metadata token for the new entry.
§Arguments
assembly- The CilAssembly being modified
§Returns
Returns the metadata token for the newly created NestedClass entry.
§Errors
Returns an error if:
- The nested class token is not set
- The enclosing class token is not set
- Either token is not a valid TypeDef token
- The tokens refer to the same type (self-nesting)
- There are issues adding the table row
§Examples
let nesting_token = NestedClassBuilder::new()
.nested_class(inner_row)
.enclosing_class(outer_row)
.build(&mut assembly)?;
println!("Created NestedClass with token: {:?}", nesting_token);Trait Implementations§
§impl Clone for NestedClassBuilder
impl Clone for NestedClassBuilder
§fn clone(&self) -> NestedClassBuilder
fn clone(&self) -> NestedClassBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for NestedClassBuilder
impl Debug for NestedClassBuilder
Auto Trait Implementations§
impl Freeze for NestedClassBuilder
impl RefUnwindSafe for NestedClassBuilder
impl Send for NestedClassBuilder
impl Sync for NestedClassBuilder
impl Unpin for NestedClassBuilder
impl UnsafeUnpin for NestedClassBuilder
impl UnwindSafe for NestedClassBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.