pub trait AsyncProjectionCheckpointStore: Send + Sync {
type Cursor: Send + Sync;
type Error: Send;
// Required methods
fn load<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<Option<ProjectionCheckpoint<Self::Cursor>>, Self::Error>> + Send + 'a>>;
fn save<'a>(
&'a mut self,
checkpoint: ProjectionCheckpoint<Self::Cursor>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>;
}Expand description
English:
Checkpoint persistence port returning boxed Send futures tied to the store borrow.
The store instance determines the projection scope, as in ProjectionCheckpointStore.
The store must be Send + Sync, the cursor Send + Sync, and the error Send; these bounds
do not provide locking, monotonic progress checks, or atomic read-model updates. Implementations
define durability, concurrent replacement, partial failures, and panic conditions.
Dropping a returned future ends that operation’s polling, but does not promise rollback or that no I/O occurred. Implementations may perform work before returning a future and must specify cancellation and retry behavior. This trait supplies no executor or transaction coordinator.
Await a write and then read its result; the adapter determines read-after-write consistency.
This helper returns None if the subsequent load reports no stored checkpoint.
日本語:
ストアの借用期間に結び付いた、ボックス化された Send Future を返す進捗永続化ポートです。
ProjectionCheckpointStore と同様に、プロジェクションの範囲はストアのインスタンスが定めます。
ストアには Send + Sync、カーソルには Send + Sync、エラーには Send が必要ですが、
これらの境界はロック、単調な進捗の検査、読み取りモデルの原子的更新を提供しません。
永続性、並行する置換、部分失敗、パニック条件は実装が定めます。
返された Future の破棄はその操作のポーリングを終了しますが、ロールバックや I/O が未実行であることを 保証しません。実装は Future を返す前にも処理でき、キャンセルと再試行の挙動を定める必要があります。 このトレイトは実行器やトランザクション調整器を提供しません。
書き込みを待ってから結果を読み込みます。書き込み後の読み取り整合性はアダプターが定めます。
後続の読み込みがチェックポイントの不在を報告した場合、このヘルパーは None を返します。
§Example / 使用例
use ddd_toolkit_core::{AsyncProjectionCheckpointStore, ProjectionCheckpoint};
async fn save_then_load<S: AsyncProjectionCheckpointStore>(
store: &mut S,
cursor: S::Cursor,
) -> Result<Option<S::Cursor>, S::Error> {
store.save(ProjectionCheckpoint::new(cursor)).await?;
Ok(store.load().await?.map(ProjectionCheckpoint::into_cursor))
}Required Associated Types§
Required Methods§
Sourcefn load<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<Option<ProjectionCheckpoint<Self::Cursor>>, Self::Error>> + Send + 'a>>
fn load<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<Option<ProjectionCheckpoint<Self::Cursor>>, Self::Error>> + Send + 'a>>
English:
Borrows the store for 'a and returns a future yielding owned stored progress.
Ok(None) means absence, while Err reports a read failure. Shared access permits multiple
load borrows but does not define snapshot isolation or freshness. Drop effects are adapter-defined.
日本語:
ストアを 'a の間借用し、所有された保存済み進捗を返す Future を返します。
Ok(None) は不在を表し、Err は読み込み失敗を表します。共有参照で複数の読み込みを借用できますが、
スナップショット分離や鮮度は定めません。破棄による効果はアダプターが定めます。
Sourcefn save<'a>(
&'a mut self,
checkpoint: ProjectionCheckpoint<Self::Cursor>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>
fn save<'a>( &'a mut self, checkpoint: ProjectionCheckpoint<Self::Cursor>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>
English:
Takes ownership of checkpoint and exclusively borrows the store for 'a.
The returned future reports Ok(()) or a write failure, without returning the checkpoint
on error or cancellation. No rollback, retry, or atomic coordination with a projection is added.
日本語:
checkpoint の所有権を受け取り、ストアを 'a の間排他的に借用します。
返す Future は Ok(()) または書き込み失敗を報告し、エラーやキャンセル時にチェックポイントを
返しません。ロールバック、再試行、プロジェクションとの原子的な連携は追加しません。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".