Skip to main content

ApkKey

Struct ApkKey 

Source
pub struct ApkKey { /* private fields */ }
Expand description

Identity of an APK for cache purposes.

A program of several archives has a key of its own (rendered results, L3, and MemoryCache go by it), and each archive its own key too: L1 and L2 files of an entry live under its archive’s key, by its name inside the archive (ApkKey::locate). Rewriting one jar of a program then costs that jar’s entries only, and a jar read alone shares them with the same jar read as part of a program.

Implementations§

Source§

impl ApkKey

Source

pub fn for_apk(apk: &Apk) -> Result<ApkKey>

Derive the key from the file size, mtime and a hash of the central directory (so a rewritten archive with the same size is not confused with the old one); for a program of several archives, from those of each and its path, in order.

§Errors

The errors of asc_apk::Apk::directories, and asc_apk::ApkError::Io when an archive’s metadata cannot be read.

Source

pub fn for_content(label: &str, sha256: &[u8; 32]) -> ApkKey

The key of a file known by its content rather than its place: one ABC file of a HarmonyOS program, whose decompiled records depend on its bytes alone. label names it (entry.hap/ets/modules.abc): its last component’s stem starts the key, the first 16 hex digits of sha256 end it. The same bytes get the same key under any path, in any program; there are no archives to locate in.

The key only spreads files over directories: whoever stores under it keeps the whole digest in the query, as two contents may share these 64 bits.

Source

pub fn as_str(&self) -> &str

The key as text: <sanitised stem>-<16 hex digits>, also the name of the APK’s cache directories.

Source

pub fn locate<'n>(&self, name: &'n str) -> (&ApkKey, &'n str)

The key and name the L1 / L2 files of the entry (or logical DEX) a program calls name are stored under: its archive’s, by its name inside that archive. Other names (and a lone archive’s) stay as they are.

Trait Implementations§

Source§

impl Clone for ApkKey

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ApkKey

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for ApkKey

Source§

impl Hash for ApkKey

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ApkKey

Source§

fn eq(&self, other: &ApkKey) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for ApkKey

§

impl Freeze for ApkKey

§

impl Move for ApkKey

§

impl RefUnwindSafe for ApkKey

§

impl Send for ApkKey

§

impl Sync for ApkKey

§

impl Unpin for ApkKey

§

impl UnsafeUnpin for ApkKey

§

impl UnwindSafe for ApkKey

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.