Skip to main content

EntryAclBlob

Struct EntryAclBlob 

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

Wraps an AAEntryACLBlob handle.

Implementations§

Source§

impl EntryAclBlob

Source

pub fn new() -> Result<Self>

Wraps AAEntryACLBlobCreate.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 30)
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}
Source

pub fn from_encoded_data(data: &[u8]) -> Result<Self>

Wraps AAEntryACLBlobCreateWithEncodedData.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 35)
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}
Source

pub fn from_path(dir: &str, path: &str, flags: ArchiveFlags) -> Result<Self>

Wraps AAEntryACLBlobCreateWithPath.

Source

pub fn apply_to_path( &self, dir: &str, path: &str, flags: ArchiveFlags, ) -> Result<()>

Wraps AAEntryACLBlobApplyToPath.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 36)
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}
Source

pub fn entry_count(&self) -> u32

Wraps AAEntryACLBlobGetEntry.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 44)
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}
Source

pub fn is_empty(&self) -> bool

Wraps AAEntryACLBlobGetEntry.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 33)
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}
Source

pub fn entry(&self, index: u32) -> Result<AccessControlEntry>

Wraps AAEntryACLBlobGetEntry.

Source

pub fn entries(&self) -> Result<Vec<AccessControlEntry>>

Wraps AAEntryACLBlobAppendEntry.

Source

pub fn append_entry(&mut self, entry: &AccessControlEntry) -> Result<()>

Wraps AAEntryACLBlobAppendEntry.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 31)
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}
Source

pub fn set_entry( &mut self, index: u32, entry: &AccessControlEntry, ) -> Result<()>

Wraps AAEntryACLBlobSetEntry.

Source

pub fn clear(&mut self) -> Result<()>

Wraps AAEntryACLBlobClear.

Source

pub fn remove_entry(&mut self, index: u32) -> Result<()>

Wraps AAEntryACLBlobRemoveEntry.

Source

pub fn encoded_size(&self) -> usize

Wraps AAEntryACLBlobGetEncodedData.

Source

pub fn encoded_data(&self) -> Result<Vec<u8>>

Wraps AAEntryACLBlobGetEncodedData.

Examples found in repository?
examples/09_aa_entry_blobs.rs (line 34)
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}

Trait Implementations§

Source§

impl Clone for EntryAclBlob

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 EntryAclBlob

Source§

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

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

impl Drop for EntryAclBlob

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.