Struct Scope

Source
pub struct Scope<'d> {
    pub file: &'d File,
    pub typedef: HashMap<String, &'d Decl>,
}
Expand description

Gather information about the full AST.

Fields§

§file: &'d File

Reference to the source file.

§typedef: HashMap<String, &'d Decl>

Collection of Group, Packet, Enum, Struct, Checksum, and CustomField declarations.

Implementations§

Source§

impl<'d> Scope<'d>

Source

pub fn new(file: &'d File) -> Result<Scope<'d>, Diagnostics>

Source

pub fn iter_children<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Decl> + 's

Iterate over the child declarations of the selected declaration.

Source

pub fn get_parent(&self, decl: &Decl) -> Option<&'d Decl>

Return the parent declaration of the selected declaration, if it has one.

Source

pub fn iter_parents<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Decl> + 's

Iterate over the parent declarations of the selected declaration.

Source

pub fn iter_parents_and_self<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Decl> + 's

Iterate over the parent declarations of the selected declaration, including the current declaration.

Source

pub fn iter_fields<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Field> + 's

Iterate over the declaration and its parent’s fields.

Source

pub fn iter_parent_fields<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Field> + 's

Iterate over the declaration parent’s fields.

Source

pub fn iter_constraints<'s>( &'s self, decl: &'d Decl, ) -> impl Iterator<Item = &'d Constraint> + 's

Iterate over the declaration and its parent’s constraints.

Source

pub fn get_type_declaration(&self, field: &Field) -> Option<&'d Decl>

Return the type declaration for the selected field, if applicable.

Source

pub fn is_bitfield(&self, field: &Field) -> bool

Test if the selected field is a bit-field.

Trait Implementations§

Source§

impl<'d> Debug for Scope<'d>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'d> Freeze for Scope<'d>

§

impl<'d> RefUnwindSafe for Scope<'d>

§

impl<'d> Send for Scope<'d>

§

impl<'d> Sync for Scope<'d>

§

impl<'d> Unpin for Scope<'d>

§

impl<'d> UnwindSafe for Scope<'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, 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.