From 407e5a53ede9c8525c6814fcbb0cb4d07bb4f3f4 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 10 Nov 2023 15:42:23 +0000 Subject: feat(nix-compat/narinfo): track presence of unknown fields Change-Id: Ia3f8a86209a0045ff98322b56a21ae20220fbe99 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9991 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/nix-compat/src/narinfo.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tvix/nix-compat/src/narinfo.rs b/tvix/nix-compat/src/narinfo.rs index 6a070b35ac0f..62b0c3524bdf 100644 --- a/tvix/nix-compat/src/narinfo.rs +++ b/tvix/nix-compat/src/narinfo.rs @@ -31,6 +31,7 @@ use crate::{ #[derive(Debug)] pub struct NarInfo<'a> { + pub unknown_fields: bool, // core (authenticated, but unverified here) /// Store path described by this [NarInfo] pub store_path: StorePathRef<'a>, @@ -64,6 +65,8 @@ pub struct NarInfo<'a> { impl<'a> NarInfo<'a> { pub fn parse(input: &'a str) -> Result { + let mut unknown_fields = false; + let mut store_path = None; let mut url = None; let mut compression = None; @@ -218,12 +221,13 @@ impl<'a> NarInfo<'a> { } } _ => { - // unknown field, ignore + unknown_fields = true; } } } Ok(NarInfo { + unknown_fields, store_path: store_path.ok_or(Error::MissingField("StorePath"))?, nar_hash: nar_hash.ok_or(Error::MissingField("NarHash"))?, nar_size: nar_size.ok_or(Error::MissingField("NarSize"))?, -- cgit 1.4.1