From 639cca3e22706533d38b6af258767b985c191c45 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 22 Nov 2023 21:47:28 +0200 Subject: feat(nix-compat/narinfo/signature): add new() constructor This is useful when creating a new Signature struct where the individual elements are already parsed. Change-Id: Ie33c66287641951e7a030aaa1e7ff0a86b2628ac Reviewed-on: https://cl.tvl.fyi/c/depot/+/10111 Reviewed-by: edef Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/nix-compat/src/narinfo/signature.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tvix/nix-compat') diff --git a/tvix/nix-compat/src/narinfo/signature.rs b/tvix/nix-compat/src/narinfo/signature.rs index a0e56f93488e..c7d2e1ecbcf7 100644 --- a/tvix/nix-compat/src/narinfo/signature.rs +++ b/tvix/nix-compat/src/narinfo/signature.rs @@ -4,11 +4,16 @@ use data_encoding::BASE64; #[derive(Debug)] pub struct Signature<'a> { + /// TODO(edef): be stricter with signature names here, they especially shouldn't have newlines! name: &'a str, bytes: [u8; 64], } impl<'a> Signature<'a> { + pub fn new(name: &'a str, bytes: [u8; 64]) -> Self { + Self { name, bytes } + } + pub fn parse(input: &'a str) -> Result, SignatureError> { let (name, bytes64) = input .split_once(':') -- cgit 1.4.1