Token

Enum Token 

Source
pub enum Token<'a> {
Show 72 variants ILLEGAL(&'a str), EOF, IDENT(&'a str, Option<SocketPlug>), VALUE(Value<'a>), TAG(Option<u8>, Option<TagConstraint<'a>>), ASSIGN, OPTIONAL, ASTERISK, ONEORMORE, UNWRAP, COMMA, COLON, COMMENT(&'a str), TCHOICE, GCHOICE, TCHOICEALT, GCHOICEALT, ARROWMAP, CUT, RANGEOP(bool), RANGE(RangeValue<'a>, RangeValue<'a>, bool), LPAREN, RPAREN, LBRACE, RBRACE, LBRACKET, RBRACKET, LANGLEBRACKET, RANGLEBRACKET, ControlOperator(ControlOperator), GTOCHOICE, FALSE, TRUE, BOOL, NIL, NULL, UINT, NINT, INT, FLOAT16, FLOAT32, FLOAT64, FLOAT1632, FLOAT3264, FLOAT, BSTR, TSTR, ANY, BYTES, TEXT, TDATE, TIME, NUMBER, BIGUINT, BIGNINT, BIGINT, INTEGER, UNSIGNED, DECFRAC, BIGFLOAT, EB64URL, EB64LEGACY, EB16, ENCODEDCBOR, URI, B64URL, B64LEGACY, REGEXP, MIMEMESSAGE, CBORANY, UNDEFINED, NEWLINE,
}
Expand description

Token which represents a valid CDDL character or sequence

Variants§

§

ILLEGAL(&'a str)

Illegal sequence of characters

§

EOF

End of file

§

IDENT(&'a str, Option<SocketPlug>)

Identifier

Tuple Fields

§0: &'a str

Identifier

§1: Option<SocketPlug>

Socket/plug

§

VALUE(Value<'a>)

Value

§

TAG(Option<u8>, Option<TagConstraint<'a>>)

CBOR tag ‘#’

Tuple Fields

§0: Option<u8>

Major type

§1: Option<TagConstraint<'a>>

Optional constraint - either a literal number or a type expression

§

ASSIGN

Assignment operator ‘=’

§

OPTIONAL

Optional occurrence indicator ‘?’

§

ASTERISK

Zero or more occurrence indicator ‘*’

§

ONEORMORE

One or more occurrence indicator ‘+’

§

UNWRAP

Unwrap operator ‘~’

§

COMMA

Comma ‘,’

§

COLON

Colon ‘:’

§

COMMENT(&'a str)

Comment text

§

TCHOICE

Type choice indicator ‘/’

§

GCHOICE

Group choice indicator ‘//’

§

TCHOICEALT

Type choice alternative ‘/=’

§

GCHOICEALT

Group choice alternative ‘//=’

§

ARROWMAP

Arrow map ‘=>’

§

CUT

Cut ‘^’

§

RANGEOP(bool)

Range operator. Inclusive ‘..’ if true, otherwise exclusive ’…’s

§

RANGE(RangeValue<'a>, RangeValue<'a>, bool)

Range

Tuple Fields

§0: RangeValue<'a>

Lower bound

§1: RangeValue<'a>

Upper bound

§2: bool

Inclusive

§

LPAREN

Left opening parend

§

RPAREN

Right closing parend

§

LBRACE

Left opening brace

§

RBRACE

Right closing brace

§

LBRACKET

Left opening bracket

§

RBRACKET

Right closing bracket

§

LANGLEBRACKET

Left opening angle bracket

§

RANGLEBRACKET

Right closing angle bracket

§

ControlOperator(ControlOperator)

Control operator token

§

GTOCHOICE

group to choice enumeration ‘&’

§

FALSE

false

§

TRUE

true

§

BOOL

bool

§

NIL

nil

§

NULL

null

§

UINT

uint

§

NINT

nint

§

INT

int

§

FLOAT16

float16

§

FLOAT32

float32

§

FLOAT64

float64

§

FLOAT1632

float16-32

§

FLOAT3264

float32-64

§

FLOAT

float

§

BSTR

bstr

§

TSTR

tstr

§

ANY

any

§

BYTES

bytes

§

TEXT

text

§

TDATE

tdate

§

TIME

time

§

NUMBER

number

§

BIGUINT

biguint

§

BIGNINT

bignint

§

BIGINT

bigint

§

INTEGER

integer

§

UNSIGNED

unsigned

§

DECFRAC

decfrac

§

BIGFLOAT

bigfloat

§

EB64URL

eb64url

§

EB64LEGACY

eb64legacy

§

EB16

eb16k

§

ENCODEDCBOR

encoded-cbor

§

URI

uri

§

B64URL

b64url

§

B64LEGACY

b64legacy

§

REGEXP

regexp

§

MIMEMESSAGE

mime-message

§

CBORANY

cbor-any

§

UNDEFINED

undefined

§

NEWLINE

newline (used only for comment formatting when compiled with the “lsp” feature)

Implementations§

Source§

impl Token<'_>

Source

pub fn in_standard_prelude(&self) -> Option<&'static str>

Returns optional string literal of token if it is in the standard prelude

§Example
use cddl::token::Token;

let t = Token::ANY;
assert_eq!(t.in_standard_prelude(), Some("any"));

Trait Implementations§

Source§

impl<'a> Clone for Token<'a>

Source§

fn clone(&self) -> Token<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Token<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Token<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<Token<'a>> for Identifier<'a>

Source§

fn from(token: Token<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for Token<'a>

Source§

fn eq(&self, other: &Token<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<Token<'a>> for RangeValue<'a>

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(t: Token<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> StructuralPartialEq for Token<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Token<'a>

§

impl<'a> RefUnwindSafe for Token<'a>

§

impl<'a> Send for Token<'a>

§

impl<'a> Sync for Token<'a>

§

impl<'a> Unpin for Token<'a>

§

impl<'a> UnwindSafe for Token<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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

Source§

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.