pub struct EntryXatBlob { /* private fields */ }Expand description
Wraps an AAEntryXATBlob handle.
Implementations§
Source§impl EntryXatBlob
impl EntryXatBlob
Sourcepub fn from_encoded_data(data: &[u8]) -> Result<Self>
pub fn from_encoded_data(data: &[u8]) -> Result<Self>
Wraps AAEntryXATBlobCreateWithEncodedData.
Examples found in repository?
examples/09_aa_entry_blobs.rs (line 39)
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}Sourcepub fn from_path(dir: &str, path: &str, flags: ArchiveFlags) -> Result<Self>
pub fn from_path(dir: &str, path: &str, flags: ArchiveFlags) -> Result<Self>
Wraps AAEntryXATBlobCreateWithPath.
Examples found in repository?
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}Sourcepub fn apply_to_path(
&self,
dir: &str,
path: &str,
flags: ArchiveFlags,
) -> Result<()>
pub fn apply_to_path( &self, dir: &str, path: &str, flags: ArchiveFlags, ) -> Result<()>
Wraps AAEntryXATBlobApplyToPath.
Examples found in repository?
examples/09_aa_entry_blobs.rs (line 40)
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}Sourcepub fn entry_count(&self) -> u32
pub fn entry_count(&self) -> u32
Wraps AAEntryXATBlobGetEntry.
Examples found in repository?
examples/09_aa_entry_blobs.rs (line 45)
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}Sourcepub fn entry(&self, index: u32) -> Result<NamedBlobEntry>
pub fn entry(&self, index: u32) -> Result<NamedBlobEntry>
Wraps AAEntryXATBlobGetEntry.
Sourcepub fn entries(&self) -> Result<Vec<NamedBlobEntry>>
pub fn entries(&self) -> Result<Vec<NamedBlobEntry>>
Wraps AAEntryXATBlobAppendEntry.
Sourcepub fn append_entry(&mut self, entry: &NamedBlobEntry) -> Result<()>
pub fn append_entry(&mut self, entry: &NamedBlobEntry) -> Result<()>
Wraps AAEntryXATBlobAppendEntry.
Sourcepub fn set_entry(&mut self, index: u32, entry: &NamedBlobEntry) -> Result<()>
pub fn set_entry(&mut self, index: u32, entry: &NamedBlobEntry) -> Result<()>
Wraps AAEntryXATBlobSetEntry.
Sourcepub fn remove_entry(&mut self, index: u32) -> Result<()>
pub fn remove_entry(&mut self, index: u32) -> Result<()>
Wraps AAEntryXATBlobRemoveEntry.
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
Wraps AAEntryXATBlobGetEncodedData.
Sourcepub fn encoded_data(&self) -> Result<Vec<u8>>
pub fn encoded_data(&self) -> Result<Vec<u8>>
Wraps AAEntryXATBlobGetEncodedData.
Examples found in repository?
examples/09_aa_entry_blobs.rs (line 38)
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 EntryXatBlob
impl Clone for EntryXatBlob
Source§impl Debug for EntryXatBlob
impl Debug for EntryXatBlob
Source§impl Drop for EntryXatBlob
impl Drop for EntryXatBlob
Auto Trait Implementations§
impl Freeze for EntryXatBlob
impl RefUnwindSafe for EntryXatBlob
impl !Send for EntryXatBlob
impl !Sync for EntryXatBlob
impl Unpin for EntryXatBlob
impl UnsafeUnpin for EntryXatBlob
impl UnwindSafe for EntryXatBlob
Blanket Implementations§
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