pub struct TypeBuilder { /* private fields */ }Expand description
Builder for constructing BAML types at runtime
Implementations§
Source§impl TypeBuilder
impl TypeBuilder
Sourcepub fn literal_string(&self, value: &str) -> TypeDef
pub fn literal_string(&self, value: &str) -> TypeDef
Get a literal string type
Sourcepub fn literal_int(&self, value: i64) -> TypeDef
pub fn literal_int(&self, value: i64) -> TypeDef
Get a literal int type
Sourcepub fn literal_bool(&self, value: bool) -> TypeDef
pub fn literal_bool(&self, value: bool) -> TypeDef
Get a literal bool type
Sourcepub fn optional(&self, inner: &TypeDef) -> TypeDef
pub fn optional(&self, inner: &TypeDef) -> TypeDef
Get an optional type containing the given inner type
Sourcepub fn map(&self, key: &TypeDef, value: &TypeDef) -> TypeDef
pub fn map(&self, key: &TypeDef, value: &TypeDef) -> TypeDef
Get a map type with the given key and value types
Sourcepub fn add_baml(&self, baml: &str) -> Result<(), BamlError>
pub fn add_baml(&self, baml: &str) -> Result<(), BamlError>
Parse and add BAML schema definitions
Sourcepub fn add_enum(&self, name: &str) -> Result<EnumBuilder, BamlError>
pub fn add_enum(&self, name: &str) -> Result<EnumBuilder, BamlError>
Add a new enum (fallible - name conflicts, invalid names)
Sourcepub fn get_enum(&self, name: &str) -> Option<EnumBuilder>
pub fn get_enum(&self, name: &str) -> Option<EnumBuilder>
Get an enum by name (nullable - may not exist)
Sourcepub fn list_enums(&self) -> Vec<EnumBuilder>
pub fn list_enums(&self) -> Vec<EnumBuilder>
List all enums (infallible)
Sourcepub fn add_class(&self, name: &str) -> Result<ClassBuilder, BamlError>
pub fn add_class(&self, name: &str) -> Result<ClassBuilder, BamlError>
Add a new class (fallible - name conflicts, invalid names)
Sourcepub fn get_class(&self, name: &str) -> Option<ClassBuilder>
pub fn get_class(&self, name: &str) -> Option<ClassBuilder>
Get a class by name (nullable - may not exist)
Sourcepub fn list_classes(&self) -> Vec<ClassBuilder>
pub fn list_classes(&self) -> Vec<ClassBuilder>
List all classes (infallible)
Trait Implementations§
Source§impl BamlEncode for TypeBuilder
impl BamlEncode for TypeBuilder
Source§fn baml_encode(&self) -> HostValue
fn baml_encode(&self) -> HostValue
Encode to a
HostValue (inbound schema)Source§impl Clone for TypeBuilder
impl Clone for TypeBuilder
Source§fn clone(&self) -> TypeBuilder
fn clone(&self) -> TypeBuilder
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 moreAuto Trait Implementations§
impl Freeze for TypeBuilder
impl RefUnwindSafe for TypeBuilder
impl Send for TypeBuilder
impl Sync for TypeBuilder
impl Unpin for TypeBuilder
impl UnwindSafe for TypeBuilder
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