feat(nix-compat/narinfo): track presence of unknown fields
Change-Id: Ia3f8a86209a0045ff98322b56a21ae20220fbe99 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9991 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
8694694b74
commit
407e5a53ed
1 changed files with 5 additions and 1 deletions
|
@ -31,6 +31,7 @@ use crate::{
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NarInfo<'a> {
|
pub struct NarInfo<'a> {
|
||||||
|
pub unknown_fields: bool,
|
||||||
// core (authenticated, but unverified here)
|
// core (authenticated, but unverified here)
|
||||||
/// Store path described by this [NarInfo]
|
/// Store path described by this [NarInfo]
|
||||||
pub store_path: StorePathRef<'a>,
|
pub store_path: StorePathRef<'a>,
|
||||||
|
@ -64,6 +65,8 @@ pub struct NarInfo<'a> {
|
||||||
|
|
||||||
impl<'a> NarInfo<'a> {
|
impl<'a> NarInfo<'a> {
|
||||||
pub fn parse(input: &'a str) -> Result<Self, Error> {
|
pub fn parse(input: &'a str) -> Result<Self, Error> {
|
||||||
|
let mut unknown_fields = false;
|
||||||
|
|
||||||
let mut store_path = None;
|
let mut store_path = None;
|
||||||
let mut url = None;
|
let mut url = None;
|
||||||
let mut compression = None;
|
let mut compression = None;
|
||||||
|
@ -218,12 +221,13 @@ impl<'a> NarInfo<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// unknown field, ignore
|
unknown_fields = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(NarInfo {
|
Ok(NarInfo {
|
||||||
|
unknown_fields,
|
||||||
store_path: store_path.ok_or(Error::MissingField("StorePath"))?,
|
store_path: store_path.ok_or(Error::MissingField("StorePath"))?,
|
||||||
nar_hash: nar_hash.ok_or(Error::MissingField("NarHash"))?,
|
nar_hash: nar_hash.ok_or(Error::MissingField("NarHash"))?,
|
||||||
nar_size: nar_size.ok_or(Error::MissingField("NarSize"))?,
|
nar_size: nar_size.ok_or(Error::MissingField("NarSize"))?,
|
||||||
|
|
Loading…
Add table
Reference in a new issue