nu_engine

Trait CallExt

Source
pub trait CallExt {
    // Required methods
    fn has_flag(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        flag_name: &str,
    ) -> Result<bool, ShellError>;
    fn get_flag<T: FromValue>(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        name: &str,
    ) -> Result<Option<T>, ShellError>;
    fn get_flag_span(&self, stack: &Stack, name: &str) -> Option<Span>;
    fn rest<T: FromValue>(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        starting_pos: usize,
    ) -> Result<Vec<T>, ShellError>;
    fn opt<T: FromValue>(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        pos: usize,
    ) -> Result<Option<T>, ShellError>;
    fn opt_const<T: FromValue>(
        &self,
        working_set: &StateWorkingSet<'_>,
        pos: usize,
    ) -> Result<Option<T>, ShellError>;
    fn req<T: FromValue>(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        pos: usize,
    ) -> Result<T, ShellError>;
    fn req_parser_info<T: FromValue>(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        name: &str,
    ) -> Result<T, ShellError>;
    fn has_positional_args(&self, stack: &Stack, starting_pos: usize) -> bool;
}

Required Methods§

Source

fn has_flag( &self, engine_state: &EngineState, stack: &mut Stack, flag_name: &str, ) -> Result<bool, ShellError>

Check if a boolean flag is set (i.e. --bool or --bool=true)

Source

fn get_flag<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<Option<T>, ShellError>

Source

fn get_flag_span(&self, stack: &Stack, name: &str) -> Option<Span>

Efficiently get the span of a flag argument

Source

fn rest<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, starting_pos: usize, ) -> Result<Vec<T>, ShellError>

Source

fn opt<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<Option<T>, ShellError>

Source

fn opt_const<T: FromValue>( &self, working_set: &StateWorkingSet<'_>, pos: usize, ) -> Result<Option<T>, ShellError>

Source

fn req<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<T, ShellError>

Source

fn req_parser_info<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<T, ShellError>

Source

fn has_positional_args(&self, stack: &Stack, starting_pos: usize) -> bool

True if the command has any positional or rest arguments, excluding before the given index.

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.

Implementations on Foreign Types§

Source§

impl CallExt for Call

Source§

fn has_flag( &self, engine_state: &EngineState, stack: &mut Stack, flag_name: &str, ) -> Result<bool, ShellError>

Source§

fn get_flag<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<Option<T>, ShellError>

Source§

fn get_flag_span(&self, _stack: &Stack, name: &str) -> Option<Span>

Source§

fn rest<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, starting_pos: usize, ) -> Result<Vec<T>, ShellError>

Source§

fn opt<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<Option<T>, ShellError>

Source§

fn opt_const<T: FromValue>( &self, working_set: &StateWorkingSet<'_>, pos: usize, ) -> Result<Option<T>, ShellError>

Source§

fn req<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<T, ShellError>

Source§

fn req_parser_info<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<T, ShellError>

Source§

fn has_positional_args(&self, _stack: &Stack, starting_pos: usize) -> bool

Source§

impl CallExt for Call

Source§

fn has_flag( &self, _engine_state: &EngineState, stack: &mut Stack, flag_name: &str, ) -> Result<bool, ShellError>

Source§

fn get_flag<T: FromValue>( &self, _engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<Option<T>, ShellError>

Source§

fn get_flag_span(&self, stack: &Stack, name: &str) -> Option<Span>

Source§

fn rest<T: FromValue>( &self, _engine_state: &EngineState, stack: &mut Stack, starting_pos: usize, ) -> Result<Vec<T>, ShellError>

Source§

fn opt<T: FromValue>( &self, _engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<Option<T>, ShellError>

Source§

fn opt_const<T: FromValue>( &self, _working_set: &StateWorkingSet<'_>, _pos: usize, ) -> Result<Option<T>, ShellError>

Source§

fn req<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, pos: usize, ) -> Result<T, ShellError>

Source§

fn req_parser_info<T: FromValue>( &self, engine_state: &EngineState, stack: &mut Stack, name: &str, ) -> Result<T, ShellError>

Source§

fn has_positional_args(&self, stack: &Stack, starting_pos: usize) -> bool

Implementors§

Source§

impl CallExt for nu_engine::command_prelude::Call<'_>