pub struct DynamicClass<T: KnownTypes, S: KnownTypes> {
pub name: String,
/* private fields */
}Expand description
A fully dynamic class - all fields accessed via .get()
Fields§
§name: StringImplementations§
Source§impl<T: KnownTypes, S: KnownTypes> DynamicClass<T, S>
impl<T: KnownTypes, S: KnownTypes> DynamicClass<T, S>
Sourcepub fn with_fields(
name: String,
fields: HashMap<String, BamlValue<T, S>>,
) -> Self
pub fn with_fields( name: String, fields: HashMap<String, BamlValue<T, S>>, ) -> Self
Create with pre-populated fields
Sourcepub fn get<V: FromBamlValue<T, S>>(
&self,
field_name: &str,
) -> Result<V, BamlError>
pub fn get<V: FromBamlValue<T, S>>( &self, field_name: &str, ) -> Result<V, BamlError>
Get a field and convert it to the specified type. Clones the value.
Sourcepub fn get_ref<'a, V: FromBamlValueRef<'a, T, S>>(
&'a self,
field_name: &str,
) -> Result<V, BamlError>
pub fn get_ref<'a, V: FromBamlValueRef<'a, T, S>>( &'a self, field_name: &str, ) -> Result<V, BamlError>
Get a field by reference (zero-copy for primitives and known types).
Sourcepub fn pop<V: FromBamlValue<T, S>>(
&mut self,
field_name: &str,
) -> Result<V, BamlError>
pub fn pop<V: FromBamlValue<T, S>>( &mut self, field_name: &str, ) -> Result<V, BamlError>
Remove a field and convert it (takes ownership, no clone).
Sourcepub fn into_fields(self) -> HashMap<String, BamlValue<T, S>>
pub fn into_fields(self) -> HashMap<String, BamlValue<T, S>>
Consume this DynamicClass and return the remaining fields.
Useful for @@dynamic classes: pop known fields first, then call this
to get remaining dynamic fields.
Trait Implementations§
Source§impl<T: Clone + KnownTypes, S: Clone + KnownTypes> Clone for DynamicClass<T, S>
impl<T: Clone + KnownTypes, S: Clone + KnownTypes> Clone for DynamicClass<T, S>
Source§fn clone(&self) -> DynamicClass<T, S>
fn clone(&self) -> DynamicClass<T, S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug + KnownTypes, S: Debug + KnownTypes> Debug for DynamicClass<T, S>
impl<T: Debug + KnownTypes, S: Debug + KnownTypes> Debug for DynamicClass<T, S>
Source§impl<T: KnownTypes, S: KnownTypes> FromBamlValue<T, S> for DynamicClass<T, S>
DynamicClass extraction
impl<T: KnownTypes, S: KnownTypes> FromBamlValue<T, S> for DynamicClass<T, S>
DynamicClass extraction
Source§impl<'a, T: KnownTypes, S: KnownTypes> FromBamlValueRef<'a, T, S> for &'a DynamicClass<T, S>
DynamicClass ref
impl<'a, T: KnownTypes, S: KnownTypes> FromBamlValueRef<'a, T, S> for &'a DynamicClass<T, S>
DynamicClass ref
Auto Trait Implementations§
impl<T, S> Freeze for DynamicClass<T, S>
impl<T, S> RefUnwindSafe for DynamicClass<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for DynamicClass<T, S>
impl<T, S> Sync for DynamicClass<T, S>
impl<T, S> Unpin for DynamicClass<T, S>
impl<T, S> UnwindSafe for DynamicClass<T, S>where
T: UnwindSafe,
S: UnwindSafe,
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