AgentValue

Enum AgentValue 

Source
pub enum AgentValue {
    Unit,
    Boolean(bool),
    Integer(i64),
    Number(f64),
    String(Arc<String>),
    Image(Arc<PhotonImage>),
    Array(Vector<AgentValue>),
    Object(HashMap<String, AgentValue>),
    Tensor(Arc<Vec<f32>>),
    Message(Arc<Message>),
    Error(Arc<AgentError>),
}

Variants§

§

Unit

§

Boolean(bool)

§

Integer(i64)

§

Number(f64)

§

String(Arc<String>)

§

Image(Arc<PhotonImage>)

§

Array(Vector<AgentValue>)

§

Object(HashMap<String, AgentValue>)

§

Tensor(Arc<Vec<f32>>)

§

Message(Arc<Message>)

§

Error(Arc<AgentError>)

Implementations§

Source§

impl AgentValue

Source

pub fn unit() -> Self

Source

pub fn boolean(value: bool) -> Self

Source

pub fn integer(value: i64) -> Self

Source

pub fn number(value: f64) -> Self

Source

pub fn string(value: impl Into<String>) -> Self

Source

pub fn image(value: PhotonImage) -> Self

Source

pub fn image_arc(value: Arc<PhotonImage>) -> Self

Source

pub fn array(value: Vector<AgentValue>) -> Self

Source

pub fn object(value: AgentValueMap<String, AgentValue>) -> Self

Source

pub fn tensor(value: Vec<f32>) -> Self

Source

pub fn message(value: Message) -> Self

Source

pub fn boolean_default() -> Self

Source

pub fn integer_default() -> Self

Source

pub fn number_default() -> Self

Source

pub fn string_default() -> Self

Source

pub fn image_default() -> Self

Source

pub fn array_default() -> Self

Source

pub fn object_default() -> Self

Source

pub fn tensor_default() -> Self

Source

pub fn from_json(value: Value) -> Result<Self, AgentError>

Source

pub fn to_json(&self) -> Value

Source

pub fn from_serialize<T: Serialize>(value: &T) -> Result<Self, AgentError>

Create AgentValue from Serialize

Source

pub fn to_deserialize<T: for<'de> Deserialize<'de>>( &self, ) -> Result<T, AgentError>

Convert AgentValue to a Deserialize

Source

pub fn is_unit(&self) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_integer(&self) -> bool

Source

