riot_wrappers::shell

Struct Command

Source
pub struct Command<'a, Next, H, T = i32>
where Next: CommandListInternals, H: FnMut(&mut Stdio, Args<'_>) -> T, T: Termination,
{ name: &'a CStr, desc: &'a CStr, handler: H, next: Next, }
Available on 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>
where Next: CommandListInternals, H: FnMut(&mut Stdio, Args<'_>) -> T, T: Termination,

Source

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).

Source

const fn tailsize() -> usize

Size of the own type’s built structs, in multiples of shell_command_t.

Usef for finding the own instance again, see handle documentation.

Trait Implementations§

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§

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

Change the buffer size used for .run_forever_providing_buf(). Read more
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 Read more
Source§

fn run_once(&mut self)

Run the shell prompt on stdio until EOF is reached Read more
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. Read more
Source§

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

Source§

type Built = BuiltCommand<<Next as CommandListInternals>::Built>

Source§

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

Run your own callback with argc and argv if the called argument is what the implementation put into its own entry of its Built, or defer to its next.
Source§

fn run_any<R, F: Fn(*const shell_command_t, *mut c_char, i32) -> R>( &mut self, linebuffer: &mut [u8], cb: F, ) -> R

Source§

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>
where H: Freeze, Next: Freeze,

§

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>
where H: Send, Next: Send,

§

impl<'a, Next, H, T> Sync for Command<'a, Next, H, T>
where H: Sync, Next: Sync,

§

impl<'a, Next, H, T> Unpin for Command<'a, Next, H, T>
where H: Unpin, Next: Unpin,

§

impl<'a, Next, H, T> UnwindSafe for Command<'a, Next, H, T>
where H: UnwindSafe, Next: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSwitch for T

Source§

fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
Source§

fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
Source§

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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.