Struct scpi::tree::Node

source · []
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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.