pub trait ControlStore: Send + Sync {
// Required methods
fn area_settings<'life0, 'life1, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AreaSettings>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list_area_settings<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AreaSettings>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn put_area_settings<'life0, 'async_trait>(
&'life0 self,
settings: AreaSettings,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn cursor<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 str,
viewer: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AwayCursor>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn advance_cursor<'life0, 'async_trait>(
&'life0 self,
cursor: AwayCursor,
) -> Pin<Box<dyn Future<Output = Result<AwayCursor>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn update_area_settings<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
change: &'life2 (dyn for<'a> Fn(&'a mut AreaSettings) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<AreaSettings>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Where the control plane keeps AreaSettings and AwayCursors (spec 3.3 §10 K3,
K4).
| Method | Contract |
|---|---|
area_settings, list_area_settings | One area’s record, or every one ordered by partition id |
put_area_settings | Replaces the area’s record |
update_area_settings | Changes the area’s record with no other write in between, so concurrent changes all hold |
cursor | One viewer’s cursor |
advance_cursor | Stores the cursor unless the stored one is past its seq, and returns the stored one: a cursor never moves back |
§Example
use adk_kernel::control::{AwayCursor, ControlStore, InMemoryControlStore};
let store = InMemoryControlStore::new();
let now = chrono::Utc::now();
store.advance_cursor(AwayCursor::new("ana", "home", 9, now)).await?;
let stored = store.advance_cursor(AwayCursor::new("ana", "home", 4, now)).await?;
assert_eq!(stored.seq, 9, "a cursor never moves back");Required Methods§
Sourcefn area_settings<'life0, 'life1, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AreaSettings>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn area_settings<'life0, 'life1, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
) -> Pin<Box<dyn Future<Output = Result<Option<AreaSettings>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The settings changed for partition, or None.
§Errors
Returns KernelError::Store when the backend fails.
Sourcefn list_area_settings<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AreaSettings>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_area_settings<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<AreaSettings>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Every area’s changed settings, ordered by partition id.
§Errors
Returns KernelError::Store when the backend fails.
Sourcefn put_area_settings<'life0, 'async_trait>(
&'life0 self,
settings: AreaSettings,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put_area_settings<'life0, 'async_trait>(
&'life0 self,
settings: AreaSettings,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Replaces the changed settings of settings.partition.
§Errors
Returns KernelError::Store when the backend fails.
Sourcefn cursor<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 str,
viewer: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AwayCursor>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cursor<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
user: &'life1 str,
viewer: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AwayCursor>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The cursor of viewer of user, or None before it first marks anything seen.
§Errors
Returns KernelError::Store when the backend fails.
Sourcefn advance_cursor<'life0, 'async_trait>(
&'life0 self,
cursor: AwayCursor,
) -> Pin<Box<dyn Future<Output = Result<AwayCursor>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn advance_cursor<'life0, 'async_trait>(
&'life0 self,
cursor: AwayCursor,
) -> Pin<Box<dyn Future<Output = Result<AwayCursor>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stores cursor when the stored cursor of its viewer is at or before its seq, and
returns the cursor stored after the call.
§Errors
Returns KernelError::Store when the backend fails.
Provided Methods§
Sourcefn update_area_settings<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
change: &'life2 (dyn for<'a> Fn(&'a mut AreaSettings) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<AreaSettings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn update_area_settings<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
partition: &'life1 PartitionId,
change: &'life2 (dyn for<'a> Fn(&'a mut AreaSettings) + Send + Sync),
) -> Pin<Box<dyn Future<Output = Result<AreaSettings>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Applies change to the record of partition, an empty one when it has none, and
stores it with no other write in between: when another write changed the record
meanwhile, change is applied again to that one, so concurrent changes of different
settings all hold (spec 3.3 §10 K3). Returns the record stored.
The default reads, applies and puts, which keeps that promise only for a store with one writer; every store of this crate overrides it.
§Errors
Returns KernelError::Store when the backend fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".