start implementing field

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2023-09-01 16:50:46 +02:00
parent 0ae6ce5e88
commit c84e3e36cc
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
5 changed files with 145 additions and 32 deletions

View file

@ -143,6 +143,27 @@ impl<'a> DexFileReader<'a> {
})
}
/// Return a [`&TypeIdItem`] from its idx.
pub fn get_type_id(&self, idx: usize) -> Result<&TypeIdItem> {
self.type_ids
.get(idx)
.ok_or(Error::InconsistantStruct(format!(
"type idx {} out of bound of type_ids (|type_ids| = {})",
idx,
self.type_ids.len()
)))
}
/// Return a [`&FieldIdItem`] from its idx.
pub fn get_field_id(&self, idx: usize) -> Result<&FieldIdItem> {
self.field_ids
.get(idx)
.ok_or(Error::InconsistantStruct(format!(
"field idx {idx} is out of bound (|field_ids|={})",
self.field_ids.len()
)))
}
fn sanity_check(&self) -> Result<()> {
if self.header.magic.version != [0x30, 0x33, 0x39] {
warn!(