Skip to main content

InstanceBuilder

Struct InstanceBuilder 

Source
pub struct InstanceBuilder<'env> { /* private fields */ }
Expand description

Builds an instance slot by slot, then creates it.

Slot values are passed as real CLIPS values rather than as make-instance text, so nothing has to be escaped or re-parsed.

Implementations§

Source§

impl<'env> InstanceBuilder<'env>

Source

pub fn integer(&mut self, slot: &str, value: i64) -> Result<&mut Self>

Sets an integer slot.

Source

pub fn float(&mut self, slot: &str, value: f64) -> Result<&mut Self>

Sets a float slot.

Source

pub fn symbol(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets a symbol slot.

Source

pub fn string(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets a string slot.

Source

pub fn instance_name(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets an instance-name slot.

Source

pub fn fact(&mut self, slot: &str, value: &Fact<'env>) -> Result<&mut Self>

Sets a slot to a fact address.

Source

pub fn instance( &mut self, slot: &str, value: &Instance<'env>, ) -> Result<&mut Self>

Sets a slot to an instance address.

Source

pub fn multifield( &mut self, slot: &str, value: &Multifield<'env>, ) -> Result<&mut Self>

Sets a multifield slot.

Source

pub fn value(&mut self, slot: &str, value: &Value<'env>) -> Result<&mut Self>

Assigns an already existing CLIPS value.

Fails with Error::ForeignEnvironment if value belongs to another environment, since CLIPS atoms are interned per environment.

Source

pub fn make(&mut self, name: Option<&str>) -> Result<Instance<'env>>

Creates the instance and returns a retained handle to it.

With None, CLIPS generates a name of the form genN. The builder is reusable afterwards, so several instances of the class can be made without recreating it.

Trait Implementations§

Source§

impl Drop for InstanceBuilder<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'env> !RefUnwindSafe for InstanceBuilder<'env>

§

impl<'env> !Send for InstanceBuilder<'env>

§

impl<'env> !Sync for InstanceBuilder<'env>

§

impl<'env> !UnwindSafe for InstanceBuilder<'env>

§

impl<'env> Freeze for InstanceBuilder<'env>

§

impl<'env> Unpin for InstanceBuilder<'env>

§

impl<'env> UnsafeUnpin for InstanceBuilder<'env>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.