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 { ... }
}
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§
type WithBufferSizeResult<const NEWSIZE: usize>: CommandList<NEWSIZE>
Required Methods§
Sourcefn with_buffer_size<const NEWSIZE: usize>(
self,
) -> Self::WithBufferSizeResult<NEWSIZE>
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§
fn run_once_with_buf(&mut self, linebuffer: &mut [u8])
fn run_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> !
Sourcefn run_forever(&mut self) -> !
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.
Sourcefn run_once(&mut self)
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.
fn run_forever_providing_buf(&mut self) -> !
fn run_once_providing_buf(&mut self)
Sourcefn and<'a, H, T>(
self,
name: &'a CStr,
desc: &'a CStr,
handler: H,
) -> impl CommandList<BUFSIZE>
fn and<'a, H, T>( self, name: &'a CStr, desc: &'a CStr, handler: H, ) -> impl CommandList<BUFSIZE>
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.