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
impl AgentValue
pub fn unit() -> Self
pub fn boolean(value: bool) -> Self
pub fn integer(value: i64) -> Self
pub fn number(value: f64) -> Self
pub fn string(value: impl Into<String>) -> Self
pub fn image(value: PhotonImage) -> Self
pub fn image_arc(value: Arc<PhotonImage>) -> Self
pub fn array(value: Vector<AgentValue>) -> Self
pub fn object(value: AgentValueMap<String, AgentValue>) -> Self
pub fn tensor(value: Vec<f32>) -> Self
pub fn message(value: Message) -> Self
pub fn boolean_default() -> Self
pub fn integer_default() -> Self
pub fn number_default() -> Self
pub fn string_default() -> Self
pub fn image_default() -> Self
pub fn array_default() -> Self
pub fn object_default() -> Self
pub fn tensor_default() -> Self
pub fn from_json(value: Value) -> Result<Self, AgentError>
pub fn to_json(&self) -> Value
Sourcepub fn from_serialize<T: Serialize>(value: &T) -> Result<Self, AgentError>
pub fn from_serialize<T: Serialize>(value: &T) -> Result<Self, AgentError>
Create AgentValue from Serialize
Sourcepub fn to_deserialize<T: for<'de> Deserialize<'de>>(
&self,
) -> Result<T, AgentError>
pub fn to_deserialize<T: for<'de> Deserialize<'de>>( &self, ) -> Result<T, AgentError>
Convert AgentValue to a Deserialize
pub fn is_unit(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_integer(&self) -> bool
pub fn is_number(&self) -> bool
pub fn is_string(&self) -> bool
pub fn is_image(&self) -> bool
pub fn is_array(&self) -> bool
pub fn is_object(&self) -> bool
pub fn is_tensor(&self) -> bool
pub fn is_message(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn as_i64(&self) -> Option<i64>
pub fn as_f64(&self) -> Option<f64>
pub fn as_str(&self) -> Option<&str>
pub fn as_image(&self) -> Option<&PhotonImage>
Sourcepub fn as_image_mut(&mut self) -> Option<&mut PhotonImage>
pub fn as_image_mut(&mut self) -> Option<&mut PhotonImage>
If self is an Image, get a mutable reference to the inner PhotonImage.
Sourcepub fn into_image(self) -> Option<Arc<PhotonImage>>
pub fn into_image(self) -> Option<Arc<PhotonImage>>
If self is an Image, extract the inner PhotonImage; otherwise, return None. This consumes self.
pub fn as_message(&self) -> Option<&Message>
pub fn as_message_mut(&mut self) -> Option<&mut Message>
pub fn into_message(self) -> Option<Arc<Message>>
Sourcepub fn to_boolean(&self) -> Option<bool>
pub fn to_boolean(&self) -> Option<bool>
Convert to Boolean.
Sourcepub fn to_boolean_value(&self) -> Option<AgentValue>
pub fn to_boolean_value(&self) -> Option<AgentValue>
Convert to AgentValue::Boolean or AgentValue::Array of booleans.
Sourcepub fn to_integer(&self) -> Option<i64>
pub fn to_integer(&self) -> Option<i64>
Convert to Integer (i64).
Sourcepub fn to_integer_value(&self) -> Option<AgentValue>
pub fn to_integer_value(&self) -> Option<AgentValue>
Convert to AgentValue::Integer or AgentValue::Array of integers.
Sourcepub fn to_number_value(&self) -> Option<AgentValue>
pub fn to_number_value(&self) -> Option<AgentValue>
Convert to AgentValue::Number or AgentValue::Array of numbers.
Sourcepub fn to_string_value(&self) -> Option<AgentValue>
pub fn to_string_value(&self) -> Option<AgentValue>
Convert to AgentValue::String or AgentValue::Array of strings.
Sourcepub fn to_message(&self) -> Option<Message>
pub fn to_message(&self) -> Option<Message>
Convert to Message.
Sourcepub fn to_message_value(&self) -> Option<AgentValue>
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.
pub fn as_object(&self) -> Option<&AgentValueMap<String, AgentValue>>
pub fn as_object_mut( &mut self, ) -> Option<&mut AgentValueMap<String, AgentValue>>
Sourcepub fn into_object(self) -> Option<AgentValueMap<String, AgentValue>>
pub fn into_object(self) -> Option<AgentValueMap<String, AgentValue>>
If self is an Object, extract the inner HashMap; otherwise, return None. This consumes self.
pub fn as_array(&self) -> Option<&Vector<AgentValue>>
pub fn as_array_mut(&mut self) -> Option<&mut Vector<AgentValue>>
Sourcepub fn into_array(self) -> Option<Vector<AgentValue>>
pub fn into_array(self) -> Option<Vector<AgentValue>>
If self is an Array, extract the inner Vector; otherwise, return None. This consumes self.
pub fn as_tensor(&self) -> Option<&Vec<f32>>
pub fn as_tensor_mut(&mut self) -> Option<&mut Vec<f32>>
Sourcepub fn into_tensor(self) -> Option<Arc<Vec<f32>>>
pub fn into_tensor(self) -> Option<Arc<Vec<f32>>>
If self is a Tensor, extract the inner Vec; otherwise, return None. This consumes self.
Sourcepub fn into_tensor_vec(self) -> Option<Vec<f32>>
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.
pub fn get(&self, key: &str) -> Option<&AgentValue>
pub fn get_mut(&mut self, key: &str) -> Option<&mut AgentValue>
pub fn get_bool(&self, key: &str) -> Option<bool>
pub fn get_i64(&self, key: &str) -> Option<i64>
pub fn get_f64(&self, key: &str) -> Option<f64>
pub fn get_str(&self, key: &str) -> Option<&str>
pub fn get_image(&self, key: &str) -> Option<&PhotonImage>
pub fn get_image_mut(&mut self, key: &str) -> Option<&mut PhotonImage>
pub fn get_object( &self, key: &str, ) -> Option<&AgentValueMap<String, AgentValue>>
pub fn get_object_mut( &mut self, key: &str, ) -> Option<&mut AgentValueMap<String, AgentValue>>
pub fn get_array(&self, key: &str) -> Option<&Vector<AgentValue>>
pub fn get_array_mut(&mut self, key: &str) -> Option<&mut Vector<AgentValue>>
pub fn get_tensor(&self, key: &str) -> Option<&Vec<f32>>
pub fn get_tensor_mut(&mut self, key: &str) -> Option<&mut Vec<f32>>
pub fn get_message(&self, key: &str) -> Option<&Message>
pub fn get_message_mut(&mut self, key: &str) -> Option<&mut Message>
pub fn set(&mut self, key: String, value: AgentValue) -> Result<(), AgentError>
Trait Implementations§
Source§impl Clone for AgentValue
impl Clone for AgentValue
Source§fn clone(&self) -> AgentValue
fn clone(&self) -> AgentValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentValue
impl Debug for AgentValue
Source§impl Default for AgentValue
impl Default for AgentValue
Source§impl<'de> Deserialize<'de> for AgentValue
impl<'de> Deserialize<'de> for AgentValue
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<&str> for AgentValue
impl From<&str> for AgentValue
Source§impl From<()> for AgentValue
impl From<()> for AgentValue
Source§impl From<AgentError> for AgentValue
impl From<AgentError> for AgentValue
Source§fn from(value: AgentError) -> Self
fn from(value: AgentError) -> Self
Source§impl From<HashMap<String, AgentValue>> for AgentValue
impl From<HashMap<String, AgentValue>> for AgentValue
Source§impl From<HashMap<String, AgentValue>> for AgentValue
impl From<HashMap<String, AgentValue>> for AgentValue
Source§impl From<Message> for AgentValue
impl From<Message> for AgentValue
Source§impl From<Option<AgentValue>> for AgentValue
impl From<Option<AgentValue>> for AgentValue
Source§fn from(value: Option<AgentValue>) -> Self
fn from(value: Option<AgentValue>) -> Self
Source§impl From<String> for AgentValue
impl From<String> for AgentValue
Source§impl From<ToolInfo> for AgentValue
impl From<ToolInfo> for AgentValue
Source§impl From<Vec<AgentValue>> for AgentValue
impl From<Vec<AgentValue>> for AgentValue
Source§fn from(value: Vec<AgentValue>) -> Self
fn from(value: Vec<AgentValue>) -> Self
Source§impl From<Vector<AgentValue>> for AgentValue
impl From<Vector<AgentValue>> for AgentValue
Source§fn from(value: Vector<AgentValue>) -> Self
fn from(value: Vector<AgentValue>) -> Self
Source§impl From<bool> for AgentValue
impl From<bool> for AgentValue
Source§impl From<f32> for AgentValue
impl From<f32> for AgentValue
Source§impl From<f64> for AgentValue
impl From<f64> for AgentValue
Source§impl From<i32> for AgentValue
impl From<i32> for AgentValue
Source§impl From<i64> for AgentValue
impl From<i64> for AgentValue
Source§impl From<u64> for AgentValue
impl From<u64> for AgentValue
Source§impl From<usize> for AgentValue
impl From<usize> for AgentValue
Source§impl PartialEq for AgentValue
impl PartialEq for AgentValue
Source§impl Serialize for AgentValue
impl Serialize for AgentValue
Source§impl TryFrom<AgentValue> for Message
impl TryFrom<AgentValue> for Message
Source§type Error = AgentError
type Error = AgentError
Auto Trait Implementations§
impl Freeze for AgentValue
impl RefUnwindSafe for AgentValue
impl Send for AgentValue
impl Sync for AgentValue
impl Unpin for AgentValue
impl UnwindSafe for AgentValue
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more