reifydb_core/interface/
execute.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use crate::{
5	Frame,
6	interface::{
7		CommandTransaction, Identity, Params, QueryTransaction, WithEventBus, interceptor::WithInterceptors,
8	},
9};
10
11#[derive(Debug)]
12pub struct Command<'a> {
13	pub rql: &'a str,
14	pub params: Params,
15	pub identity: &'a Identity,
16}
17
18#[derive(Debug)]
19pub struct Query<'a> {
20	pub rql: &'a str,
21	pub params: Params,
22	pub identity: &'a Identity,
23}
24
25pub trait Execute<CT: CommandTransaction + WithInterceptors<CT> + WithEventBus, QT: QueryTransaction>:
26	ExecuteCommand<CT> + ExecuteQuery<QT>
27{
28}
29
30pub trait ExecuteCommand<CT: CommandTransaction + WithInterceptors<CT> + WithEventBus> {
31	fn execute_command(&self, txn: &mut CT, cmd: Command<'_>) -> crate::Result<Vec<Frame>>;
32}
33
34pub trait ExecuteQuery<QT: QueryTransaction> {
35	fn execute_query(&self, txn: &mut QT, qry: Query<'_>) -> crate::Result<Vec<Frame>>;
36}