Compare commits
2 commits
libnixstor
...
mistress
Author | SHA1 | Date | |
---|---|---|---|
|
eb22e800a1 | ||
|
7548018491 |
6 changed files with 4 additions and 58 deletions
|
@ -1,18 +1,11 @@
|
|||
[package]
|
||||
name = "narinfo"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
edition = "2021"
|
||||
description = "A parser for the narinfo file format"
|
||||
repository = "https://im.badat.dev/bad/narinfo-rs"
|
||||
license = "MIT OR Apache-2.0"
|
||||
keywords = ["nix", "nixos"]
|
||||
|
||||
[features]
|
||||
libnixstore = ["dep:libnixstore"]
|
||||
|
||||
[dependencies]
|
||||
derive_builder = { version = "0.11.2", default-features = false }
|
||||
libnixstore = { version = "0.2.0", optional = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
|
10
shell.nix
10
shell.nix
|
@ -1,10 +0,0 @@
|
|||
with import <nixpkgs> { };
|
||||
mkShell {
|
||||
nativeBuildInputs = [
|
||||
nix
|
||||
nlohmann_json
|
||||
libsodium
|
||||
boost
|
||||
pkg-config
|
||||
];
|
||||
}
|
|
@ -6,13 +6,10 @@ extern crate alloc;
|
|||
|
||||
pub mod error;
|
||||
|
||||
pub mod narinfo;
|
||||
pub mod nix_cache_info;
|
||||
mod narinfo;
|
||||
mod nix_cache_info;
|
||||
mod sig;
|
||||
|
||||
#[cfg(feature = "libnixstore")]
|
||||
mod libnixstore;
|
||||
|
||||
pub use crate::narinfo::NarInfo;
|
||||
pub use nix_cache_info::NixCacheInfo;
|
||||
pub use sig::Sig;
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
use crate::narinfo::NarInfoBuilder;
|
||||
use crate::Sig;
|
||||
use alloc::borrow::Cow;
|
||||
|
||||
impl<'a> NarInfoBuilder<'a> {
|
||||
/// Read and set the store dir from [`libnixstore`].
|
||||
///
|
||||
/// This function assumes that [`libnixstore::init`] has already been called
|
||||
pub fn store_dir_from_libnixstore(&mut self) -> &Self {
|
||||
let store_dir = libnixstore::get_store_dir();
|
||||
self.store_path(Cow::Owned(store_dir));
|
||||
self
|
||||
}
|
||||
|
||||
/// Read and set `path`, `references` and `sigs` from a [`libnixstore::PathInfo`]
|
||||
pub fn attr_from_libnixstore_path(&mut self, path: &'a libnixstore::PathInfo) -> &Self {
|
||||
self.file_size(Some(path.size));
|
||||
self.references(path.refs.iter().map(Cow::from).collect());
|
||||
self.sigs(
|
||||
path.sigs
|
||||
.iter()
|
||||
.map(|v| Sig::parse(v).expect("libnixstore provided signature should be in a valid format"))
|
||||
.collect());
|
||||
|
||||
self
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ impl<'a> NarInfo<'a> {
|
|||
"System" => builder.system(Some(Cow::from(value))),
|
||||
"References" => builder.references(value.split(' ').map(Cow::from).collect()),
|
||||
"Sig" => {
|
||||
sigs.push(Sig::try_from(value)?);
|
||||
sigs.push(Sig::parse(value)?);
|
||||
&mut builder
|
||||
},
|
||||
_ => return Err(ParsingError::UnknownKey { key }),
|
||||
|
|
|
@ -12,13 +12,6 @@ pub struct Sig<'a> {
|
|||
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
|
||||
// it doesn't really make sense to de/serialize the
|
||||
// sig into the narinfo format outside of de/serializing a whole narinfo
|
||||
|
|
Loading…
Reference in a new issue