pub struct TemplateBuilder { /* private fields */ }Expand description
Template builder for fluent API
Implementations§
Source§impl TemplateBuilder
impl TemplateBuilder
Sourcepub fn string_field(self, name: impl Into<String>) -> Self
pub fn string_field(self, name: impl Into<String>) -> Self
Add a string field
Sourcepub fn required_string(self, name: impl Into<String>) -> Self
pub fn required_string(self, name: impl Into<String>) -> Self
Add a required string field
Sourcepub fn integer_field(self, name: impl Into<String>) -> Self
pub fn integer_field(self, name: impl Into<String>) -> Self
Add an integer field
Sourcepub fn float_field(self, name: impl Into<String>) -> Self
pub fn float_field(self, name: impl Into<String>) -> Self
Add a float field
Sourcepub fn boolean_field(self, name: impl Into<String>) -> Self
pub fn boolean_field(self, name: impl Into<String>) -> Self
Add a boolean field
Sourcepub fn field_with_default(
self,
name: impl Into<String>,
field_type: FieldType,
default: FactValue,
) -> Self
pub fn field_with_default( self, name: impl Into<String>, field_type: FieldType, default: FactValue, ) -> Self
Add a field with custom default
Sourcepub fn array_field(
self,
name: impl Into<String>,
element_type: FieldType,
) -> Self
pub fn array_field( self, name: impl Into<String>, element_type: FieldType, ) -> Self
Add an array field
Sourcepub fn multislot_field(
self,
name: impl Into<String>,
element_type: FieldType,
) -> Self
pub fn multislot_field( self, name: impl Into<String>, element_type: FieldType, ) -> Self
Add a multislot field (CLIPS-style naming for arrays)
This is an alias for array_field that uses CLIPS terminology.
In CLIPS, multislot fields can hold multiple values of the same type.
§Example
ⓘ
let template = TemplateBuilder::new("Order")
.required_string("order_id")
.multislot_field("items", FieldType::String) // CLIPS style
.build();Equivalent to:
(deftemplate order
(slot order-id (type STRING))
(multislot items (type STRING)))Sourcepub fn required_array_field(
self,
name: impl Into<String>,
element_type: FieldType,
) -> Self
pub fn required_array_field( self, name: impl Into<String>, element_type: FieldType, ) -> Self
Add a required array field
Sourcepub fn required_multislot_field(
self,
name: impl Into<String>,
element_type: FieldType,
) -> Self
pub fn required_multislot_field( self, name: impl Into<String>, element_type: FieldType, ) -> Self
Add a required multislot field (CLIPS-style)
Auto Trait Implementations§
impl Freeze for TemplateBuilder
impl RefUnwindSafe for TemplateBuilder
impl Send for TemplateBuilder
impl Sync for TemplateBuilder
impl Unpin for TemplateBuilder
impl UnsafeUnpin for TemplateBuilder
impl UnwindSafe for TemplateBuilder
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