TypeBuilder

Struct TypeBuilder 

Source
pub struct TypeBuilder { /* private fields */ }
Expand description

Builder for constructing BAML types at runtime

Implementations§

Source§

impl TypeBuilder

Source

pub fn new(runtime: *const c_void) -> Self

Create a new TypeBuilder (infallible)

Source

pub fn string(&self) -> TypeDef

Get string type

Source

pub fn int(&self) -> TypeDef

Get int type

Source

pub fn float(&self) -> TypeDef

Get float type

Source

pub fn bool(&self) -> TypeDef

Get bool type

Source

pub fn null(&self) -> TypeDef

Get null type

Source

pub fn literal_string(&self, value: &str) -> TypeDef

Get a literal string type

Source

pub fn literal_int(&self, value: i64) -> TypeDef

Get a literal int type

Source

pub fn literal_bool(&self, value: bool) -> TypeDef

Get a literal bool type

Source

pub fn list(&self, inner: &TypeDef) -> TypeDef

Get a list type containing the given inner type

Source

pub fn optional(&self, inner: &TypeDef) -> TypeDef

Get an optional type containing the given inner type

Source

pub fn map(&self, key: &TypeDef, value: &TypeDef) -> TypeDef

Get a map type with the given key and value types

Source

pub fn union(&self, types: &[&TypeDef]) -> TypeDef

Get a union type of the given types

Source

pub fn add_baml(&self, baml: &str) -> Result<(), BamlError>

Parse and add BAML schema definitions

Source

pub fn print(&self) -> String

Get string representation (never fails)

Source

pub fn add_enum(&self, name: &str) -> Result<EnumBuilder, BamlError>

Add a new enum (fallible - name conflicts, invalid names)

Source

pub fn get_enum(&self, name: &str) -> Option<EnumBuilder>

Get an enum by name (nullable - may not exist)

Source

pub fn list_enums(&self) -> Vec<EnumBuilder>

List all enums (infallible)

Source

pub fn add_class(&self, name: &str) -> Result<ClassBuilder, BamlError>

Add a new class (fallible - name conflicts, invalid names)

Source

pub fn get_class(&self, name: &str) -> Option<ClassBuilder>

Get a class by name (nullable - may not exist)

Source

pub fn list_classes(&self) -> Vec<ClassBuilder>

List all classes (infallible)

Trait Implementations§

Source§

impl BamlEncode for TypeBuilder

Source§

fn baml_encode(&self) -> HostValue

Encode to a HostValue (inbound schema)
Source§

impl Clone for TypeBuilder

Source§

fn clone(&self) -> TypeBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.