pub trait State: Send + Sync {
// Required methods
fn get(&self, key: &str) -> Option<Value>;
fn set(&mut self, key: String, value: Value);
fn all(&self) -> HashMap<String, Value>;
}Expand description
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling Mutable session state with key-value storage.
Implementations persist state across turns within a session.
Required Methods§
Sourcefn get(&self, key: &str) -> Option<Value>
fn get(&self, key: &str) -> Option<Value>
Returns the value for the given key, or None if not present.
Sourcefn set(&mut self, key: String, value: Value)
fn set(&mut self, key: String, value: Value)
Set a state value. Implementations should call validate_state_key and
reject invalid keys (e.g., by logging a warning or panicking).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".