pub enum Node<'a, D> {
Leaf {
name: &'static [u8],
default: bool,
handler: &'a dyn Command<D>,
},
Branch {
name: &'static [u8],
default: bool,
sub: &'a [Node<'a, D>],
},
}
Expand description
A SCPI command node These nodes are structured as a command tree where each node represent a SCPI header mnemonic.
Variants§
Leaf
A leaf node which can be called or queried.
Fields
Branch
A branch which contains one or more leaves.
Implementations§
source§impl<'a, D> Node<'a, D>
impl<'a, D> Node<'a, D>
sourcepub const fn leaf(name: &'static [u8], handler: &'a dyn Command<D>) -> Self
pub const fn leaf(name: &'static [u8], handler: &'a dyn Command<D>) -> Self
Create a leaf node
Alternatively use crate::Leaf!
sourcepub const fn default_leaf(
name: &'static [u8],
handler: &'a dyn Command<D>
) -> Self
pub const fn default_leaf( name: &'static [u8], handler: &'a dyn Command<D> ) -> Self
Create a default leaf node
Alternatively use crate::Leaf!
sourcepub const fn branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self
pub const fn branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self
Create a branch node
Alternatively use crate::Branch!
sourcepub const fn default_branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self
pub const fn default_branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self
Create a default branch node
Alternatively use crate::Branch!
sourcepub const fn root(sub: &'a [Node<'a, D>]) -> Self
pub const fn root(sub: &'a [Node<'a, D>]) -> Self
Create a root node
Alternatively use crate::Root!
source§impl<'a, D> Node<'a, D>where
D: Device,
impl<'a, D> Node<'a, D>where
D: Device,
sourcepub fn run<FMT>(
&self,
command: &[u8],
device: &mut D,
context: &mut Context<'_>,
response: &mut FMT
) -> Result<()>where
FMT: Formatter,
pub fn run<FMT>(
&self,
command: &[u8],
device: &mut D,
context: &mut Context<'_>,
response: &mut FMT
) -> Result<()>where
FMT: Formatter,
Execute a command against a given device.
§Arguments:
- command - To be executed
- device - To execute against
- context - Context for this command
- response - A formatter to write a response into.
Auto Trait Implementations§
impl<'a, D> Freeze for Node<'a, D>
impl<'a, D> !RefUnwindSafe for Node<'a, D>
impl<'a, D> !Send for Node<'a, D>
impl<'a, D> !Sync for Node<'a, D>
impl<'a, D> Unpin for Node<'a, D>
impl<'a, D> !UnwindSafe for Node<'a, D>
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
Mutably borrows from an owned value. Read more