Skip to main content

Scope

Trait Scope 

Source
pub(crate) trait Scope: Sized {
    type Errors: ErrorAccumulator;
    type Indent: IndentTracker;

    // Required methods
    fn indent(&self) -> impl Display;
    fn push_indent(&self) -> Self;
    fn options(&self) -> &OutputOptions;
    fn extensions(&self) -> &SimpleExtensions;
    fn extension_registry(&self) -> &ExtensionRegistry;
    fn errors(&self) -> &Self::Errors;

    // Provided methods
    fn push_error(&self, e: FormatError) { ... }
    fn failure<E: Into<FormatError>>(&self, e: E) -> ErrorToken { ... }
    fn expect<'a, T: Textify>(
        &'a self,
        t: Option<&'a T>,
    ) -> MaybeToken<impl Display> { ... }
    fn display<'a, T: Textify>(
        &'a self,
        value: &'a T,
    ) -> Displayable<'a, Self, T> { ... }
    fn separated<'a, T: Textify, I: IntoIterator<Item = &'a T> + Clone>(
        &'a self,
        items: I,
        separator: &'static str,
    ) -> Separated<'a, Self, T, I> { ... }
    fn optional<'a, T: Textify>(
        &'a self,
        value: &'a T,
        option: bool,
    ) -> OptionalDisplayable<'a, Self, T> { ... }
}
Expand description

Holds the context for outputting a plan.

This includes:

The Scope trait is used to provide the context for textifying a plan.

Required Associated Types§

Source

type Errors: ErrorAccumulator

The type of errors that can occur when textifying a plan.

Source

type Indent: IndentTracker

Required Methods§

Source

fn indent(&self) -> impl Display

Get the current indent level.

Source

fn push_indent(&self) -> Self

Push a new indent level.

Source

fn options(&self) -> &OutputOptions

Get the options for formatting the plan.

Source

fn extensions(&self) -> &SimpleExtensions

Source

fn extension_registry(&self) -> &ExtensionRegistry

Get the extension registry

Source

fn errors(&self) -> &Self::Errors

Provided Methods§

Source

fn push_error(&self, e: FormatError)

Source

fn failure<E: Into<FormatError>>(&self, e: E) -> ErrorToken

Handle a failure to textify a value. Textify errors are written as “!{name}” to the output (where “name” is the type name), and the error is pushed to the error accumulator.

Source

fn expect<'a, T: Textify>( &'a self, t: Option<&'a T>, ) -> MaybeToken<impl Display>

Source

fn display<'a, T: Textify>(&'a self, value: &'a T) -> Displayable<'a, Self, T>

Source

fn separated<'a, T: Textify, I: IntoIterator<Item = &'a T> + Clone>( &'a self, items: I, separator: &'static str, ) -> Separated<'a, Self, T, I>

Wrap an iterator over textifiable items into a displayable that will separate them with the given separator.

§Example
let items = vec![1, 2, 3];
let separated = self.separated(&items, ", ");
Source

fn optional<'a, T: Textify>( &'a self, value: &'a T, option: bool, ) -> OptionalDisplayable<'a, Self, T>

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.

Implementors§