riot_wrappers::shell

Trait CommandList

Source
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_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> ! { ... }
    fn run_forever(&mut self) -> ! { ... }
    fn run_once(&mut self) { ... }
    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,
    ) -> impl CommandList<BUFSIZE>
       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_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> !

Source

fn run_forever(&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.

Source

fn run_once(&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.

Source

fn run_forever_providing_buf(&mut self) -> !

👎Deprecated since 0.9: Renamed to run_forever
Source

fn run_once_providing_buf(&mut self)

👎Deprecated since 0.9: Renamed to run_once
Source

fn and<'a, H, T>( self, name: &'a CStr, desc: &'a CStr, handler: H, ) -> impl CommandList<BUFSIZE>
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.

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§

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,

Source§

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

Source§

impl<const BUFSIZE: usize> CommandList<BUFSIZE> for CommandListEnd