Skip to main content

AsyncRepository

Trait AsyncRepository 

Source
pub trait AsyncRepository {
    type Aggregate: AggregateRoot;
    type Error;

    // Required methods
    fn find_by_id<'a>(
        &'a self,
        id: &'a <Self::Aggregate as Entity>::Id,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Aggregate>, Self::Error>> + Send + 'a>>;
    fn save<'a>(
        &'a mut self,
        aggregate: &'a Self::Aggregate,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>;
    fn delete<'a>(
        &'a mut self,
        id: &'a <Self::Aggregate as Entity>::Id,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>;
    fn exists<'a>(
        &'a self,
        id: &'a <Self::Aggregate as Entity>::Id,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'a>>;
}
Expand description

English:
Provides asynchronous persistence operations for one aggregate type. Implementors supply storage behavior and its error type; returned futures borrow the repository and are Send.

日本語:
ひとつの集約型に対する非同期の永続化操作を提供します。実装側が保存処理とエラー型を 定義します。返される future はリポジトリを借用し、Send です。

Required Associated Types§

Source

type Aggregate: AggregateRoot

English:
Aggregate type managed by this repository.

日本語:
このリポジトリが管理する集約型です。

Source

type Error

English:
Error returned by persistence operations.

日本語:
永続化操作が返すエラー型です。

Required Methods§

Source

fn find_by_id<'a>( &'a self, id: &'a <Self::Aggregate as Entity>::Id, ) -> Pin<Box<dyn Future<Output = Result<Option<Self::Aggregate>, Self::Error>> + Send + 'a>>

English:
Loads an aggregate by identifier, returning Ok(None) when no matching aggregate exists and an error when the lookup fails.

日本語:
識別子で集約を読み込みます。一致する集約がなければ Ok(None)、検索に失敗すれば エラーを返します。

Source

fn save<'a>( &'a mut self, aggregate: &'a Self::Aggregate, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>

English:
Persists aggregate, returning an error if storage fails. Whether this inserts or updates is determined by the implementation.

日本語:
aggregate を永続化し、保存に失敗した場合はエラーを返します。新規登録か更新かは 実装によって決まります。

Source

fn delete<'a>( &'a mut self, id: &'a <Self::Aggregate as Entity>::Id, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>

English:
Removes the aggregate identified by id; returns an error if the operation fails. Behavior when the identifier is absent is implementation-defined.

日本語:
id で識別される集約を削除します。操作に失敗すればエラーを返し、識別子が存在しない 場合の動作は実装によって異なります。

Source

fn exists<'a>( &'a self, id: &'a <Self::Aggregate as Entity>::Id, ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'a>>

English:
Checks whether an aggregate with id exists, returning its presence or an error if the check fails.

日本語:
id の集約が存在するかを調べ、その有無または確認に失敗した場合のエラーを返します。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§