pub struct Command<'a, Next, H, T = i32>{
name: &'a CStr,
desc: &'a CStr,
handler: H,
next: Next,
}
riot_module_shell
only.Expand description
Internal helper that holds the data assembled using the CommandList::and
builder
(Exposed publicly as the CommandList::and
trait method can not return an impl CommandList
yet)
Fields§
§name: &'a CStr
§desc: &'a CStr
§handler: H
§next: Next
Implementations§
Source§impl<'a, Next, H, T> Command<'a, Next, H, T>
impl<'a, Next, H, T> Command<'a, Next, H, T>
Sourceextern "C" fn handle<Root: CommandListInternals>(
argc: i32,
argv: *mut *mut c_char,
) -> i32
extern "C" fn handle<Root: CommandListInternals>( argc: i32, argv: *mut *mut c_char, ) -> i32
This is building a trampoline. As it’s static and thus can’t have the instance, we pass on a disambiguator (the command_index) for the globally stored root to pick our own self out of its tail again.
As all the commands in the list are serialized into a single CommandListInternals at the
root, they are all nested, and thus have sequential tail sizes. Over using the own TypeId,
this gives the advantage of building shorter trampolines (14 bytes rather than 24 on
Cortex-M3), and also allows the find_self_and_run function to optimize better, as all its
jumps are from a contiguous small range (think match ... {1 => one(), 2 => two(), _ => panic!()}
rather than arbitrary large numbers; the compiler range check once and then pick
the jump address from a table).
Trait Implementations§
Source§impl<'a, Next, H, T, const BUFSIZE: usize> CommandList<BUFSIZE> for Command<'a, Next, H, T>
impl<'a, Next, H, T, const BUFSIZE: usize> CommandList<BUFSIZE> for Command<'a, Next, H, T>
type WithBufferSizeResult<const NEWSIZE: usize> = Command<'a, Next, H, T>
Source§fn with_buffer_size<const NEWSIZE: usize>(
self,
) -> Self::WithBufferSizeResult<NEWSIZE>
fn with_buffer_size<const NEWSIZE: usize>( self, ) -> Self::WithBufferSizeResult<NEWSIZE>
.run_forever_providing_buf()
. Read morefn run_once_with_buf(&mut self, linebuffer: &mut [u8])
fn run_forever_with_buf(&mut self, linebuffer: &mut [u8]) -> !
Source§fn run_forever(&mut self) -> !
fn run_forever(&mut self) -> !
Source§fn run_forever_providing_buf(&mut self) -> !
fn run_forever_providing_buf(&mut self) -> !
Source§fn run_once_providing_buf(&mut self)
fn run_once_providing_buf(&mut self)
Source§impl<'a, Next, H, T> CommandListInternals for Command<'a, Next, H, T>
impl<'a, Next, H, T> CommandListInternals for Command<'a, Next, H, T>
type Built = BuiltCommand<<Next as CommandListInternals>::Built>
fn build_shell_command<Root: CommandListInternals>(&self) -> Self::Built
Source§fn find_self_and_run(
&mut self,
argc: i32,
argv: *mut *mut c_char,
command_index: usize,
) -> i32
fn find_self_and_run( &mut self, argc: i32, argv: *mut *mut c_char, command_index: usize, ) -> i32
fn run_any<R, F: Fn(*const shell_command_t, *mut c_char, i32) -> R>( &mut self, linebuffer: &mut [u8], cb: F, ) -> R
fn find_root_and_run( argc: i32, argv: *mut *mut c_char, command_index: usize, ) -> i32
Auto Trait Implementations§
impl<'a, Next, H, T> Freeze for Command<'a, Next, H, T>
impl<'a, Next, H, T> RefUnwindSafe for Command<'a, Next, H, T>where
H: RefUnwindSafe,
Next: RefUnwindSafe,
impl<'a, Next, H, T> Send for Command<'a, Next, H, T>
impl<'a, Next, H, T> Sync for Command<'a, Next, H, T>
impl<'a, Next, H, T> Unpin for Command<'a, Next, H, T>
impl<'a, Next, H, T> UnwindSafe for Command<'a, Next, H, T>where
H: UnwindSafe,
Next: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoSwitch for T
impl<T> IntoSwitch for T
Source§fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>
Source§fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>where
Self: Sized,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.