about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-22T19·47+0200
committerflokli <flokli@flokli.de>2023-11-22T20·37+0000
commit639cca3e22706533d38b6af258767b985c191c45 (patch)
tree975cbb3892b63ecb6d9d80100f30f22eff90f295
parentc44cbc852a26e88d613b0f2498223d02eb603848 (diff)
feat(nix-compat/narinfo/signature): add new() constructor r/7050
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 <edef@edef.eu>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
-rw-r--r--tvix/nix-compat/src/narinfo/signature.rs5
1 files changed, 5 insertions, 0 deletions
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<Signature<'a>, SignatureError> {
         let (name, bytes64) = input
             .split_once(':')