Skip to main content

ArchiveFlags

Struct ArchiveFlags 

Source
pub struct ArchiveFlags(/* private fields */);
Expand description

Wraps AppleArchive archive-processing flags.

Implementations§

Source§

impl ArchiveFlags

Source

pub const IGNORE_EPERM: Self

Wraps the IGNORE_EPERM AppleArchive archive flag bit.

Source

pub const ARCHIVE_DEDUPLICATE_DAT: Self

Wraps the ARCHIVE_DEDUPLICATE_DAT AppleArchive archive flag bit.

Source

pub const ARCHIVE_NO_RESOLVE_ACL_QUALIFIERS: Self

Wraps the ARCHIVE_NO_RESOLVE_ACL_QUALIFIERS AppleArchive archive flag bit.

Source

pub const REPLACE_ATTRIBUTES: Self

Wraps the REPLACE_ATTRIBUTES AppleArchive archive flag bit.

Source

pub const EXTRACT_NO_AUTO_DEDUP: Self

Wraps the EXTRACT_NO_AUTO_DEDUP AppleArchive archive flag bit.

Source

pub const EXTRACT_NO_AUTO_SPARSE: Self

Wraps the EXTRACT_NO_AUTO_SPARSE AppleArchive archive flag bit.

Source

pub const CROSS_VOLUME_BOUNDARIES: Self

Wraps the CROSS_VOLUME_BOUNDARIES AppleArchive archive flag bit.

Wraps the EXTRACT_AUTO_DEDUP_AS_HARD_LINKS AppleArchive archive flag bit.

Source

pub const DECODE_INSERT_IDX: Self

Wraps the DECODE_INSERT_IDX AppleArchive archive flag bit.

Source

pub const EXCLUDE_METADATA_ENTRIES: Self

Wraps the EXCLUDE_METADATA_ENTRIES AppleArchive archive flag bit.

Source

pub const PROCESS_RANDOM_ACCESS_OUTPUT: Self

Wraps the PROCESS_RANDOM_ACCESS_OUTPUT AppleArchive archive flag bit.

Source

pub const VERBOSITY_0: Self

Wraps the VERBOSITY_0 AppleArchive archive flag bit.

Source

pub const VERBOSITY_1: Self

Wraps the VERBOSITY_1 AppleArchive archive flag bit.

Source

pub const VERBOSITY_2: Self

Wraps the VERBOSITY_2 AppleArchive archive flag bit.

Source

pub const VERBOSITY_3: Self

Wraps the VERBOSITY_3 AppleArchive archive flag bit.

Source

pub const fn empty() -> Self

Wraps an empty AppleArchive archive flag set.

