pub struct Node<'a> {
pub name: &'static [u8],
pub handler: Option<&'a dyn Command>,
pub sub: &'a [Node<'a>],
pub optional: bool,
}
Expand description
A SCPI command node These nodes are structured as a command tree where each node represent a SCPI header mnemonic.
Example
use scpi::tree::Node;
use scpi::scpi_tree;
use scpi::ieee488::commands::*;
let root = scpi_tree![
Node{name: b"*IDN?", optional: false, handler: Some(&IdnCommand{
manufacturer: b"GPA-Robotics",
model: b"Potato",
serial: b"42",
firmware: b"0"
}), sub: &[]}
//...
];
Note that all strings are ascii-/bytestrings, this is because only ASCII is defined in SCPI thus
the normal UTF8 &str in rust would be improper. To send a unicode string you can use Arbitrary Block Data
(or, this parser has an alternative arbitrary data header #s"..."
which allows and checks UTF8 data inside the quotes.
Fields
name: &'static [u8]
Mnemonic of this node, must follow the form SCPI notation (eg LARGEsmall[<index>]
etc)
handler: Option<&'a dyn Command>
Command handler. If None, the parser will return a UndefinedHeader error if the node is called (may still be traversed)
sub: &'a [Node<'a>]
Subnodes. The node may contain None or an array of subcommands. If a message attempts to traverse this node and it does not have any subnodes (eg `IMhelping:THISnode:DONTexist), a UndefinedHeaderError will be returned.
optional: bool
Marks the node as being optional (called default with inverse behaviour in IEE488)
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Node<'a>
impl<'a> !Send for Node<'a>
impl<'a> !Sync for Node<'a>
impl<'a> Unpin for Node<'a>
impl<'a> !UnwindSafe for Node<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more