Skip to main content

DirectCompiler

Struct DirectCompiler 

Source
pub struct DirectCompiler<Handle, Decoder = Parsed> { /* private fields */ }
Expand description

Compiles a CLI program into the commands run on a Handle, their words read by a Decoder.

CliDirect reads words with Parsed; another interpretation that parses its own way compiles with its own decoder. A context compiles its subtree with the compiler for the handle the context answers.

Implementations§

Source§

impl<Handle, Decoder> DirectCompiler<Handle, Decoder>

Source

pub fn selecting(name: &'static str) -> Self

Compiles only the commands beneath the first-layer name name, so no other command is described or decoded.

Trait Implementations§

Source§

impl<Handle, Decoder> CliCommandsAlg for DirectCompiler<Handle, Decoder>

Source§

type Commands = Vec<Entry<Handle, Decoder>>

The interpreter’s homogeneous command collection.
Source§

fn cli_empty(&self) -> Self::Commands

Returns the empty command collection.
Source§

fn cli_merge( &self, left: Self::Commands, right: Self::Commands, ) -> Self::Commands

Combines two command collections, left first.
Source§

impl<Handle, Decoder, Operation, Sources, Mode> CliContextAlg<Operation, Sources, Mode> for DirectCompiler<Handle, Decoder>
where Handle: Send + 'static, Decoder: 'static, Operation: OperationAlg + ApplyAlg<Handle, Operation::Args> + Send + Sync + 'static, Operation::Args: Send, Sources: CliSources<Operation::Args> + CliDecodeSources<Operation::Args, Decoder, String> + Send + Sync + 'static, Mode: CliOutcomeOf<Operation::Output> + Send + Sync + 'static, Mode::Value: Send + 'static, Mode::Error: Display + CliFailureAlg,

Applies a subtree’s commands to the handle the context operation answers.

The global arguments are decoded with the command’s own, so a usage error is reported before the context is opened; a context that fails ends the run with its status.

Source§

fn cli_inner(&self) -> Self::Inner

A context adds no path, so its subtree’s first layer is this one’s, selected alike.

Source§

type Inner = DirectCompiler<<Mode as CliOutcomeOf<<Operation as ApplyAlg<Handle, <Operation as OperationAlg>::Args>>::Output>>::Value, Decoder>

The interpreter compiling the subtree.
Source§

type InnerCommands = Vec<Entry<<Mode as CliOutcomeOf<<Operation as ApplyAlg<Handle, <Operation as OperationAlg>::Args>>::Output>>::Value, Decoder>>

The command collection the subtree compiles to.
Source§

type Commands = Vec<Entry<Handle, Decoder>>

The command collection this compiles the subtree into.
Source§

fn cli_within( &self, operation: Operation, sources: Sources, mode: Mode, commands: Self::InnerCommands, ) -> Self::Commands

Applies the subtree’s commands to the context operation answers from inputs.
Source§

impl<Handle, Decoder> CliNestAlg for DirectCompiler<Handle, Decoder>

Source§

fn cli_nest_with( &self, name: &'static str, compile: impl FnOnce(&Self) -> Self::Commands, ) -> Self::Commands

A selected name’s subtree compiles in full; any other compiles to nothing.

Source§

type Commands = Vec<Entry<Handle, Decoder>>

The command collection being nested.
Source§

fn cli_nest( &self, name: &'static str, commands: Self::Commands, ) -> Self::Commands

Places commands beneath name.
Source§

impl<Handle, Decoder, Operation, Sources, Mode> CliOperationAlg<Operation, Sources, Mode> for DirectCompiler<Handle, Decoder>
where Handle: Send + 'static, Decoder: 'static, Operation: OperationAlg + ApplyAlg<Handle, Operation::Args> + Send + Sync + 'static, Operation::Args: Send, Sources: CliSources<Operation::Args> + CliDecodeSources<Operation::Args, Decoder, String> + Send + Sync + 'static, Mode: CliOutcomeOf<Operation::Output> + Send + Sync + 'static, Mode::Value: DirectRender, Mode::Error: Display + CliFailureAlg,

Source§

type Commands = Vec<Entry<Handle, Decoder>>

The command collection one command compiles to.
Source§

fn cli_operation( &self, name: &'static str, operation: Operation, sources: Sources, mode: Mode, conventions: Conventions, ) -> Self::Commands

Registers operation under name, decoded through inputs from words read under conventions, its output read under mode.
Source§

impl<Handle, Decoder> Default for DirectCompiler<Handle, Decoder>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Handle, Decoder> Freeze for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> RefUnwindSafe for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> Send for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> Sync for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> Unpin for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> UnsafeUnpin for DirectCompiler<Handle, Decoder>

§

impl<Handle, Decoder> UnwindSafe for DirectCompiler<Handle, Decoder>

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<This> CliDeclarationLawsExt<This> for This

Source§

fn law_cli_declaration<Operation, Sources, Mode, Commands>( &self, name: &'static str, operation: Operation, sources: Sources, mode: Mode, conventions: Conventions, ) -> Result<(), &'static str>
where This: CliOperationAlg<Operation, Sources, Mode, Commands = Commands> + CliCommandsObserved<Commands = Commands>, Operation: OperationAlg, Sources: CliSources<<Operation as OperationAlg>::Args>,

Checks that operation declared under name with sources describes exactly that, with one argument per operation argument, in order, and distinct spellings and positions.

Source§

impl<This> CliOutcomeLawsExt<This> for This

Source§

fn law_cli_outcome<Output>(&self, output: Output) -> Result<(), &'static str>
where This: CliOutcomeOf<Output>, <This as CliOutcomeOf<Output>>::Error: CliFailureAlg,

Checks that output read under this mode exits with zero exactly when it succeeds.

Source§

impl<Source> CliPartsFor<ContextArg> for Source

Source§

const PARTS: &'static [&'static str]

The argument’s part names, in order.
Source§

const PART: &'static str = "part"

What one part is called: field or alternative.
Source§

const WHOLE: &'static str = "argument"

What the whole is called: product or sum.
Source§

impl<This> CliProgramExt<This> for This

Source§

fn compile_cli<Program>( &self, program: Program, ) -> <Program as CliProgramAlg<This>>::Commands
where Program: CliProgramAlg<This>,

Compiles a named CLI program with this interpreter.

Source§

impl<Source> CliStatedFor<ContextArg> for Source

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<This> ShapeProgramExt<This> for This

Source§

fn compile_shape<Program>( &self, program: Program, ) -> <Program as ShapeProgramAlg<This>>::Ty
where Program: ShapeProgramAlg<This>,

Folds a declaration with this interpretation.

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.