1- use crate :: types:: { Asn1Writable , SimpleAsn1Writable } ;
1+ use crate :: types:: Asn1Writable ;
22use crate :: Tag ;
33#[ cfg( not( feature = "std" ) ) ]
44use alloc:: vec:: Vec ;
@@ -107,50 +107,6 @@ impl Writer<'_> {
107107 val. write ( self )
108108 }
109109
110- /// This is an alias for `write_element::<Explicit<T, tag>>`.
111- pub fn write_explicit_element < T : Asn1Writable > ( & mut self , val : & T , tag : u32 ) -> WriteResult {
112- let tag = crate :: explicit_tag ( tag) ;
113- self . write_tlv ( tag, |dest| Writer :: new ( dest) . write_element ( val) )
114- }
115-
116- /// This is an alias for `write_element::<Option<Explicit<T, tag>>>`.
117- pub fn write_optional_explicit_element < T : Asn1Writable > (
118- & mut self ,
119- val : & Option < T > ,
120- tag : u32 ,
121- ) -> WriteResult {
122- if let Some ( v) = val {
123- let tag = crate :: explicit_tag ( tag) ;
124- self . write_tlv ( tag, |dest| Writer :: new ( dest) . write_element ( v) )
125- } else {
126- Ok ( ( ) )
127- }
128- }
129-
130- /// This is an alias for `write_element::<Implicit<T, tag>>`.
131- pub fn write_implicit_element < T : SimpleAsn1Writable > (
132- & mut self ,
133- val : & T ,
134- tag : u32 ,
135- ) -> WriteResult {
136- let tag = crate :: implicit_tag ( tag, T :: TAG ) ;
137- self . write_tlv ( tag, |dest| val. write_data ( dest) )
138- }
139-
140- /// This is an alias for `write_element::<Option<Implicit<T, tag>>>`.
141- pub fn write_optional_implicit_element < T : SimpleAsn1Writable > (
142- & mut self ,
143- val : & Option < T > ,
144- tag : u32 ,
145- ) -> WriteResult {
146- if let Some ( v) = val {
147- let tag = crate :: implicit_tag ( tag, T :: TAG ) ;
148- self . write_tlv ( tag, |dest| v. write_data ( dest) )
149- } else {
150- Ok ( ( ) )
151- }
152- }
153-
154110 /// Writes a TLV with the specified tag where the value is any bytes
155111 /// written to the `Vec` in the callback. The length portion of the
156112 /// TLV is automatically computed.
@@ -716,39 +672,6 @@ mod tests {
716672 ( Implicit :: new ( true ) , b"\x82 \x01 \xff " ) ,
717673 ( Implicit :: new ( false ) , b"\x82 \x01 \x00 " ) ,
718674 ] ) ;
719-
720- assert_eq ! (
721- write( |w| { w. write_optional_implicit_element( & Some ( true ) , 2 ) } ) . unwrap( ) ,
722- b"\x82 \x01 \xff "
723- ) ;
724- assert_eq ! (
725- write( |w| { w. write_optional_explicit_element:: <u8 >( & None , 2 ) } ) . unwrap( ) ,
726- b""
727- ) ;
728-
729- assert_eq ! (
730- write( |w| {
731- w. write_optional_implicit_element( & Some ( SequenceWriter :: new( & |_w| Ok ( ( ) ) ) ) , 2 )
732- } )
733- . unwrap( ) ,
734- b"\xa2 \x00 "
735- ) ;
736- assert_eq ! (
737- write( |w| { w. write_optional_explicit_element:: <SequenceWriter <' _>>( & None , 2 ) } )
738- . unwrap( ) ,
739- b""
740- ) ;
741-
742- assert_eq ! (
743- write( |w| { w. write_implicit_element( & true , 2 ) } ) . unwrap( ) ,
744- b"\x82 \x01 \xff "
745- ) ;
746-
747- assert_eq ! (
748- write( |w| { w. write_implicit_element( & SequenceWriter :: new( & |_w| { Ok ( ( ) ) } ) , 2 ) } )
749- . unwrap( ) ,
750- b"\xa2 \x00 "
751- ) ;
752675 }
753676
754677 #[ test]
@@ -757,20 +680,6 @@ mod tests {
757680 ( Explicit :: new ( true ) , b"\xa2 \x03 \x01 \x01 \xff " ) ,
758681 ( Explicit :: new ( false ) , b"\xa2 \x03 \x01 \x01 \x00 " ) ,
759682 ] ) ;
760-
761- assert_eq ! (
762- write( |w| { w. write_optional_explicit_element( & Some ( true ) , 2 ) } ) . unwrap( ) ,
763- b"\xa2 \x03 \x01 \x01 \xff "
764- ) ;
765- assert_eq ! (
766- write( |w| { w. write_optional_explicit_element:: <u8 >( & None , 2 ) } ) . unwrap( ) ,
767- b""
768- ) ;
769-
770- assert_eq ! (
771- write( |w| { w. write_explicit_element( & true , 2 ) } ) . unwrap( ) ,
772- b"\xa2 \x03 \x01 \x01 \xff "
773- ) ;
774683 }
775684
776685 #[ test]
0 commit comments