@@ -11,7 +11,7 @@ mod vote;
1111pub use builder:: GeneralizedTxBuilder ;
1212use coset:: CborSerializable ;
1313pub use event_map:: { EventKey , EventMap } ;
14- use minicbor:: { data :: Tag , Decode , Decoder , Encode , Encoder } ;
14+ use minicbor:: { Decode , Decoder , Encode , Encoder } ;
1515pub use tx_body:: { TxBody , VoterData } ;
1616pub use vote:: { Choice , Proof , PropId , Vote } ;
1717
3232 signature : coset:: CoseSign ,
3333}
3434
35- /// An encoded CBOR struct, CBOR tag 24.
36- #[ derive( Debug , Clone , PartialEq ) ]
37- pub struct EncodedCbor < T > ( T )
38- where T : for < ' a > Cbor < ' a > ;
39-
40- /// encoded-cbor CBOR tag <https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml/>.
41- const ENCODED_CBOR_TAG : u64 = 24 ;
42-
4335/// `GeneralizedTx` array struct length
4436const GENERALIZED_TX_LEN : u64 = 2 ;
4537
@@ -109,39 +101,6 @@ where
109101 }
110102}
111103
112- impl < T > Decode < ' _ , ( ) > for EncodedCbor < T >
113- where T : for < ' a > Cbor < ' a >
114- {
115- fn decode ( d : & mut Decoder < ' _ > , ( ) : & mut ( ) ) -> Result < Self , minicbor:: decode:: Error > {
116- let tag = d. tag ( ) ?;
117- if ENCODED_CBOR_TAG != tag. as_u64 ( ) {
118- return Err ( minicbor:: decode:: Error :: message ( format ! (
119- "tag value must be: {ENCODED_CBOR_TAG}, provided: {}" ,
120- tag. as_u64( ) ,
121- ) ) ) ;
122- }
123- let cbor_bytes = d. bytes ( ) ?. to_vec ( ) ;
124- let cbor = T :: from_bytes ( & cbor_bytes) . map_err ( minicbor:: decode:: Error :: message) ?;
125- Ok ( Self ( cbor) )
126- }
127- }
128-
129- impl < T > Encode < ( ) > for EncodedCbor < T >
130- where T : for < ' a > Cbor < ' a >
131- {
132- fn encode < W : minicbor:: encode:: Write > (
133- & self , e : & mut minicbor:: Encoder < W > , ( ) : & mut ( ) ,
134- ) -> Result < ( ) , minicbor:: encode:: Error < W :: Error > > {
135- e. tag ( Tag :: new ( ENCODED_CBOR_TAG ) ) ?;
136- let cbor_bytes = self
137- . 0
138- . to_bytes ( )
139- . map_err ( minicbor:: encode:: Error :: message) ?;
140- e. bytes ( & cbor_bytes) ?;
141- Ok ( ( ) )
142- }
143- }
144-
145104/// Reads CBOR bytes from the decoder and returns them as bytes.
146105fn read_cbor_bytes ( d : & mut Decoder < ' _ > ) -> Result < Vec < u8 > , minicbor:: decode:: Error > {
147106 let start = d. position ( ) ;
@@ -169,7 +128,7 @@ mod tests {
169128 use test_strategy:: proptest;
170129
171130 use super :: * ;
172- use crate :: uuid:: Uuid ;
131+ use crate :: { encoded_cbor :: EncodedCbor , uuid:: Uuid } ;
173132
174133 type ChoiceT = Vec < u8 > ;
175134 type ProofT = Vec < u8 > ;
0 commit comments