@@ -53,7 +53,7 @@ use crate::lazy::text::value::{
5353 LazyRawTextValue_1_0 , LazyRawTextValue_1_1 , LazyRawTextVersionMarker_1_0 ,
5454 LazyRawTextVersionMarker_1_1 , RawTextAnnotationsIterator ,
5555} ;
56- use crate :: { IonResult , IonType , RawSymbolRef } ;
56+ use crate :: { Encoding , IonResult , IonType , RawSymbolRef } ;
5757use bumpalo:: Bump as BumpAllocator ;
5858
5959/// An implementation of the `LazyDecoder` trait that can read any encoding of Ion.
@@ -89,6 +89,18 @@ pub enum LazyRawAnyVersionMarkerKind<'top> {
8989 Binary_1_1 ( LazyRawBinaryVersionMarker_1_1 < ' top > ) ,
9090}
9191
92+ impl < ' top > LazyRawAnyVersionMarker < ' top > {
93+ pub fn encoding ( & self ) -> IonEncoding {
94+ use crate :: lazy:: any_encoding:: LazyRawAnyVersionMarkerKind :: * ;
95+ match self . encoding {
96+ Text_1_0 ( _) => TextEncoding_1_0 . encoding ( ) ,
97+ Binary_1_0 ( _) => BinaryEncoding_1_0 . encoding ( ) ,
98+ Text_1_1 ( _) => TextEncoding_1_1 . encoding ( ) ,
99+ Binary_1_1 ( _) => BinaryEncoding_1_1 . encoding ( ) ,
100+ }
101+ }
102+ }
103+
92104impl < ' top > HasSpan < ' top > for LazyRawAnyVersionMarker < ' top > {
93105 fn span ( & self ) -> Span < ' top > {
94106 use LazyRawAnyVersionMarkerKind :: * ;
@@ -165,6 +177,16 @@ pub enum LazyRawAnyEExpressionKind<'top> {
165177 Binary_1_1 ( Never ) , // TODO: RawBinaryEExpression_1_1
166178}
167179
180+ impl < ' top > LazyRawAnyEExpression < ' top > {
181+ pub fn encoding ( & self ) -> IonEncoding {
182+ use LazyRawAnyEExpressionKind :: * ;
183+ match self . encoding {
184+ Text_1_1 ( _) => TextEncoding_1_1 . encoding ( ) ,
185+ Binary_1_1 ( _) => BinaryEncoding_1_1 . encoding ( ) ,
186+ }
187+ }
188+ }
189+
168190impl < ' top > From < RawTextEExpression_1_1 < ' top > > for LazyRawAnyEExpression < ' top > {
169191 fn from ( text_invocation : RawTextEExpression_1_1 < ' top > ) -> Self {
170192 LazyRawAnyEExpression {
@@ -278,7 +300,7 @@ pub enum RawReaderKind<'data> {
278300 Binary_1_1 ( LazyRawBinaryReader_1_1 < ' data > ) ,
279301}
280302
281- #[ derive( Default , Copy , Clone ) ]
303+ #[ derive( Default , Debug , Copy , Clone ) ]
282304#[ non_exhaustive]
283305pub enum IonEncoding {
284306 // In the absence of a binary IVM, readers must assume Ion 1.0 text data until a
@@ -300,6 +322,24 @@ impl IonEncoding {
300322 use IonEncoding :: * ;
301323 matches ! ( * self , Binary_1_0 | Binary_1_1 )
302324 }
325+
326+ pub fn name ( & self ) -> & str {
327+ use IonEncoding :: * ;
328+ match self {
329+ Text_1_0 => TextEncoding_1_0 :: name ( ) ,
330+ Binary_1_0 => BinaryEncoding_1_0 :: name ( ) ,
331+ Text_1_1 => TextEncoding_1_1 :: name ( ) ,
332+ Binary_1_1 => BinaryEncoding_1_1 :: name ( ) ,
333+ }
334+ }
335+
336+ pub fn version ( & self ) -> ( u8 , u8 ) {
337+ use IonEncoding :: * ;
338+ match self {
339+ Text_1_0 | Binary_1_0 => ( 1 , 0 ) ,
340+ Text_1_1 | Binary_1_1 => ( 1 , 1 ) ,
341+ }
342+ }
303343}
304344
305345impl < ' data > From < LazyRawTextReader_1_0 < ' data > > for LazyRawAnyReader < ' data > {
@@ -421,6 +461,16 @@ impl<'top> LazyRawAnyValue<'top> {
421461 pub fn kind ( & self ) -> LazyRawValueKind < ' top > {
422462 self . encoding
423463 }
464+
465+ pub fn encoding ( & self ) -> IonEncoding {
466+ use LazyRawValueKind :: * ;
467+ match & self . encoding {
468+ Text_1_0 ( _) => TextEncoding_1_0 . encoding ( ) ,
469+ Binary_1_0 ( _) => BinaryEncoding_1_0 . encoding ( ) ,
470+ Text_1_1 ( _) => TextEncoding_1_1 . encoding ( ) ,
471+ Binary_1_1 ( _) => BinaryEncoding_1_1 . encoding ( ) ,
472+ }
473+ }
424474}
425475
426476#[ derive( Debug , Copy , Clone ) ]
0 commit comments