pub struct QueryResult {
pub columns: Vec<String>,
pub column_types: Vec<LogicalType>,
pub rows: Vec<Vec<Value>>,
pub execution_time_ms: Option<f64>,
pub rows_scanned: Option<u64>,
pub status_message: Option<String>,
pub gql_status: GqlStatus,
}Expand description
The result of running a query.
Contains rows and columns, like a table. Use iter() to
loop through rows, or scalar() if you expect a single value.
§Examples
use grafeo_engine::GrafeoDB;
let db = GrafeoDB::new_in_memory();
db.create_node(&["Person"]);
let result = db.execute("MATCH (p:Person) RETURN count(p) AS total")?;
// Check what we got
println!("Columns: {:?}", result.columns);
println!("Rows: {}", result.row_count());
// Iterate through results
for row in result.iter() {
println!("{:?}", row);
}Fields§
§columns: Vec<String>Column names from the RETURN clause.
column_types: Vec<LogicalType>Column types - useful for distinguishing NodeId/EdgeId from plain integers.
rows: Vec<Vec<Value>>The actual result rows.
execution_time_ms: Option<f64>Query execution time in milliseconds (if timing was enabled).
rows_scanned: Option<u64>Number of rows scanned during query execution (estimate).
status_message: Option<String>Status message for DDL and session commands (e.g., “Created node type ‘Person’”).
gql_status: GqlStatusGQLSTATUS code per ISO/IEC 39075:2024, sec 23.
Implementations§
Source§impl QueryResult
impl QueryResult
Sourcepub fn status(msg: impl Into<String>) -> Self
pub fn status(msg: impl Into<String>) -> Self
Creates a query result with only a status message (for DDL commands).
Sourcepub fn with_types(columns: Vec<String>, column_types: Vec<LogicalType>) -> Self
pub fn with_types(columns: Vec<String>, column_types: Vec<LogicalType>) -> Self
Creates a new empty query result with column types.
Sourcepub fn with_metrics(self, execution_time_ms: f64, rows_scanned: u64) -> Self
pub fn with_metrics(self, execution_time_ms: f64, rows_scanned: u64) -> Self
Sets the execution metrics on this result.
Sourcepub fn execution_time_ms(&self) -> Option<f64>
pub fn execution_time_ms(&self) -> Option<f64>
Returns the execution time in milliseconds, if available.
Sourcepub fn rows_scanned(&self) -> Option<u64>
pub fn rows_scanned(&self) -> Option<u64>
Returns the number of rows scanned, if available.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryResult
impl RefUnwindSafe for QueryResult
impl Send for QueryResult
impl Sync for QueryResult
impl Unpin for QueryResult
impl UnsafeUnpin for QueryResult
impl UnwindSafe for QueryResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more