From f13bd04fadbad97c7087703ce548cf8c674a23a5 Mon Sep 17 00:00:00 2001 From: "Charles E. Lehner" Date: Fri, 11 Mar 2022 13:35:49 -0500 Subject: [PATCH] Constrain signature to be referencable as bytes --- src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 87d79c3..002699e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,10 +87,23 @@ pub enum VerificationError { NotCurrentlyValid, } -pub struct BasicSignature { +pub struct BasicSignature + TryFrom>> { pub s: S, } +impl + TryFrom>> AsRef<[u8]> for BasicSignature { + fn as_ref(&self) -> &[u8] { + self.s.as_ref() + } +} + +impl + TryFrom>> TryFrom> for BasicSignature { + type Error = >>::Error; + fn try_from(s: Vec) -> Result { + Ok(Self { s: s.try_into()? }) + } +} + #[derive(Copy, Clone)] pub enum Version { V1 = 1,