Skip to main content

ExplainTrace

Struct ExplainTrace 

Source
pub struct ExplainTrace { /* private fields */ }
Expand description

EXPLAIN / EXPLAIN ANALYZE trace handle.

This is an in-flight type and is !Send + !Sync (thread-affine). Dropping it closes the underlying runtime trace handle.

All strings exposed by this type are copied into owned Rust Strings before being returned.

Implementations§

Source§

impl ExplainTrace

Source

pub fn plan_count(&self) -> Result<usize>

Return the number of top-level plans in this trace.

§Errors

Returns an Error if the runtime API cannot be loaded.

Source

pub fn plan_meta(&self, plan_idx: usize) -> Result<ExplainPlanMeta>

Fetch metadata for one plan.

§Errors

Returns an Error if:

  • the runtime API cannot be loaded
  • plan_idx is out of range
  • returned string fields are not valid UTF-8
Source

pub fn step_count(&self, plan_idx: usize) -> Result<usize>

Return the number of steps in a plan.

This is a convenience wrapper over ExplainTrace::plan_meta.

§Errors

Returns an Error if plan_idx is out of range or metadata decoding fails.

Source

pub fn step_meta( &self, plan_idx: usize, step_idx: usize, ) -> Result<ExplainStepMeta>

Fetch metadata for one step.

§Errors

Returns an Error if:

  • the runtime API cannot be loaded
  • plan_idx or step_idx is out of range
  • returned string fields are not valid UTF-8
Source

pub fn statement_count(&self, plan_idx: usize, step_idx: usize) -> Result<usize>

Return the number of statements in a step.

This is a convenience wrapper over ExplainTrace::step_meta.

§Errors

Returns an Error if plan_idx / step_idx are out of range or metadata decoding fails.

Source

pub fn statement_meta( &self, plan_idx: usize, step_idx: usize, stmt_idx: usize, ) -> Result<ExplainStatementMeta>

Fetch metadata for one statement.

§Errors

Returns an Error if:

  • the runtime API cannot be loaded
  • plan_idx, step_idx, or stmt_idx is out of range
  • returned string fields are not valid UTF-8
Source

pub fn sqlite_plan_count( &self, plan_idx: usize, step_idx: usize, stmt_idx: usize, ) -> Result<usize>

Return the number of SQLite query-plan detail lines for one statement.

This is a convenience wrapper over ExplainTrace::statement_meta.

§Errors

Returns an Error if indices are out of range or metadata decoding fails.

Source

pub fn sqlite_plan_detail( &self, plan_idx: usize, step_idx: usize, stmt_idx: usize, detail_idx: usize, ) -> Result<String>

Fetch one SQLite query-plan detail line.

§Errors

Returns an Error if:

  • the runtime API cannot be loaded
  • any index is out of range
  • the returned detail line is not valid UTF-8
Source

pub fn sqlite_plan_details( &self, plan_idx: usize, step_idx: usize, stmt_idx: usize, ) -> Result<Vec<String>>

Fetch all SQLite query-plan detail lines for one statement.

§Errors

Returns an Error if indices are out of range or any returned detail line cannot be decoded.

Source

pub fn snapshot(&self) -> Result<Vec<ExplainPlan>>

Materialize the entire trace into owned Rust structs.

This walks all plans, steps, statements, and SQLite plan details and returns a fully owned snapshot detached from the borrowed runtime string views.

§Errors

Returns an Error if any nested metadata/detail lookup fails.

Source

pub fn compact_len(&self) -> Result<usize>

Return the size in bytes of the compact rendering.

The compact rendering is UTF-8 text, but this method returns the raw byte count.

§Errors

Returns an Error if the runtime API cannot be loaded or the runtime fails to render the compact form.

Source

pub fn to_compact_bytes(&self) -> Result<Vec<u8>>

Render the trace to compact UTF-8 bytes.

The returned bytes are owned by Rust and independent of the runtime buffer.

§Errors

Returns an Error if:

  • the runtime API cannot be loaded
  • the runtime fails to render the compact form
  • the runtime returns an invalid null/non-null pointer + length combination
Source

pub fn to_compact_string(&self) -> Result<String>

Render the trace to a compact UTF-8 string.

§Errors

Returns an Error if the compact rendering cannot be produced or if the returned bytes are not valid UTF-8.

Source

pub fn write_compact(&self, out: impl Write) -> Result<()>

Write the compact rendering into any Rust writer.

§Errors

Returns an Error if rendering fails or if writing to out fails.

Trait Implementations§

Source§

impl Drop for ExplainTrace

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.