Compare commits

..

No commits in common. "6bed1a222e20d33d5d97ad30d82034a5758c268a" and "3b8681360f8878e9c5039a3a2f3704b39fe5aa5a" have entirely different histories.

3 changed files with 12 additions and 14 deletions

View file

@ -8,4 +8,3 @@ NarSize: 11374872
References: mhhlymrg2m70r8h94cwhv2d7a0c8l7g6-glibc-2.34-210 ppn8983d9b5r6k7mnhkbg6rqw7vgl1ij-libyaml-0.2.5 qm2lv1gpbyn0rsfai40cbvj3h4gz69yc-bash-5.1-p16 sn0w3f12547crckss4ybmnxmi29gpgq7-perl-5.34.1 zzxrhj9056vjlanfjkinvhd7458yc2z8-liblouis-3.22.0 References: mhhlymrg2m70r8h94cwhv2d7a0c8l7g6-glibc-2.34-210 ppn8983d9b5r6k7mnhkbg6rqw7vgl1ij-libyaml-0.2.5 qm2lv1gpbyn0rsfai40cbvj3h4gz69yc-bash-5.1-p16 sn0w3f12547crckss4ybmnxmi29gpgq7-perl-5.34.1 zzxrhj9056vjlanfjkinvhd7458yc2z8-liblouis-3.22.0
Deriver: dlxmsgfc0am35fh0kiy88zqr91x2dn5j-liblouis-3.22.0.drv Deriver: dlxmsgfc0am35fh0kiy88zqr91x2dn5j-liblouis-3.22.0.drv
Sig: cache.nixos.org-1:BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ== Sig: cache.nixos.org-1:BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ==
Sig: fake-test-sig-1:BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ==

View file

@ -23,8 +23,6 @@ impl<'a> NarInfo<'a> {
/// ``` /// ```
pub fn parse(value: &'a str) -> ParsingResult<Self> { pub fn parse(value: &'a str) -> ParsingResult<Self> {
let mut builder = NarInfoBuilder::default(); let mut builder = NarInfoBuilder::default();
let mut sigs = Vec::new();
for line in value.lines() { for line in value.lines() {
let (key, value) = line let (key, value) = line
.split_once(':') .split_once(':')
@ -48,15 +46,20 @@ impl<'a> NarInfo<'a> {
"Deriver" => builder.deriver(Some(Cow::from(value))), "Deriver" => builder.deriver(Some(Cow::from(value))),
"System" => builder.system(Some(Cow::from(value))), "System" => builder.system(Some(Cow::from(value))),
"References" => builder.references(value.split(' ').map(Cow::from).collect()), "References" => builder.references(value.split(' ').map(Cow::from).collect()),
"Sig" => { // TODO: replace with try_collect once that gets stabilized
sigs.push(Sig::try_from(value)?); "Sig" => builder.sigs(value.split(' ').map(Sig::try_from).try_fold(
&mut builder Vec::new(),
}, |mut a, c| {
c.map(|c| {
a.push(c);
a
})
},
)?),
_ => return Err(ParsingError::UnknownKey { key }), _ => return Err(ParsingError::UnknownKey { key }),
}; };
} }
builder.sigs(sigs);
builder.build() builder.build()
} }
} }
@ -121,10 +124,6 @@ mod tests {
assert_eq!(sig.key_name, "cache.nixos.org-1"); assert_eq!(sig.key_name, "cache.nixos.org-1");
assert_eq!(sig.sig, "BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ=="); assert_eq!(sig.sig, "BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ==");
let sig = &info.sigs[1]; assert!(info.sigs.len() == 1);
assert_eq!(sig.key_name, "fake-test-sig-1");
assert_eq!(sig.sig, "BJ5QGcOta2s76XC6sep9DbAv0x3TILh3hHSKyR+9rFWYuBDTWdHs1KHeUEpw2espE/zPPBp2yURO6/J4Dhf9DQ==");
assert!(info.sigs.len() == 2);
} }
} }

View file

@ -17,8 +17,8 @@ impl<'a> NarInfo<'a> {
write!(w, "\nNarSize: {}", self.nar_size)?; write!(w, "\nNarSize: {}", self.nar_size)?;
write!(w, "\nReferences: {}", self.references.join(" "))?; write!(w, "\nReferences: {}", self.references.join(" "))?;
write!(w, "\nSig: ")?;
for sig in self.sigs.iter() { for sig in self.sigs.iter() {
write!(w, "\nSig: ")?;
sig.serialize_into(w)?; sig.serialize_into(w)?;
} }