Skip to main content

ClassReader

Struct ClassReader 

Source
pub struct ClassReader { /* private fields */ }
Expand description

A parser to make a ClassVisitor visit a ClassFile structure.

This class parses a byte array conforming to the Java class file format and calls the appropriate methods of a given class visitor for each field, method, and bytecode instruction encountered.

Implementations§

Source§

impl ClassReader

Source

pub fn new(bytes: &[u8]) -> Self

Constructs a new ClassReader with the given class file bytes.

§Arguments
  • bytes - A byte slice containing the JVM class file data.
Source

pub fn accept( &self, visitor: &mut dyn ClassVisitor, _options: u32, ) -> Result<(), ClassReadError>

Makes the given visitor visit the Java class of this ClassReader.

This method parses the class file data and drives the visitor events.

§Arguments
  • visitor - The visitor that must visit this class.
  • _options - Option flags (currently unused, reserve for future parsing options like skipping debug info).
§Errors

Returns a ClassReadError if the class file is malformed or contains unsupported versions.

Source

pub fn to_class_node(&self) -> Result<ClassNode, ClassReadError>

Converts the read class data directly into a ClassNode.

This is a convenience method that parses the bytes and builds a complete object model of the class.

Auto Trait Implementations§

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.