Skip to main content

Module storage

Module storage 

Source
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§

InMemoryStorage
Storage backed by a map in memory (InMemoryStorage).
InMemoryStorageConfig
Options for InMemoryStorage (InMemoryStorageConfig).
InMemoryStorageConfigBuilder
Use builder syntax to set the inputs and finish with build().
LocalFileStorage
Storage that keeps each key as a file under a base directory (LocalFileStorage).
LocalFileStorageConfig
Options for LocalFileStorage (LocalFileStorageConfig).
LocalFileStorageConfigBuilder
Use builder syntax to set the inputs and finish with build().
NamespacedStorage
A view of a Storage with every key prefixed by a namespace.

Traits§

IntoStorage
What the builders’ storage(..) setters take: a storage by value, an Arc of one, or an Arc<dyn Storage> (kept as is, so the agent’s storage is the same instance).
Storage
A backend for storing and retrieving raw bytes under string keys (Storage).

Functions§

namespace
A view of storage with every key under prefix (namespace): the backend’s own Storage::namespace when it has one, a NamespacedStorage otherwise. This is the form to use on an Arc<dyn Storage>, where the trait method returns None for backends without namespacing.