pub enum Token<'a> {
Show 14 variants HeaderMnemonicSeparator, HeaderCommonPrefix, HeaderQuerySuffix, ProgramMessageUnitSeparator, ProgramHeaderSeparator, ProgramDataSeparator, ProgramMnemonic(&'a [u8]), CharacterProgramData(&'a [u8]), DecimalNumericProgramData(&'a [u8]), DecimalNumericSuffixProgramData(&'a [u8]&'a [u8]), NonDecimalNumericProgramData(u64), StringProgramData(&'a [u8]), ArbitraryBlockData(&'a [u8]), ExpressionProgramData(&'a [u8]),
}
Expand description

SCPI tokens Loosely based on IEEE488.2 Chapter 7

Variants

HeaderMnemonicSeparator

A header mnemonic separator :

HeaderCommonPrefix

A common header prefix *

HeaderQuerySuffix

A header query suffix ?

ProgramMessageUnitSeparator

A message unit separator ;

ProgramHeaderSeparator

A Program header separator

ProgramDataSeparator

A program data separator ‘,’

ProgramMnemonic(&'a [u8])

A program mnemonic

CharacterProgramData(&'a [u8])

A 7.7.1

DecimalNumericProgramData(&'a [u8])

A 7.7.2

DecimalNumericSuffixProgramData(&'a [u8]&'a [u8])

A 7.7.2 followed by a 7.7.3

NonDecimalNumericProgramData(u64)

A 7.7.4

StringProgramData(&'a [u8])

A 7.7.5

ArbitraryBlockData(&'a [u8])

A 7.7.6

ExpressionProgramData(&'a [u8])

A 7.7.7

Implementations

Returns true if token is a ProgramMnemonic that matches provided mnemonic. Header suffix is optional if equal to 1 or not present in mnemonic. Header suffixes other than 1 must match exactly.

Eg:

  • head[er] == HEADer
  • head[er]1 == HEADer
  • head[er] == HEADer1
  • head[er]<N> == HEADer<N> Where [] marks optional, <> required.

Handle data as a SCPI and convert to R datatype

**Note: Decimal data is not compared to the maximum/minimum value and must be done seperately (unless equal to max/min of that datatype).

Example
use scpi::tokenizer::Token;
use scpi::NumericValues;
use scpi::error::ErrorCode;
let  s = Token::CharacterProgramData(b"MAXimum");

let mut x = 128u8;
if let Ok(v) = s.numeric(|special| match special {
    NumericValues::Maximum => Ok(255u8),
    NumericValues::Minimum => Ok(0u8),
    NumericValues::Default => Ok(1u8),
    NumericValues::Up => Ok(x+1),
    NumericValues::Down => Ok(x-1),
    _ => Err(ErrorCode::ParameterError.into())
}) {
    //v is resolved to a u8 type
    x = v;
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Convert string data data into a slice (&[u8]).

Returns

  • Ok(&[u8]) - If data is a string.
  • Err(DataTypeError) - If data is not a string.
  • Err(SyntaxError) - If token is not data

The type returned in the event of a conversion error.

Performs the conversion.

Convert string data data into a boolean.

Returns

  • Ok(bool) - If data is character data matching ON|OFF or numeric 1|0.
  • Err(IllegalParameterValue) - If data is character data or numeric but is not a boolean
  • Err(DataTypeError) - If data is not a character data or numeric.
  • Err(SyntaxError) - If token is not data.

The type returned in the event of a conversion error.

Performs the conversion.

Convert string/block data data into a str.

Returns

  • Ok(&str) - If data is a string or block data.
  • Err(DataTypeError) - If data is not a string.
  • Err(StringDataError) - If string is not valid utf8
  • Err(SyntaxError) - If token is not data

The type returned in the event of a conversion error.

Performs the conversion.

Convert character data into a str.

Returns

  • Ok(&str) - If data is character data.
  • Err(DataTypeError) - If data is not character string.
  • Err(SyntaxError) - If token is not data

The type returned in the event of a conversion error.

Performs the conversion.

Convert character data into a str.

Returns

  • Ok(&str) - If data is character data.
  • Err(DataTypeError) - If data is not character string.
  • Err(SyntaxError) - If token is not data

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

The type returned in the event of a conversion error.

Performs the conversion.

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.