Fix the sig parsing in narinfo parsing code #3
1 changed files with 7 additions and 10 deletions
|
@ -23,6 +23,8 @@ 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(':')
|
||||||
|
@ -46,20 +48,15 @@ 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()),
|
||||||
// TODO: replace with try_collect once that gets stabilized
|
"Sig" => {
|
||||||
"Sig" => builder.sigs(value.split(' ').map(Sig::try_from).try_fold(
|
sigs.push(Sig::try_from(value)?);
|
||||||
Vec::new(),
|
&mut builder
|
||||||
|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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue