Enum scpi::tree::Node

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

§name: &'static [u8]

Mnemonic of this leaf

§default: bool

Default node, will be executed if the branch immediately below is executed. Only one default node is allowed in each branch.

§handler: &'a dyn Command<D>

Command handler

§

Branch

A branch which contains one or more leaves.

Fields

§name: &'static [u8]

Mnemonic of this branch

§default: bool

Default node.

§sub: &'a [Node<'a, D>]

Child nodes Note: Default node must be first!

Implementations§

source§

impl<'a, D> Node<'a, D>

source

pub const fn leaf(name: &'static [u8], handler: &'a dyn Command<D>) -> Self

Create a leaf node

Alternatively use crate::Leaf!

source

pub const fn default_leaf( name: &'static [u8], handler: &'a dyn Command<D> ) -> Self

Create a default leaf node

Alternatively use crate::Leaf!

source

pub const fn branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self

Create a branch node

Alternatively use crate::Branch!

source

pub const fn default_branch(name: &'static [u8], sub: &'a [Node<'a, D>]) -> Self

Create a default branch node

Alternatively use crate::Branch!

source

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>

source

pub fn name(&self) -> &'static [u8]

source§

impl<'a, D> Node<'a, D>
where D: Device,

source

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.