Examples found in repository?
examples/06_aa_entry_stream_path_list.rs (line 18)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let artifact_dir = artifact_dir("aa-entry-stream");
9    fs::create_dir_all(artifact_dir.join("nested"))?;
10    fs::write(
11        artifact_dir.join("nested").join("example.txt"),
12        b"entry stream",
13    )?;
14
15    let path_list = PathList::from_directory_contents(
16        &path_string(&artifact_dir),
17        None,
18        ArchiveFlags::empty(),
19        0,
20    )?;
21    let paths = path_list.paths()?;
22    assert!(paths.iter().any(|path| path.ends_with("example.txt")));
23    println!("paths={paths:?}");
24    println!("✅ AppleArchive entry/path-list APIs OK");
25    Ok(())
26}
More examples
Hide additional examples
examples/05_aa_byte_stream_pipeline.rs (line 27)
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11    let input = pseudo_random_bytes(32 * 1024);
12    let artifact_dir = artifact_dir("aa-byte-stream");
13    let plain_path = artifact_dir.join("payload.bin");
14    let compressed_path = artifact_dir.join("payload.pbzx");
15    fs::write(&plain_path, &input)?;
16
17    let mut input_stream =
18        ByteStream::open_with_path(&path_string(&plain_path), OPEN_READ_ONLY, 0)?;
19    let compressed_stream = ByteStream::open_with_path(
20        &path_string(&compressed_path),
21        OPEN_WRITE_ONLY | OPEN_CREATE | OPEN_TRUNCATE,
22        DEFAULT_FILE_MODE,
23    )?;
24    let mut compressed_stream = compressed_stream.into_compression_output(
25        ArchiveCompressionAlgorithm::Lzfse,
26        64 * 1024,
27        ArchiveFlags::empty(),
28        0,
29    )?;
30    input_stream.process_into(&mut compressed_stream)?;
31    compressed_stream.close()?;
32
33    let compressed_stream =
34        ByteStream::open_with_path(&path_string(&compressed_path), OPEN_READ_ONLY, 0)?;
35    let mut decompressed_stream =
36        compressed_stream.into_decompression_input(ArchiveFlags::empty(), 0)?;
37    let output = decompressed_stream.read_to_end()?;
38    assert_eq!(output, input);
39    decompressed_stream.close()?;
40
41    let compressed_len = fs::metadata(&compressed_path)?.len();
42    println!("compressed bytes={compressed_len}");
43    println!("✅ AppleArchive byte-stream pipeline OK");
44    Ok(())
45}
examples/09_aa_entry_blobs.rs (line 32)
9fn main() -> Result<(), Box<dyn std::error::Error>> {
10    let artifact_dir = artifact_dir("aa-entry-blobs");
11    let dir = path_string(&artifact_dir);
12    let source_name = "source.txt";
13    let target_name = "target.txt";
14    let source_path = path_string(&artifact_dir.join(source_name));
15    let target_path = path_string(&artifact_dir.join(target_name));
16    fs::write(&source_path, b"blob source")?;
17    fs::write(&target_path, b"blob target")?;
18
19    Command::new("xattr")
20        .args(["-w", "com.example.compression-rs", "example", &source_path])
21        .status()?;
22
23    let acl_entry = AccessControlEntry {
24        tag: 1,
25        perms: 1 << 1,
26        flags: 0,
27        qualifier_type: AceQualifierType::User,
28        qualifier: env::var("USER")?.into_bytes(),
29    };
30    let mut acl = EntryAclBlob::new()?;
31    acl.append_entry(&acl_entry)?;
32    let xat = EntryXatBlob::from_path(&dir, source_name, ArchiveFlags::empty())?;
33    if !acl.is_empty() {
34        let encoded = acl.encoded_data()?;
35        let decoded = EntryAclBlob::from_encoded_data(&encoded)?;
36        decoded.apply_to_path(&dir, target_name, ArchiveFlags::REPLACE_ATTRIBUTES)?;
37    }
38    let encoded_xat = xat.encoded_data()?;
39    let decoded_xat = EntryXatBlob::from_encoded_data(&encoded_xat)?;
40    decoded_xat.apply_to_path(&dir, target_name, ArchiveFlags::REPLACE_ATTRIBUTES)?;
41
42    println!(
43        "acl_entries={} xattrs={}",
44        acl.entry_count(),
45        xat.entry_count()
46    );
47    println!("✅ AppleArchive ACL/XAT blob helpers OK");
48    Ok(())
49}
examples/10_aea_roundtrip.rs (line 25)
10fn main() -> Result<(), Box<dyn std::error::Error>> {
11    let artifact_dir = artifact_dir("aea-roundtrip");
12    let archive_path = path_string(&artifact_dir.join("example.aea"));
13    let payload = pseudo_random_bytes(16 * 1024);
14
15    let mut context = AeaContext::with_profile(AeaProfile::HkdfSha256AesctrHmacSymmetricNone)?;
16    context.set_padding_size(AeaPadding::NONE)?;
17    context.set_compression_algorithm(ArchiveCompressionAlgorithm::Lzfse)?;
18    context.generate_field_blob(AeaContextField::SymmetricKey)?;
19
20    let stream = ByteStream::open_with_path(
21        &archive_path,
22        OPEN_READ_WRITE | OPEN_CREATE | OPEN_TRUNCATE,
23        DEFAULT_FILE_MODE,
24    )?;
25    let mut encrypted = context.encryption_output_stream(stream, ArchiveFlags::empty(), 0)?;
26    encrypted.write_all(&payload)?;
27    context.close_encryption_output_stream(&mut encrypted)?;
28
29    let symmetric_key = context.field_blob(
30        AeaContextField::SymmetricKey,
31        AeaContextFieldRepresentation::Raw,
32    )?;
33    let mut input = ByteStream::open_with_path(&archive_path, OPEN_READ_ONLY, 0)?;
34    let mut decrypt_context = AeaContext::from_encrypted_stream(&mut input)?;
35    decrypt_context.set_symmetric_key(&symmetric_key)?;
36    let mut decrypted = decrypt_context.decryption_input_stream(input, ArchiveFlags::empty(), 0)?;
37    assert_eq!(decrypted.read_to_end()?, payload);
38
39    println!(
40        "raw_size={} container_size={}",
41        context.raw_size()?,
42        context.container_size()?
43    );
44    println!("✅ AppleEncryptedArchive roundtrip OK");
45    Ok(())
46}
examples/04_aa_archive_stream_roundtrip.rs (line 28)
9fn main() -> Result<(), Box<dyn std::error::Error>> {
10    let data = b"hello from apple archive".to_vec();
11    let artifact_dir = artifact_dir("aa-archive-stream");
12    let archive_path = artifact_dir.join("sample.aar");
13    let archive_path = path_string(&archive_path);
14
15    let mut header = Header::new()?;
16    let regular_file = u64::from(b'F');
17    let data_len = u64::try_from(data.len())?;
18    header.append_field_uint(FieldKey::TYP, regular_file)?;
19    header.append_field_string(FieldKey::PAT, "greeting.txt")?;
20    header.append_field_uint(FieldKey::SIZ, data_len)?;
21    header.append_field_blob(FieldKey::DAT, data_len)?;
22
23    let byte_stream = ByteStream::open_with_path(
24        &archive_path,
25        OPEN_WRITE_ONLY | OPEN_CREATE | OPEN_TRUNCATE,
26        DEFAULT_FILE_MODE,
27    )?;
28    let mut archive = ArchiveStream::encode_output(byte_stream, ArchiveFlags::empty(), 0)?;
29    archive.write_header(&header)?;
30    archive.write_blob(FieldKey::DAT, &data)?;
31    archive.close()?;
32
33    let byte_stream = ByteStream::open_with_path(&archive_path, OPEN_READ_ONLY, 0)?;
34    let mut archive = ArchiveStream::decode_input(byte_stream, ArchiveFlags::empty(), 0)?;
35    let header = archive.read_header()?.expect("archive entry");
36    assert_eq!(header.path()?.as_deref(), Some("greeting.txt"));
37    let blob = header.blob_with_key(FieldKey::DAT)?.expect("blob field");
38    let mut decoded = vec![0_u8; usize::try_from(blob.size)?];
39    archive.read_blob(FieldKey::DAT, &mut decoded)?;
40    assert_eq!(decoded, data);
41    assert!(archive.read_header()?.is_none());
42    archive.close()?;
43
44    println!("archive path={archive_path}");
45    println!("✅ AppleArchive round-trip OK");
46    Ok(())
47}
Source

