reifydb_core/interface/
execute.rs1use async_trait::async_trait;
5
6use crate::{
7 Frame,
8 interface::{
9 CommandTransaction, Identity, Params, QueryTransaction, WithEventBus, interceptor::WithInterceptors,
10 },
11};
12
13#[derive(Debug)]
14pub struct Command<'a> {
15 pub rql: &'a str,
16 pub params: Params,
17 pub identity: &'a Identity,
18}
19
20#[derive(Debug)]
21pub struct Query<'a> {
22 pub rql: &'a str,
23 pub params: Params,
24 pub identity: &'a Identity,
25}
26
27pub trait Execute<CT: CommandTransaction + WithInterceptors<CT> + WithEventBus, QT: QueryTransaction>:
28 ExecuteCommand<CT> + ExecuteQuery<QT>
29{
30}
31
32#[async_trait]
33pub trait ExecuteCommand<CT: CommandTransaction + WithInterceptors<CT> + WithEventBus> {
34 async fn execute_command(&self, txn: &mut CT, cmd: Command<'_>) -> crate::Result<Vec<Frame>>;
35}
36
37#[async_trait]
38pub trait ExecuteQuery<QT: QueryTransaction> {
39 async fn execute_query(&self, txn: &mut QT, qry: Query<'_>) -> crate::Result<Vec<Frame>>;
40}