feat(tvix/nix-compat): implement Serialize, Deserialize for NixHash
We use the (slightly more tolerant) from_str to deserialize, and serialize out as SRI. Change-Id: If76b0ed2d4e243904f02df34f6c90b976c0bab8c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11393 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
57fba1f167
commit
a2322d7c14
3 changed files with 50 additions and 9 deletions
|
|
@ -48,7 +48,7 @@ pub(crate) fn parse(i: &[u8]) -> Result<Derivation, Error<&[u8]>> {
|
|||
fn from_algo_and_mode_and_digest<B: AsRef<[u8]>>(
|
||||
algo_and_mode: &str,
|
||||
digest: B,
|
||||
) -> crate::nixhash::Result<CAHash> {
|
||||
) -> crate::nixhash::NixHashResult<CAHash> {
|
||||
Ok(match algo_and_mode.strip_prefix("r:") {
|
||||
Some(algo) => nixhash::CAHash::Nar(nixhash::from_algo_and_digest(
|
||||
algo.try_into()?,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue