pub struct AgentConfigs(/* private fields */);Expand description
Configuration container for an agent.
Holds configuration values in key-value format and provides type-safe accessor methods.
Configuration parameters defined with #[modular_agent] macro are stored in this struct.
Implementations§
Source§impl AgentConfigs
impl AgentConfigs
Sourcepub fn set(&mut self, key: String, value: AgentValue)
pub fn set(&mut self, key: String, value: AgentValue)
Sets a configuration value.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the configuration contains the specified key.
Sourcepub fn get(&self, key: &str) -> Result<&AgentValue, AgentError>
pub fn get(&self, key: &str) -> Result<&AgentValue, AgentError>
Sourcepub fn get_bool(&self, key: &str) -> Result<bool, AgentError>
pub fn get_bool(&self, key: &str) -> Result<bool, AgentError>
Gets a boolean configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to boolean.
Sourcepub fn get_bool_or(&self, key: &str, default: bool) -> bool
pub fn get_bool_or(&self, key: &str, default: bool) -> bool
Gets a boolean configuration value, or the specified default if not found.
Sourcepub fn get_bool_or_default(&self, key: &str) -> bool
pub fn get_bool_or_default(&self, key: &str) -> bool
Gets a boolean configuration value, or false if not found.
Sourcepub fn get_integer(&self, key: &str) -> Result<i64, AgentError>
pub fn get_integer(&self, key: &str) -> Result<i64, AgentError>
Gets an integer configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to integer.
Sourcepub fn get_integer_or(&self, key: &str, default: i64) -> i64
pub fn get_integer_or(&self, key: &str, default: i64) -> i64
Gets an integer configuration value, or the specified default if not found.
Sourcepub fn get_integer_or_default(&self, key: &str) -> i64
pub fn get_integer_or_default(&self, key: &str) -> i64
Gets an integer configuration value, or 0 if not found.
Sourcepub fn get_number(&self, key: &str) -> Result<f64, AgentError>
pub fn get_number(&self, key: &str) -> Result<f64, AgentError>
Gets a number (f64) configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to number.
Sourcepub fn get_number_or(&self, key: &str, default: f64) -> f64
pub fn get_number_or(&self, key: &str, default: f64) -> f64
Gets a number configuration value, or the specified default if not found.
Sourcepub fn get_number_or_default(&self, key: &str) -> f64
pub fn get_number_or_default(&self, key: &str) -> f64
Gets a number configuration value, or 0.0 if not found.
Sourcepub fn get_string(&self, key: &str) -> Result<String, AgentError>
pub fn get_string(&self, key: &str) -> Result<String, AgentError>
Gets a string configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to string.
Sourcepub fn get_string_or(&self, key: &str, default: impl Into<String>) -> String
pub fn get_string_or(&self, key: &str, default: impl Into<String>) -> String
Gets a string configuration value, or the specified default if not found.
Sourcepub fn get_string_or_default(&self, key: &str) -> String
pub fn get_string_or_default(&self, key: &str) -> String
Gets a string configuration value, or an empty string if not found.
Sourcepub fn get_array(&self, key: &str) -> Result<&Vector<AgentValue>, AgentError>
pub fn get_array(&self, key: &str) -> Result<&Vector<AgentValue>, AgentError>
Gets an array configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to array.
Sourcepub fn get_array_or<'a>(
&'a self,
key: &str,
default: &'a Vector<AgentValue>,
) -> &'a Vector<AgentValue>
pub fn get_array_or<'a>( &'a self, key: &str, default: &'a Vector<AgentValue>, ) -> &'a Vector<AgentValue>
Gets an array configuration value, or the specified default if not found.
Sourcepub fn get_array_or_default(&self, key: &str) -> Vector<AgentValue>
pub fn get_array_or_default(&self, key: &str) -> Vector<AgentValue>
Gets an array configuration value, or an empty array if not found.
Sourcepub fn get_object(
&self,
key: &str,
) -> Result<&AgentValueMap<String, AgentValue>, AgentError>
pub fn get_object( &self, key: &str, ) -> Result<&AgentValueMap<String, AgentValue>, AgentError>
Gets an object configuration value.
§Errors
Returns UnknownConfig if the key does not exist or cannot be converted to object.
Sourcepub fn get_object_or<'a>(
&'a self,
key: &str,
default: &'a AgentValueMap<String, AgentValue>,
) -> &'a AgentValueMap<String, AgentValue>
pub fn get_object_or<'a>( &'a self, key: &str, default: &'a AgentValueMap<String, AgentValue>, ) -> &'a AgentValueMap<String, AgentValue>
Gets an object configuration value, or the specified default if not found.
Sourcepub fn get_object_or_default(
&self,
key: &str,
) -> AgentValueMap<String, AgentValue>
pub fn get_object_or_default( &self, key: &str, ) -> AgentValueMap<String, AgentValue>
Gets an object configuration value, or an empty object if not found.
Sourcepub fn keys(&self) -> Keys<'_, String, AgentValue>
pub fn keys(&self) -> Keys<'_, String, AgentValue>
Returns an iterator over the configuration keys.
Sourcepub fn remove(&mut self, key: &str) -> Option<AgentValue>
pub fn remove(&mut self, key: &str) -> Option<AgentValue>
Removes a configuration value by key, returning the value if it existed.
Uses shift_remove to preserve insertion order.
Trait Implementations§
Source§impl Clone for AgentConfigs
impl Clone for AgentConfigs
Source§fn clone(&self) -> AgentConfigs
fn clone(&self) -> AgentConfigs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentConfigs
impl Debug for AgentConfigs
Source§impl Default for AgentConfigs
impl Default for AgentConfigs
Source§fn default() -> AgentConfigs
fn default() -> AgentConfigs
Source§impl<'de> Deserialize<'de> for AgentConfigs
impl<'de> Deserialize<'de> for AgentConfigs
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<'a> FromIterator<(&'a String, &'a AgentValue)> for AgentConfigs
impl<'a> FromIterator<(&'a String, &'a AgentValue)> for AgentConfigs
Source§fn from_iter<T: IntoIterator<Item = (&'a String, &'a AgentValue)>>(
iter: T,
) -> Self
fn from_iter<T: IntoIterator<Item = (&'a String, &'a AgentValue)>>( iter: T, ) -> Self
Source§impl FromIterator<(String, AgentValue)> for AgentConfigs
impl FromIterator<(String, AgentValue)> for AgentConfigs
Source§fn from_iter<T: IntoIterator<Item = (String, AgentValue)>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = (String, AgentValue)>>(iter: T) -> Self
Source§impl<'a> IntoIterator for &'a AgentConfigs
impl<'a> IntoIterator for &'a AgentConfigs
Source§impl IntoIterator for AgentConfigs
impl IntoIterator for AgentConfigs
Auto Trait Implementations§
impl Freeze for AgentConfigs
impl RefUnwindSafe for AgentConfigs
impl Send for AgentConfigs
impl Sync for AgentConfigs
impl Unpin for AgentConfigs
impl UnsafeUnpin for AgentConfigs
impl UnwindSafe for AgentConfigs
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