Compare commits

..

No commits in common. "mistress" and "fix-sig-parsing" have entirely different histories.

3 changed files with 9 additions and 2 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "narinfo" name = "narinfo"
version = "1.0.1" version = "1.0.0"
edition = "2021" edition = "2021"
description = "A parser for the narinfo file format" description = "A parser for the narinfo file format"
repository = "https://im.badat.dev/bad/narinfo-rs" repository = "https://im.badat.dev/bad/narinfo-rs"

View file

@ -49,7 +49,7 @@ impl<'a> NarInfo<'a> {
"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" => { "Sig" => {
sigs.push(Sig::parse(value)?); sigs.push(Sig::try_from(value)?);
&mut builder &mut builder
}, },
_ => return Err(ParsingError::UnknownKey { key }), _ => return Err(ParsingError::UnknownKey { key }),

View file

@ -12,6 +12,13 @@ pub struct Sig<'a> {
pub sig: Cow<'a, str>, pub sig: Cow<'a, str>,
} }
impl<'a> TryFrom<&'a str> for Sig<'a> {
type Error = ParsingError<'a>;
fn try_from(value: &'a str) -> ParsingResult<Self> {
Sig::parse(value)
}
}
// Neither the parse nor the serializa method is public since // Neither the parse nor the serializa method is public since
// it doesn't really make sense to de/serialize the // it doesn't really make sense to de/serialize the
// sig into the narinfo format outside of de/serializing a whole narinfo // sig into the narinfo format outside of de/serializing a whole narinfo