Skip to main content

StructType

Trait StructType 

Source
pub trait StructType: Send + Sync {
    // Required methods
    fn get_type(&self) -> &Type;
    fn new_value<'b, 'v>(
        &self,
        fields: BTreeMap<String, CowVal<'b, 'v>>,
    ) -> Result<Box<dyn Val + 'v>, ExecutionError>;
}
Expand description

A struct type that expressions can construct, e.g. acme.Account{id: 1}.

StructDef is one; implementing this trait lets a struct literal construct any other Val, e.g. a Rust type of your own.

Required Methods§

Source

fn get_type(&self) -> &Type

The struct’s type: its name is the one struct literals construct it by, and the one it is registered under.

Source

fn new_value<'b, 'v>( &self, fields: BTreeMap<String, CowVal<'b, 'v>>, ) -> Result<Box<dyn Val + 'v>, ExecutionError>

Creates a value of this type from the fields of a struct literal.

§Errors

Fails when the fields do not make a value of this type, e.g. an unknown field or a value of the wrong type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§