pub const fn bits(self) -> u64

Wraps the raw AppleArchive archive flag bits.

Source

pub const fn from_bits(bits: u64) -> Self

Wraps raw AppleArchive archive flag bits.

Source

pub const fn contains(self, other: Self) -> bool

Wraps AppleArchive archive flag containment checks.

Source

pub const fn verbosity(level: u64) -> Self

Wraps AppleArchive archive verbosity flag construction.

Trait Implementations§

Source§

impl BitAnd for ArchiveFlags

Source§

type Output = ArchiveFlags

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
Source§

impl BitAndAssign for ArchiveFlags

Source§

fn bitand_assign(&mut self, rhs: Self)

Performs the &= operation. Read more
Source§

impl BitOr for ArchiveFlags

Source§

type Output = ArchiveFlags

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign for ArchiveFlags

Source§

fn bitor_assign(&mut self, rhs: Self)

Performs the |= operation. Read more
Source§

impl Clone for ArchiveFlags

Source§

fn clone(&self) -> ArchiveFlags

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 Copy for ArchiveFlags

Source§

impl Debug for ArchiveFlags

Source§

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

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

impl Default for ArchiveFlags

Source§

fn default() -> ArchiveFlags

Returns the “default value” for a type. Read more
Source§

impl Eq for ArchiveFlags

Source§

impl Hash for ArchiveFlags

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 ArchiveFlags

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ArchiveFlags

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.