diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-10T21·06+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-10-14T13·23+0000 |
commit | 5f8eb4eeaaad31aedc45efee3143e6b0bbc982a4 (patch) | |
tree | 24633312e41753a3cf2686da98d927bb7e1e0042 /tvix/store/src/proto | |
parent | 173641ed37318fe61886ccb0402a9929b0f5783d (diff) |
feat(tvix/store/protos): add StorePath message r/6804
This encodes a store path a bit more concise, which is used in the Deriver field. Change-Id: Ibfb54d3b206917e51970d1d5fe94fcedb901704b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9646 Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/proto')
-rw-r--r-- | tvix/store/src/proto/mod.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs index 7921adc4062e..718e24912de1 100644 --- a/tvix/store/src/proto/mod.rs +++ b/tvix/store/src/proto/mod.rs @@ -1,7 +1,7 @@ #![allow(clippy::derive_partial_eq_without_eq, non_snake_case)] use data_encoding::BASE64; // https://github.com/hyperium/tonic/issues/1056 -use nix_compat::store_path::{self, StorePath}; +use nix_compat::store_path; use thiserror::Error; use tvix_castore::proto::{self as castorepb, NamedNode, ValidateNodeError}; @@ -64,13 +64,13 @@ pub enum ValidatePathInfoError { /// Parses a root node name. /// -/// On success, this returns the parsed [StorePath]. +/// On success, this returns the parsed [store_path::StorePath]. /// On error, it returns an error generated from the supplied constructor. fn parse_node_name_root<E>( name: &[u8], err: fn(Vec<u8>, store_path::Error) -> E, -) -> Result<StorePath, E> { - match StorePath::from_bytes(name) { +) -> Result<store_path::StorePath, E> { + match store_path::StorePath::from_bytes(name) { Ok(np) => Ok(np), Err(e) => Err(err(name.to_vec(), e)), } @@ -78,9 +78,9 @@ fn parse_node_name_root<E>( impl PathInfo { /// validate performs some checks on the PathInfo struct, - /// Returning either a [StorePath] of the root node, or a + /// Returning either a [store_path::StorePath] of the root node, or a /// [ValidatePathInfoError]. - pub fn validate(&self) -> Result<StorePath, ValidatePathInfoError> { + pub fn validate(&self) -> Result<store_path::StorePath, ValidatePathInfoError> { // ensure the references have the right number of bytes. for (i, reference) in self.references.iter().enumerate() { if reference.len() != store_path::DIGEST_SIZE { @@ -111,13 +111,15 @@ impl PathInfo { // parse references in reference_names. for (i, reference_name_str) in narinfo.reference_names.iter().enumerate() { // ensure thy parse as (non-absolute) store path - let reference_names_store_path = - StorePath::from_bytes(reference_name_str.as_bytes()).map_err(|_| { - ValidatePathInfoError::InvalidNarinfoReferenceName( - i, - reference_name_str.to_owned(), - ) - })?; + let reference_names_store_path = store_path::StorePath::from_bytes( + reference_name_str.as_bytes(), + ) + .map_err(|_| { + ValidatePathInfoError::InvalidNarinfoReferenceName( + i, + reference_name_str.to_owned(), + ) + })?; // ensure their digest matches the one at self.references[i]. { @@ -137,7 +139,7 @@ impl PathInfo { } } - // Ensure there is a (root) node present, and it properly parses to a [StorePath]. + // Ensure there is a (root) node present, and it properly parses to a [store_path::StorePath]. let root_nix_path = match &self.node { None | Some(castorepb::Node { node: None }) => { Err(ValidatePathInfoError::NoNodePresent())? |