pub fn is_number(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_image(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_object(&self) -> bool

Source

pub fn is_tensor(&self) -> bool

Source

pub fn is_message(&self) -> bool

Source

pub fn as_bool(&self) -> Option<bool>

Source

pub fn as_i64(&self) -> Option<i64>

Source

pub fn as_f64(&self) -> Option<f64>

Source

pub fn as_str(&self) -> Option<&str>

Source

pub fn as_image(&self) -> Option<&PhotonImage>

Source

pub fn as_image_mut(&mut self) -> Option<&mut PhotonImage>

If self is an Image, get a mutable reference to the inner PhotonImage.

Source

pub fn into_image(self) -> Option<Arc<PhotonImage>>

If self is an Image, extract the inner PhotonImage; otherwise, return None. This consumes self.

Source

pub fn as_message(&self) -> Option<&Message>

Source

pub fn as_message_mut(&mut self) -> Option<&mut Message>

Source

pub fn into_message(self) -> Option<Arc<Message>>

Source

pub fn to_boolean(&self) -> Option<bool>

Convert to Boolean.

Source

pub fn to_boolean_value(&self) -> Option<AgentValue>

Convert to AgentValue::Boolean or AgentValue::Array of booleans.

Source

pub fn to_integer(&self) -> Option<i64>

Convert to Integer (i64).

Source

pub fn to_integer_value(&self) -> Option<AgentValue>

Convert to AgentValue::Integer or AgentValue::Array of integers.

Source

pub fn to_number(&self) -> Option<f64>

Convert to Number (f64).

Source

pub fn to_number_value(&self) -> Option<AgentValue>

Convert to AgentValue::Number or AgentValue::Array of numbers.

Source

pub fn to_string(&self) -> Option<String>

Convert to String.

Source

pub fn to_string_value(&self) -> Option<AgentValue>

Convert to AgentValue::String or AgentValue::Array of strings.

Source

pub fn to_message(&self) -> Option<Message>

Convert to Message.

Source

pub fn to_message_value(&self) -> Option<AgentValue>

Convert to AgentValue::Message or AgentValue::Array of messages. If the value is an array, it recursively converts its elements.

Source

pub fn as_object(&self) -> Option<&AgentValueMap<String, AgentValue>>

Source

pub fn as_object_mut( &mut self, ) -> Option<&mut AgentValueMap<String, AgentValue>>

Source

pub fn into_object(self) -> Option<AgentValueMap<String, AgentValue>>

If self is an Object, extract the inner HashMap; otherwise, return None. This consumes self.

Source

pub fn as_array(&self) -> Option<&Vector<AgentValue>>

Source

pub fn as_array_mut(&mut self) -> Option<&mut Vector<AgentValue>>

Source

pub fn into_array(self) -> Option<Vector<AgentValue>>

If self is an Array, extract the inner Vector; otherwise, return None. This consumes self.

Source

pub fn as_tensor(&self) -> Option<&Vec<f32>>

Source

pub fn as_tensor_mut(&mut self) -> Option<&mut Vec<f32>>

Source

pub fn into_tensor(self) -> Option<Arc<Vec<f32>>>

If self is a Tensor, extract the inner Vec; otherwise, return None. This consumes self.

Source

pub fn into_tensor_vec(self) -> Option<Vec<f32>>

If self is a Tensor, extract the inner Vec; otherwise, return None.

This consumes self. Possibly O(n) copy.

Source

pub fn get(&self, key: &str) -> Option<&AgentValue>

Source

pub fn get_mut(&mut self, key: &str) -> Option<&mut AgentValue>

Source

pub fn get_bool(&self, key: &str) -> Option<bool>

Source

pub fn get_i64(&self, key: &str) -> Option<i64>

Source

pub fn get_f64(&self, key: &str) -> Option<f64>

Source

pub fn get_str(&self, key: &str) -> Option<&str>

Source

pub fn get_image(&self, key: &str) -> Option<&PhotonImage>

Source

pub fn get_image_mut(&mut self, key: &str) -> Option<&mut PhotonImage>

Source

pub fn get_object( &self, key: &str, ) -> Option<&AgentValueMap<String, AgentValue>>

Source

pub fn get_object_mut( &mut self, key: &str, ) -> Option<&mut AgentValueMap<String, AgentValue>>

Source

pub fn get_array(&self, key: &str) -> Option<&Vector<AgentValue>>

Source

pub fn get_array_mut(&mut self, key: &str) -> Option<&mut Vector<AgentValue>>

Source

pub fn get_tensor(&self, key: &str) -> Option<&Vec<f32>>

Source

pub fn get_tensor_mut(&mut self, key: &str) -> Option<&mut Vec<f32>>

Source

pub fn get_message(&self, key: &str) -> Option<&Message>

Source

pub fn get_message_mut(&mut self, key: &str) -> Option<&mut Message>

Source

pub fn set(&mut self, key: String, value: AgentValue) -> Result<(), AgentError>

Trait Implementations§

Source§

impl Clone for AgentValue

Source§

fn clone(&self) -> AgentValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AgentValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AgentValue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AgentValue

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&str> for AgentValue

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for AgentValue

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl From<AgentError> for AgentValue

Source§

fn from(value: AgentError) -> Self

Converts to this type from the input type.
Source§

impl From<Arc<Vec<f32>>> for AgentValue

Source§

fn from(value: Arc<Vec<f32>>) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, AgentValue>> for AgentValue

Source§

fn from(value: HashMap<String, AgentValue>) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, AgentValue>> for AgentValue

Source§

fn from(value: HashMap<String, AgentValue>) -> Self

Converts to this type from the input type.
Source§

impl From<Message> for AgentValue

Source§

fn from(msg: Message) -> Self

Converts to this type from the input type.
Source§

impl From<Option<AgentValue>> for AgentValue

Source§

fn from(value: Option<AgentValue>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for AgentValue

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<ToolInfo> for AgentValue

Source§

fn from(info: ToolInfo) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<AgentValue>> for AgentValue

Source§

fn from(value: Vec<AgentValue>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Message>> for AgentValue

Source§

fn from(msgs: Vec<Message>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<f32>> for AgentValue

Source§

fn from(value: Vec<f32>) -> Self

Converts to this type from the input type.
Source§

impl From<Vector<AgentValue>> for AgentValue

Source§

fn from(value: Vector<AgentValue>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for AgentValue

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for AgentValue

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for AgentValue

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for AgentValue

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for AgentValue

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for AgentValue

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for AgentValue

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for AgentValue

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for AgentValue

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<AgentValue> for Message

Source§

type Error = AgentError

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

fn try_from(value: AgentValue) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,