1
1
use std:: { hash:: Hash , marker:: PhantomData , ops:: Deref } ;
2
2
3
3
use committable:: { Commitment , Committable , RawCommitmentBuilder } ;
4
+ use minicbor:: { Decode , Encode } ;
4
5
use serde:: { Deserialize , Serialize } ;
5
6
6
7
use crate :: { Committee , Keypair , Signed } ;
7
8
8
9
/// Marker type to denote envelopes whose signature has not been validated.
9
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , Serialize , Deserialize ) ]
10
+ #[ derive(
11
+ Clone , Copy , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , Serialize , Deserialize , Encode , Decode ,
12
+ ) ]
10
13
pub enum Unchecked { }
11
14
12
15
/// Marker type to denote envelopes whose signature has been validated.
13
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , Serialize ) ]
16
+ #[ derive( Clone , Copy , Debug , Eq , PartialEq , PartialOrd , Ord , Hash , Serialize , Encode ) ]
14
17
pub enum Validated { }
15
18
16
19
/// An envelope contains data, its signed commitment hash and the signing key.
@@ -25,12 +28,18 @@ pub enum Validated {}
25
28
/// let _: Envelope<Signature, Validated> =
26
29
/// bincode::serde::decode_from_slice(&[], bincode::config::standard()).unwrap().0;
27
30
/// ```
28
- #[ derive( Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord , Serialize , Deserialize ) ]
31
+ #[ derive(
32
+ Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord , Serialize , Deserialize , Encode , Decode ,
33
+ ) ]
29
34
#[ serde( bound( deserialize = "D: Deserialize<'de>, S: Deserialize<'de>" ) ) ]
35
+ #[ cbor( map) ]
30
36
pub struct Envelope < D : Committable , S > {
37
+ #[ cbor( n( 0 ) ) ]
31
38
signed : Signed < D > ,
39
+
40
+ #[ cbor( skip) ]
32
41
#[ serde( skip) ]
33
- _marker : PhantomData < fn ( S ) > ,
42
+ _marker : PhantomData < fn ( & S ) > ,
34
43
}
35
44
36
45
impl < D : Committable > Envelope < D , Validated > {
0 commit comments