pub trait CommandList<const BUFSIZE: usize = { riot_sys::SHELL_DEFAULT_BUFSIZE as _ }>: CommandListInternals {
    type WithBufferSizeResult<const NEWSIZE: usize>: CommandList<NEWSIZE>;

    // Required method
    fn with_buffer_size<const NEWSIZE: usize>(
        self
    ) -> Self::WithBufferSizeResult<NEWSIZE>;

    // Provided methods
    fn run_once_with_buf(&mut self, linebuffer: &mut [u8]) { ... }
    fn run_once(&mut self, linebuffer: &mut [u8]) { ... }
    fn run_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> ! { ... }
    fn run_forever(&mut self, linebuffer: &mut [u8]) -> ! { ... }
    fn run_forever_providing_buf(&mut self) -> ! { ... }
    fn run_once_providing_buf(&mut self) { ... }
    fn and<'a, H, T>(
        self,
        name: &'a CStr,
        desc: &'a CStr,
        handler: H
    ) -> Command<'a, Self, H, T>
       where H: FnMut(&mut Stdio, Args<'_>) -> T,
             T: Termination { ... }
}
Available on riot_module_shell only.
Expand description

A list of commands that can be presented as a shell prompt

The BUFSIZE is carried around in the trait because it can have a default there (a trait method can’t have a default value for its generic argument), which necessitates that implementers use with_buffer_size to change it and carry that size on. (Having a .run_forever() / .run_forever<BUFSIZE = 60>() would be ideal, but that’s currently not possible).

Required Associated Types§

source

type WithBufferSizeResult<const NEWSIZE: usize>: CommandList<NEWSIZE>

Required Methods§

source

fn with_buffer_size<const NEWSIZE: usize>( self ) -> Self::WithBufferSizeResult<NEWSIZE>

Change the buffer size used for .run_forever_providing_buf().

Note that no buffer of that size is carried around – it is merely transported in the trait to provide a (defaultable) number for that method.

Provided Methods§

source

fn run_once_with_buf(&mut self, linebuffer: &mut [u8])

source

fn run_once(&mut self, linebuffer: &mut [u8])

👎Deprecated: Use run_once_with_buf, or just run_once_providing_buf, which will take over this name in the next breaking release
source

fn run_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> !

source

fn run_forever(&mut self, linebuffer: &mut [u8]) -> !

👎Deprecated: Use run_forever_with_buf, or just run_forever_providing_buf, which will take over this name in the next breaking release
source

fn run_forever_providing_buf(&mut self) -> !

Run the shell prompt on stdio

See shell_run_forever for details.

The line buffer is allocated inside this function with the size configured as part of the trait type; use .with_buffer_size::<>() to alter that. The method will be renamed to run_forever once that name is free.

source

fn run_once_providing_buf(&mut self)

Run the shell prompt on stdio until EOF is reached

See shell_run_once for details.

The line buffer is allocated inside this function with the size configured as part of the trait type; use .with_buffer_size::<>() to alter that. The method will be renamed to run_once once that name is free.

source

fn and<'a, H, T>( self, name: &'a CStr, desc: &'a CStr, handler: H ) -> Command<'a, Self, H, T>where H: FnMut(&mut Stdio, Args<'_>) -> T, T: Termination,

Extend the list of commands by an additional one.

The handler will be called every time the command is entered, and is passed the arguments including its own name in the form of Args. Currently, RIOT ignores the return value of the function.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, Next, H, T, const BUFSIZE: usize> CommandList<BUFSIZE> for Command<'a, Next, H, T>where Next: CommandListInternals, H: FnMut(&mut Stdio, Args<'_>) -> T, T: Termination,

§

type WithBufferSizeResult<const NEWSIZE: usize> = Command<'a, Next, H, T>