pub struct Instance<'a> { /* private fields */ }
Expand description
An instance of a reference type (i.e. not a primitive).
Implementations§
Source§impl<'a> Instance<'a>
impl<'a> Instance<'a>
pub fn obj_id(&self) -> Id
pub fn stack_trace_serial(&self) -> Serial
pub fn class_obj_id(&self) -> Id
Source§impl<'a> Instance<'a>
impl<'a> Instance<'a>
Sourcepub fn fields(&self) -> &&'a [u8] ⓘ
pub fn fields(&self) -> &&'a [u8] ⓘ
Instance field values, root class’s fields last.
§Example
Once you have assembled the class hierarchy and have accumulated all the field descriptors,
instance fields can be parsed like so (adapted from print_field_val
in the examples):
use jvm_hprof::heap_dump::{FieldDescriptor, Instance, FieldValue};
use jvm_hprof::{Hprof, IdSize, Id};
use std::collections::HashMap;
fn print_field_val(
instance: Instance,
field_descriptors: &[FieldDescriptor],
id_size: IdSize,
utf8: HashMap<Id, &str>
) {
let mut field_val_input: &[u8] = instance.fields();
for fd in field_descriptors.iter() {
let (input, field_val) = fd
.field_type()
.parse_value(field_val_input, id_size)
.unwrap();
field_val_input = input;
let field_name =
utf8.get(&fd.name_id()).unwrap_or_else(|| &"missing");
match field_val {
FieldValue::ObjectId(Some(id)) => println!("{}: ref to obj id {}", field_name, id),
FieldValue::ObjectId(null) => println!("{}: ref to null", field_name),
FieldValue::Int(i) => println!("{}: int {}", field_name, i),
_ => { /* and so forth */ }
}
}
}
Auto Trait Implementations§
impl<'a> Freeze for Instance<'a>
impl<'a> RefUnwindSafe for Instance<'a>
impl<'a> Send for Instance<'a>
impl<'a> Sync for Instance<'a>
impl<'a> Unpin for Instance<'a>
impl<'a> UnwindSafe for Instance<'a>
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