pub struct Arsc { /* private fields */ }Expand description
Parsed ARSC (resources.arsc) file.
Mirrors the Python ARSC class: proto holds the prost-generated protobuf
message, stringblocks wraps the global string pool (proto + binary).
Implementations§
Source§impl Arsc
impl Arsc
Sourcepub fn get_proto(&self) -> &Arsc
pub fn get_proto(&self) -> &Arsc
Return a reference to the cached prost-generated protobuf message.
Call update_proto() first if the internal state has been modified.
Sourcepub fn to_proto_text(&self) -> String
pub fn to_proto_text(&self) -> String
Serialize self.proto to native protobuf text format using prost-reflect.
Sourcepub fn to_proto_text_pretty(&self) -> String
pub fn to_proto_text_pretty(&self) -> String
Serialize to indented proto text format (one field per line).
Sourcepub fn export_proto_file(&self, path: &str) -> Result<(), AxmlError>
pub fn export_proto_file(&self, path: &str) -> Result<(), AxmlError>
Write the binary proto representation of this ARSC file to path.
Sourcepub fn from_proto_file(path: &str) -> Result<Self, AxmlError>
pub fn from_proto_file(path: &str) -> Result<Self, AxmlError>
Load an ARSC from a binary proto file written by [export_proto_file].
Sourcepub fn export_pkg_proto_file(
&self,
idx: usize,
path: &str,
) -> Result<(), AxmlError>
pub fn export_pkg_proto_file( &self, idx: usize, path: &str, ) -> Result<(), AxmlError>
Write the binary proto representation of package idx to path.
Sourcepub fn import_pkg_proto_file(
&mut self,
idx: usize,
path: &str,
) -> Result<(), AxmlError>
pub fn import_pkg_proto_file( &mut self, idx: usize, path: &str, ) -> Result<(), AxmlError>
Replace package idx from a binary proto file written by [export_pkg_proto_file].
Sourcepub fn list_packages(&self, language_filter: Option<&str>) -> String
pub fn list_packages(&self, language_filter: Option<&str>) -> String
Produce an XML listing of resource entries grouped by locale.
Each group is wrapped in <resources lang="…">.
If language_filter is Some, only the matching locale section is emitted.
Matching is case-insensitive ASCII. Use "default" to select entries with no
locale qualifier, or a language tag such as "en" or "fr-FR".
Sourcepub fn compute(&mut self, recursive: bool)
pub fn compute(&mut self, recursive: bool)
Force recalculation of string-pool chunk sizes on the next pack().
When recursive is true (the default), all string pools are marked
dirty, the global pool plus every package’s type and key pools.
When false, only the global string pool is recomputed; package-level
pools keep their current raw bytes.
Recalculate all chunk-size header fields and store them in the struct.
When recursive is true (the default), all string pools are marked
dirty and all package chunk_size fields are updated.
When false, only the global string pool and the top-level size fields
are recomputed; package-level string pools keep their current raw bytes.
After compute(), pack() produces a fully correct binary.
Sourcepub fn global_stringpool_size(&self) -> usize
pub fn global_stringpool_size(&self) -> usize
Returns the global string pool pack size (for debugging).
Sourcepub fn global_stringpool_is_dirty(&self) -> bool
pub fn global_stringpool_is_dirty(&self) -> bool
Returns whether the global string pool is dirty.
Sourcepub fn package_count(&self) -> usize
pub fn package_count(&self) -> usize
Returns the number of packages.
Sourcepub fn package_pool_info(
&self,
idx: usize,
) -> Option<(usize, bool, usize, bool)>
pub fn package_pool_info( &self, idx: usize, ) -> Option<(usize, bool, usize, bool)>
Returns info about package string pools (for debugging).
Sourcepub fn package_chunks_have_raw(&self, pkg_idx: usize) -> Vec<bool>
pub fn package_chunks_have_raw(&self, pkg_idx: usize) -> Vec<bool>
Returns the count of chunks in a package (spec and type counts).
Sourcepub fn pack(&self) -> Vec<u8> ⓘ
pub fn pack(&self) -> Vec<u8> ⓘ
Serialize this ARSC to binary resources.arsc format.
This function auto-recalculates sizes when needed (when total_size is 0). Always produces a correct binary output.
Sourcepub fn add_resource(
&mut self,
type_name: &str,
name: &str,
file_path: &str,
) -> u32
pub fn add_resource( &mut self, type_name: &str, name: &str, file_path: &str, ) -> u32
Add a new resource entry (type_name / name → file_path string value).
Finds or creates the type in the first package’s type string pool, adds
the entry name to the key string pool, adds file_path to the global
string pool, then appends a new TypeSpec+TypeType pair for the default
locale. Returns the new resource ID (0x7fTTEEEE).
Source§impl Arsc
impl Arsc
Sourcepub fn to_proto_bytes(&self) -> Vec<u8> ⓘ
pub fn to_proto_bytes(&self) -> Vec<u8> ⓘ
Serialize self.proto as binary protobuf bytes.
Sourcepub fn from_proto_bytes(data: &[u8]) -> Result<Self, AxmlError>
pub fn from_proto_bytes(data: &[u8]) -> Result<Self, AxmlError>
Deserialize an Arsc from binary protobuf bytes produced by [to_proto_bytes].
Sourcepub fn from_proto(p: Arsc) -> Result<Self, AxmlError>
pub fn from_proto(p: Arsc) -> Result<Self, AxmlError>
Reconstruct an Arsc from a prost-generated [proto::Arsc] message.
Sourcepub fn to_proto(&self) -> Arsc
pub fn to_proto(&self) -> Arsc
Convert to the prost-generated [proto::Arsc] message for in-process manipulation.
Sourcepub fn update_proto(&mut self)
pub fn update_proto(&mut self)
Recompute self.proto and self.stringblocks.proto from the current
in-memory state. Called automatically at the end of from_axml().
Call manually if you modify stringblocks.inner or packages directly.