pub struct Class<'input> { /* private fields */ }
Implementations§
source§impl<'input> Class<'input>
impl<'input> Class<'input>
sourcepub fn new(v: &'input [u8]) -> Result<Class<'input>, DecodeError>
pub fn new(v: &'input [u8]) -> Result<Class<'input>, DecodeError>
Initializes a class reader.
use noak::reader::Class;
let mut class = Class::new(data)?;
sourcepub fn version(&self) -> Version
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());
sourcepub fn pool(&self) -> &ConstantPool<'input>
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());
sourcepub fn access_flags(&self) -> AccessFlags
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));
sourcepub fn this_class(&self) -> Index<Class<'input>>
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());
pub fn super_class(&self) -> Option<Index<Class<'input>>>
sourcepub fn interfaces(&self) -> DecodeMany<'input, Index<Class<'input>>, u16>
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());
}
sourcepub fn fields(&self) -> DecodeMany<'input, Field<'input>, u16>
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());
}
sourcepub fn methods(&self) -> DecodeMany<'input, Method<'input>, u16>
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());
}
sourcepub fn attributes(&self) -> DecodeMany<'input, Attribute<'input>, u16>
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"),
_ => {}
}
}
sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
The number of bytes used by the class file.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more