rlmesh::types::Value
A value exchanged with a model or environment.
enum ValueSupported kinds: the six primitives, Tensor, list, tuple and
dict. A Discrete action is an Int, a Box observation a Tensor;
bool is not an Int.
Reads are strict: as_float refuses an Int and
as_int refuses a Bool, each with the TypeError class.
Equality is kind-strict too: Int(1) != Float(1.0) and Bool(true) != Int(1); a Float compares as IEEE f64 (NaN is unequal to itself), a
Dict ignores order.
Also available as rlmesh::Value.
Variants
Methods
- kind()The value's kind.
- is_none()Whether this is
None. - as_bool()A
Bool's value. - as_int()An
Int's value; aBoolis refused. - as_float()A
Float's value; anIntis refused. - as_text()A
Text's value. - as_bytes()A
Bytes's value. - as_tensor()A
Tensor's value. - as_list()A
List's items. - as_tuple()A
Tuple's items. - as_dict()A
Dict's map.
None
variant[source]NoneNone.
Bool
variant[source]Bool(bool)bool.
Int
variant[source]Int(i64)int.
Float
variant[source]Float(f64)float.
Text
variant[source]Text(String)str.
Bytes
variant[source]Bytes(Vec<u8>)bytes.
Tensor
variant[source]Tensor(Tensor)rlmesh.Tensor.
List
variant[source]List(Vec<Value>)list.
Tuple
variant[source]Tuple(Vec<Value>)tuple.
Dict
variant[source]Dict(Metadata)dict, in insertion order.
kind
method[source]fn kind(&self) -> ValueKindThe value’s kind.
is_none
method[source]fn is_none(&self) -> boolWhether this is None.
as_bool
method[source]fn as_bool(&self) -> Result<bool>A Bool’s value.
as_int
method[source]fn as_int(&self) -> Result<i64>An Int’s value; a Bool is refused.
as_float
method[source]fn as_float(&self) -> Result<f64>A Float’s value; an Int is refused.
as_text
method[source]fn as_text(&self) -> Result<&str>A Text’s value.
as_bytes
method[source]fn as_bytes(&self) -> Result<&[u8]>A Bytes’s value.
as_tensor
method[source]fn as_tensor(&self) -> Result<&Tensor>A Tensor’s value.
as_list
method[source]fn as_list(&self) -> Result<&[Value]>A List’s items.
as_tuple
method[source]fn as_tuple(&self) -> Result<&[Value]>A Tuple’s items.
as_dict
method[source]fn as_dict(&self) -> Result<&Metadata>A Dict’s map.
Trait implementations
- impl Clone for Value
- impl StructuralPartialEq for Value
- impl PartialEq for Value
- impl Debug for Value
- impl From<bool> for Value
- impl From<i64> for Value
- impl From<i32> for Value
- impl From<f64> for Value
- impl From<f32> for Value
- impl From<&str> for Value
- impl From<String> for Value
- impl From<Vec<u8>> for Value
- impl From<&[u8]> for Value
- impl From<Tensor> for Value
- impl From<Vec<Value>> for Value
- impl From<Metadata> for Value