Skip to main content

Token

Struct Token 

Source
pub struct Token {
    pub i: usize,
    pub signal: Signal,
    pub name: String,
    pub referenced_name: String,
    pub description: String,
    pub id: i32,
    pub version: i32,
    pub deprecated: Option<i32>,
    pub encoded_length: i32,
    pub offset: i32,
    pub component_token_count: i32,
    pub encoding: Encoding,
}

Fields§

§i: usize§signal: Signal§name: String§referenced_name: String§description: String§id: i32§version: i32§deprecated: Option<i32>§encoded_length: i32§offset: i32§component_token_count: i32§encoding: Encoding

Implementations§

Source§

impl Token

Source

pub fn array_length(&self) -> usize

Examples found in repository?
examples/dec.rs (line 91)
61    fn on_encoding(
62        &mut self,
63        field_token: &Token,
64        buffer: &[u8],
65        type_token: &Token,
66        acting_version: i32,
67    ) -> Result<(), TokenListenerError> {
68        // println!("    {name}: {{{}}} {p:?} = {buffer:02X?}", p.to_string());
69        self.print_scope();
70        if self.composite_level > 0 {
71            print!("{}", type_token.name);
72        } else {
73            print!("{}", field_token.name);
74        }
75
76        let np = self.const_or_not_present_value(type_token, field_token.version, acting_version);
77        if np.is_none() {
78            println!(
79                "={} : {buffer:02X?}",
80                buffer
81                    .chunks(type_token.encoding.primitive_type.size())
82                    .map(|b| format!(
83                        "{}",
84                        PrimitiveValue::new(type_token.encoding.primitive_type, b)
85                    ))
86                    .collect::<Vec<_>>()
87                    .join(", ")
88            );
89        } else {
90            print!("={np}");
91            for _ in 1..type_token.array_length() {
92                print!(", {np}");
93            }
94            println!(" [const]")
95        }
96
97        Ok(())
98    }

Trait Implementations§

Source§

impl Debug for Token

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Token

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnsafeUnpin for Token

§

impl UnwindSafe for Token

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