This reference describes unreleased code on main; no release documents it yet.

rlmesh::types::Value

enumPreviewuse rlmesh::types::Value;[source]

A value exchanged with a model or environment.

enum Value

Supported 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.

None

variant[source]
None

None.

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) -> ValueKind

The value’s kind.

is_none

method[source]
fn is_none(&self) -> bool

Whether 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