Skip to content

Commit 100545d

Browse files
netomiindygreg
authored andcommitted
apple-xar: add id attribute for extended attribute struct
Closes #155.
1 parent 5fb3af6 commit 100545d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

apple-xar/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
Released on ReleaseDate.
88

9+
* Added `id` field to `Ea` struct. (#155)
910
* `base64` 0.21 -> 0.22.
1011
* `cryptographic-message-syntax` 0.26 -> 0.27.
1112
* `reqwest` 0.11 -> 0.12.

apple-xar/src/table_of_contents.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ pub struct FileEncoding {
505505
#[derive(Clone, Debug, Deserialize)]
506506
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
507507
pub struct Ea {
508+
#[serde(skip_serializing_if = "Option::is_none")]
509+
pub id: Option<u64>,
508510
pub name: String,
509511
pub offset: u64,
510512
pub size: u64,
@@ -516,7 +518,15 @@ pub struct Ea {
516518

517519
impl Ea {
518520
pub fn write_xml<W: Write>(&self, writer: &mut EventWriter<W>) -> XarResult<()> {
519-
writer.write(XmlEvent::start_element("ea"))?;
521+
let mut ea = XmlEvent::start_element("ea");
522+
523+
let id = self.id.map(|x| format!("{}", x));
524+
525+
if let Some(id) = &id {
526+
ea = ea.attr("id", id.as_str());
527+
}
528+
529+
writer.write(ea)?;
520530

521531
writer.write(XmlEvent::start_element("name"))?;
522532
writer.write(XmlEvent::characters(&self.name))?;

0 commit comments

Comments
 (0)