Expand description
Unified byte storage.
Storage persists raw bytes under string keys. Every SDK subsystem that needs persistence
(sessions, memory, context offloading) consumes it. The SDK ships InMemoryStorage and
LocalFileStorage; namespace scopes any backend under a key prefix (through its own
namespacing or a NamespacedStorage), and search holds the pluggable search strategies.
use strands::storage::{InMemoryStorage, Storage};
let storage = InMemoryStorage::new();
storage.write("memory/notes.json", b"[]").await?;
assert_eq!(storage.read("memory/notes.json").await?, Some(b"[]".to_vec()));
assert_eq!(storage.list("memory/").await?, ["memory/notes.json"]);Re-exports§
pub use search::StorageSearchResult;
Modules§
- search
- Pluggable search strategies for storage backends.
Structs§
- InMemory
Storage Storagebacked by a map in memory (InMemoryStorage).- InMemory
Storage Config - Options for
InMemoryStorage(InMemoryStorageConfig). - InMemory
Storage Config Builder - Use builder syntax to set the inputs and finish with
build(). - Local
File Storage Storagethat keeps each key as a file under a base directory (LocalFileStorage).- Local
File Storage Config - Options for
LocalFileStorage(LocalFileStorageConfig). - Local
File Storage Config Builder - Use builder syntax to set the inputs and finish with
build(). - Namespaced
Storage - A view of a
Storagewith every key prefixed by a namespace.
Traits§
- Into
Storage - What the builders’
storage(..)setters take: a storage by value, anArcof one, or anArc<dyn Storage>(kept as is, so the agent’sstorageis the same instance). - Storage
- A backend for storing and retrieving raw bytes under string keys (
Storage).
Functions§
- namespace
- A view of
storagewith every key underprefix(namespace): the backend’s ownStorage::namespacewhen it has one, aNamespacedStorageotherwise. This is the form to use on anArc<dyn Storage>, where the trait method returnsNonefor backends without namespacing.