pub trait HumanizerMode: Sized + Clone {
// Required methods
fn new(redacted: bool) -> Self;
fn redacted(&self) -> bool;
fn humanize_ident(col: usize, ident: Ident, f: &mut Formatter<'_>) -> Result;
// Provided methods
fn default() -> Self { ... }
fn expr<'a, T>(
&self,
expr: &'a T,
cols: Option<&'a Vec<String>>,
) -> HumanizedExpr<'a, T, Self> { ... }
fn humanize_datum(&self, datum: Datum<'_>, f: &mut Formatter<'_>) -> Result { ... }
fn seq<'i, T>(
&self,
exprs: &'i [T],
cols: Option<&'i Vec<String>>,
) -> impl Iterator<Item = HumanizedExpr<'i, T, Self>> + Clone { ... }
}Expand description
A trait that abstracts the various ways in which we can humanize expressions.
Currently, the degrees of freedom are:
- Humanizing for an
EXPLAINoutput vs humanizing for a notice output. This is currently handled by the two different implementations of this trait -HumanizedExplainvsHumanizedNotice. - Humanizing with redacted or non-redacted literals. This is currently
covered by the
HumanizerMode::redactedmethod which is used by the default implementation ofHumanizerMode::humanize_datum.
Required Methods§
Provided Methods§
Sourcefn default() -> Self
fn default() -> Self
Default implementation of a default constructor.
This will produce a HumanizerMode instance that redacts output in
production deployments, but not in debug builds and in CI.
Sourcefn expr<'a, T>(
&self,
expr: &'a T,
cols: Option<&'a Vec<String>>,
) -> HumanizedExpr<'a, T, Self>
fn expr<'a, T>( &self, expr: &'a T, cols: Option<&'a Vec<String>>, ) -> HumanizedExpr<'a, T, Self>
Factory method that wraps the given expr and cols into a
HumanizedExpr with the current mode.
Sourcefn humanize_datum(&self, datum: Datum<'_>, f: &mut Formatter<'_>) -> Result
fn humanize_datum(&self, datum: Datum<'_>, f: &mut Formatter<'_>) -> Result
Render a literal datum.
The default implementation prints a redacted symbol (█) if redaction is enabled.
Sourcefn seq<'i, T>(
&self,
exprs: &'i [T],
cols: Option<&'i Vec<String>>,
) -> impl Iterator<Item = HumanizedExpr<'i, T, Self>> + Clone
fn seq<'i, T>( &self, exprs: &'i [T], cols: Option<&'i Vec<String>>, ) -> impl Iterator<Item = HumanizedExpr<'i, T, Self>> + Clone
Wrap the given exprs (with cols) into HumanizedExpr with the current mode.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.