Struct noak::reader::Class

source ·
pub struct Class<'input> { /* private fields */ }

Implementations§

source§

impl<'input> Class<'input>

source

pub fn new(v: &'input [u8]) -> Result<Class<'input>, DecodeError>

Initializes a class reader.

use noak::reader::Class;

let mut class = Class::new(data)?;
source

pub fn version(&self) -> Version

Returns the class version.

use noak::{Version, reader::Class};

let mut class = Class::new(data)?;
assert_eq!(class.version(), Version::latest());
source

pub fn pool(&self) -> &ConstantPool<'input>

Returns the constant pool of this class.

use noak::reader::{cpool, Class};

let mut class = Class::new(data)?;

let item: &cpool::Utf8 = class.pool().get(index)?;
println!("Item: {}", item.content.display());
source

pub fn access_flags(&self) -> AccessFlags

Returns the access flags of the class.

The flags returned may not be valid in this context.

use noak::reader::Class;
use noak::AccessFlags;

let mut class = Class::new(data)?;
let flags = class.access_flags();
assert!(flags.contains(AccessFlags::PUBLIC | AccessFlags::SUPER));
source

pub fn this_class(&self) -> Index<Class<'input>>

Returns the index of this class name.

use noak::reader::Class;
use noak::AccessFlags;

let mut class = Class::new(data)?;
let this_class = class.this_class();
println!("Class: {}", class.pool().retrieve(this_class)?.name.display());
source

pub fn super_class(&self) -> Option<Index<Class<'input>>>

source

pub fn interfaces(&self) -> DecodeMany<'input, Index<Class<'input>>, u16>

Returns an iterator over the interface indices into the constant pool.

use noak::reader::Class;

let mut class = Class::new(data)?;
for interface in class.interfaces() {
    let interface = interface?;
    println!("Interface: {}", class.pool().retrieve(interface)?.name.display());
}
source

pub fn fields(&self) -> DecodeMany<'input, Field<'input>, u16>

Returns an iterator over the fields of this class.

use noak::reader::Class;

let mut class = Class::new(data)?;
for field in class.fields() {
    let field = field?;
    println!("Field name: {}", class.pool().retrieve(field.name())?.display());
}
source

pub fn methods(&self) -> DecodeMany<'input, Method<'input>, u16>

Returns an iterator over the methods of this class.

use noak::reader::Class;

let mut class = Class::new(data)?;
for method in class.methods() {
    let method = method?;
    println!("Method name: {}", class.pool().retrieve(method.name())?.display());
}
source

pub fn attributes(&self) -> DecodeMany<'input, Attribute<'input>, u16>

Returns an iterator over the attributes of this class.

use noak::reader::{AttributeContent, Class};

let mut class = Class::new(data)?;
for attribute in class.attributes() {
    let attribute = attribute?;
    match attribute.read_content(class.pool())? {
        AttributeContent::Deprecated(_) => println!("Class is deprecated"),
        _ => {}
    }
}
source

pub fn buffer_size(&self) -> usize

The number of bytes used by the class file.

Trait Implementations§

source§

impl<'input> Clone for Class<'input>

source§

fn clone(&self) -> Class<'input>

Returns a copy 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<'input> Debug for Class<'input>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'input> Freeze for Class<'input>

§

impl<'input> RefUnwindSafe for Class<'input>

§

impl<'input> Send for Class<'input>

§

impl<'input> Sync for Class<'input>

§

impl<'input> Unpin for Class<'input>

§

impl<'input> UnwindSafe for Class<'input>

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.