[−][src]Trait ketos::structs::StructDefinition
Implements construction and field access for Struct
and struct
-like values.
Required methods
fn is_instance(&self, value: &Value, def: &Rc<StructDef>) -> bool
Returns whether the given value is an instance of the given StructDef
.
def
is the StructDef
instance for this definition.
fn from_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
Creates a value of this struct
type from the given list of fields.
def
is the StructDef
instance for this definition.
fn get_field(
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
Returns a field from a struct
value.
def
is the StructDef
instance for this definition.
fn field_names(&self) -> Vec<Name>
Returns a list of field names.
fn replace_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
Returns a new struct
value with a set of fields replaced with given values.
def
is the StructDef
instance for this definition.
Provided methods
fn size(&self) -> usize
Returns an estimate of the memory held by this definition.
The result will be used in applying memory restrictions to executing code. The result MUST NOT change for the lifetime of the value.
Methods
impl dyn StructDefinition
[src]
pub fn is<T: StructDefinition>(&self) -> bool
[src]
Returns whether the contained value is of the given type.
pub fn downcast<T: StructDefinition>(bx: Box<Self>) -> Result<Box<T>, Box<Self>>
[src]
Attempts to downcast a Box<Trait>
to a concrete type.
pub fn downcast_rc<T: StructDefinition>(rc: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
[src]
Returns an owned Rc
reference to the contained value,
if it is of the given type.
pub fn downcast_ref<T: StructDefinition>(&self) -> Option<&T>
[src]
Returns a reference to the contained value, if it is of the given type.
pub fn downcast_mut<T: StructDefinition>(&mut self) -> Option<&mut T>
[src]
Returns a mutable reference to the contained value, if it is of the given type.
Implementors
impl StructDefinition for StructValueDef
[src]
fn is_instance(&self, value: &Value, def: &Rc<StructDef>) -> bool
[src]
fn from_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
[src]
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
fn get_field(
&self,
_scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
[src]
&self,
_scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
fn field_names(&self) -> Vec<Name>
[src]
fn replace_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
[src]
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
fn size(&self) -> usize
[src]
impl<T: StructValue> StructDefinition for ForeignStructDef<T>
[src]
fn is_instance(&self, value: &Value, _def: &Rc<StructDef>) -> bool
[src]
fn from_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
[src]
&self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
fn get_field(
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
[src]
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: &Value,
field: Name
) -> Result<Value, Error>
fn field_names(&self) -> Vec<Name>
[src]
fn replace_fields(
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>
[src]
&self,
scope: &Scope,
def: &Rc<StructDef>,
value: Value,
fields: &mut [(Name, Value)]
) -> Result<Value, Error>