pub trait Explain<'a>: 'a {
type Context;
type Text: DisplayText;
type Json: DisplayJson;
type Dot: DisplayDot;
// Provided methods
fn explain(
&'a mut self,
format: &'a ExplainFormat,
context: &'a Self::Context,
) -> Result<String, ExplainError> { ... }
fn explain_text(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Text, ExplainError> { ... }
fn explain_json(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Json, ExplainError> { ... }
fn explain_dot(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Dot, ExplainError> { ... }
}
Expand description
A trait that provides a unified interface for objects that can be explained.
All possible subjects of the various forms of an EXPLAIN
SQL statement should implement this trait.
Required Associated Types§
sourcetype Text: DisplayText
type Text: DisplayText
The explanation type produced by a successful
Explain::explain_text
call.
sourcetype Json: DisplayJson
type Json: DisplayJson
The explanation type produced by a successful
Explain::explain_json
call.
sourcetype Dot: DisplayDot
type Dot: DisplayDot
The explanation type produced by a successful
Explain::explain_json
call.
Provided Methods§
sourcefn explain(
&'a mut self,
format: &'a ExplainFormat,
context: &'a Self::Context,
) -> Result<String, ExplainError>
fn explain( &'a mut self, format: &'a ExplainFormat, context: &'a Self::Context, ) -> Result<String, ExplainError>
Explain an instance of Self
within the given
Explain::Context
.
Implementors should never have the need to not rely on this default implementation.
§Errors
If the given format
is not supported, the implementation
should return an ExplainError::UnsupportedFormat
.
If an ExplainConfig
parameter cannot be honored, the
implementation should silently ignore this parameter and
proceed without returning a Result::Err
.
sourcefn explain_text(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Text, ExplainError>
fn explain_text( &'a mut self, context: &'a Self::Context, ) -> Result<Self::Text, ExplainError>
Construct a Result::Ok
of the Explain::Text
format
from the config and the context.
§Errors
If the ExplainFormat::Text
is not supported, the implementation
should return an ExplainError::UnsupportedFormat
.
If an ExplainConfig
parameter cannot be honored, the
implementation should silently ignore this parameter and
proceed without returning a Result::Err
.
sourcefn explain_json(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Json, ExplainError>
fn explain_json( &'a mut self, context: &'a Self::Context, ) -> Result<Self::Json, ExplainError>
Construct a Result::Ok
of the Explain::Json
format
from the config and the context.
§Errors
If the ExplainFormat::Text
is not supported, the implementation
should return an ExplainError::UnsupportedFormat
.
If an ExplainConfig
parameter cannot be honored, the
implementation should silently ignore this parameter and
proceed without returning a Result::Err
.
sourcefn explain_dot(
&'a mut self,
context: &'a Self::Context,
) -> Result<Self::Dot, ExplainError>
fn explain_dot( &'a mut self, context: &'a Self::Context, ) -> Result<Self::Dot, ExplainError>
Construct a Result::Ok
of the Explain::Dot
format
from the config and the context.
§Errors
If the ExplainFormat::Dot
is not supported, the implementation
should return an ExplainError::UnsupportedFormat
.
If an ExplainConfig
parameter cannot be honored, the
implementation should silently ignore this parameter and
proceed without returning a Result::Err
.