use async_trait::async_trait;
use crate::document::DocumentId;
use crate::identity::PublicKey;
use crate::operation::traits::{AsOperation, WithPublicKey};
use crate::operation::{Operation, OperationId};
use crate::schema::SchemaId;
use crate::storage_provider::error::OperationStorageError;
use crate::WithId;
#[async_trait]
pub trait OperationStore {
type Operation: AsOperation + WithId<OperationId> + WithId<DocumentId> + WithPublicKey + Sync;
async fn insert_operation(
&self,
id: &OperationId,
public_key: &PublicKey,
operation: &Operation,
document_id: &DocumentId,
) -> Result<(), OperationStorageError>;
async fn get_operation(
&self,
id: &OperationId,
) -> Result<Option<Self::Operation>, OperationStorageError>;
async fn get_document_id_by_operation_id(
&self,
id: &OperationId,
) -> Result<Option<DocumentId>, OperationStorageError>;
async fn get_operations_by_document_id(
&self,
id: &DocumentId,
) -> Result<Vec<Self::Operation>, OperationStorageError>;
async fn get_operations_by_schema_id(
&self,
id: &SchemaId,
) -> Result<Vec<Self::Operation>, OperationStorageError>;
}