11use crate :: { BytesRef , DecodeValue , EncodeValue , FixedTag , Header , Length , Reader , Tag , Writer } ;
22
3- /// This is currently `OctetStringRef ` internally, as `GeneralString` is not fully implemented yet
3+ /// This is currently `&[u8] ` internally, as `GeneralString` is not fully implemented yet
44#[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
55pub struct GeneralStringRef < ' a > {
66 /// Raw contents, unchecked
7- #[ doc( hidden) ]
8- pub __contents : & ' a [ u8 ] ,
7+ inner : BytesRef < ' a > ,
98}
9+ impl < ' a > GeneralStringRef < ' a > {
10+ /// This is currently `&[u8]` internally, as `GeneralString` is not fully implemented yet
11+ pub fn as_bytes ( & self ) -> & ' a [ u8 ] {
12+ self . inner . as_slice ( )
13+ }
14+ }
15+
1016impl FixedTag for GeneralStringRef < ' _ > {
1117 const TAG : Tag = Tag :: GeneralString ;
1218}
@@ -15,16 +21,16 @@ impl<'a> DecodeValue<'a> for GeneralStringRef<'a> {
1521
1622 fn decode_value < R : Reader < ' a > > ( reader : & mut R , header : Header ) -> Result < Self , Self :: Error > {
1723 Ok ( Self {
18- __contents : BytesRef :: decode_value ( reader, header) ?. as_slice ( ) ,
24+ inner : BytesRef :: decode_value ( reader, header) ?,
1925 } )
2026 }
2127}
2228impl EncodeValue for GeneralStringRef < ' _ > {
2329 fn value_len ( & self ) -> crate :: Result < Length > {
24- BytesRef :: new ( self . __contents ) ? . value_len ( )
30+ self . inner . value_len ( )
2531 }
2632
2733 fn encode_value ( & self , encoder : & mut impl Writer ) -> crate :: Result < ( ) > {
28- BytesRef :: new ( self . __contents ) ? . encode_value ( encoder)
34+ self . inner . encode_value ( encoder)
2935 }
3036}
0 commit comments