Skip to main content

reifydb_core/
execution.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2026 ReifyDB
3
4use std::ops::Deref;
5
6use reifydb_value::{error::Error, value::frame::frame::Frame};
7
8use crate::metric::ExecutionMetrics;
9
10#[derive(Debug)]
11pub struct ExecutionResult {
12	pub frames: Vec<Frame>,
13	pub error: Option<Error>,
14	pub metrics: ExecutionMetrics,
15}
16
17impl ExecutionResult {
18	pub fn from_error(error: Error) -> Self {
19		Self {
20			frames: vec![],
21			error: Some(error),
22			metrics: ExecutionMetrics::default(),
23		}
24	}
25
26	pub fn is_ok(&self) -> bool {
27		self.error.is_none()
28	}
29
30	pub fn is_err(&self) -> bool {
31		self.error.is_some()
32	}
33
34	pub fn check(self) -> Result<Self, Error> {
35		match self.error {
36			Some(e) => Err(e),
37			None => Ok(self),
38		}
39	}
40}
41
42impl Deref for ExecutionResult {
43	type Target = [Frame];
44
45	fn deref(&self) -> &[Frame] {
46		&self.frames
47	}
48}