Skip to main content

icydb_core/db/executor/
query_plan.rs

1use crate::{
2    db::{
3        executor::ExecutablePlan,
4        query::{
5            fluent::{delete::FluentDeleteQuery, load::FluentLoadQuery},
6            intent::{PlannedQuery, Query, QueryError},
7        },
8    },
9    traits::EntityKind,
10};
11
12impl<E: EntityKind> From<PlannedQuery<E>> for ExecutablePlan<E> {
13    fn from(value: PlannedQuery<E>) -> Self {
14        Self::new(value.into_inner())
15    }
16}
17
18impl<E: EntityKind> Query<E> {
19    /// Compile this logical planned query into executor runtime state.
20    pub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError> {
21        self.planned().map(ExecutablePlan::from)
22    }
23}
24
25impl<E: EntityKind> FluentLoadQuery<'_, E> {
26    /// Compile this fluent load intent into executor runtime state.
27    pub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError> {
28        self.planned().map(ExecutablePlan::from)
29    }
30}
31
32impl<E: EntityKind> FluentDeleteQuery<'_, E> {
33    /// Compile this fluent delete intent into executor runtime state.
34    pub fn plan(&self) -> Result<ExecutablePlan<E>, QueryError> {
35        self.planned().map(ExecutablePlan::from)
36    }
37}