pub struct ResourceTable<'a> { /* private fields */ }Expand description
A parsed resources.arsc, borrowing from its bytes.
use apk::res::{ResourceTable, ResourceType};
let bytes = apk::Apk::open("app.apk")?.read("resources.arsc")?;
let table = ResourceTable::parse(&bytes)?;
let id = table.find(0x7f, ResourceType::String, "app_name").expect("app_name");
println!("{}", table.get(id).unwrap().default_value().unwrap());Implementations§
Source§impl<'a> ResourceTable<'a>
impl<'a> ResourceTable<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self, TableError>
pub fn parse(bytes: &'a [u8]) -> Result<Self, TableError>
Parses and checks a resources.arsc file.
pub fn packages(&self) -> &[Package<'a>]
Sourcepub fn get(&self, id: ResourceId) -> Option<Resource<'_, 'a>>
pub fn get(&self, id: ResourceId) -> Option<Resource<'_, 'a>>
The resource with ID id, if any configuration defines it.
Sourcepub fn find(
&self,
package_id: u8,
ty: ResourceType,
name: &str,
) -> Option<ResourceId>
pub fn find( &self, package_id: u8, ty: ResourceType, name: &str, ) -> Option<ResourceId>
Looks up a resource by type and name in package package_id.
Trait Implementations§
Source§impl<'a> Clone for ResourceTable<'a>
impl<'a> Clone for ResourceTable<'a>
Source§impl<'a> Debug for ResourceTable<'a>
impl<'a> Debug for ResourceTable<'a>
Source§impl Display for ResourceTable<'_>
impl Display for ResourceTable<'_>
Source§impl ResourceLookup for ResourceTable<'_>
impl ResourceLookup for ResourceTable<'_>
fn lookup(&self, ty: ResourceType, name: &ResourceName) -> Option<ResourceId>
Auto Trait Implementations§
impl<'a> Freeze for ResourceTable<'a>
impl<'a> RefUnwindSafe for ResourceTable<'a>
impl<'a> Send for ResourceTable<'a>
impl<'a> Sync for ResourceTable<'a>
impl<'a> Unpin for ResourceTable<'a>
impl<'a> UnsafeUnpin for ResourceTable<'a>
impl<'a> UnwindSafe for ResourceTable<'a>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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