@@ -53,7 +53,7 @@ use crate::lazy::text::value::{
53
53
LazyRawTextValue_1_0 , LazyRawTextValue_1_1 , LazyRawTextVersionMarker_1_0 ,
54
54
LazyRawTextVersionMarker_1_1 , RawTextAnnotationsIterator ,
55
55
} ;
56
- use crate :: { IonResult , IonType , RawSymbolRef } ;
56
+ use crate :: { Encoding , IonResult , IonType , RawSymbolRef } ;
57
57
use bumpalo:: Bump as BumpAllocator ;
58
58
59
59
/// An implementation of the `LazyDecoder` trait that can read any encoding of Ion.
@@ -89,6 +89,18 @@ pub enum LazyRawAnyVersionMarkerKind<'top> {
89
89
Binary_1_1 ( LazyRawBinaryVersionMarker_1_1 < ' top > ) ,
90
90
}
91
91
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
+
92
104
impl < ' top > HasSpan < ' top > for LazyRawAnyVersionMarker < ' top > {
93
105
fn span ( & self ) -> Span < ' top > {
94
106
use LazyRawAnyVersionMarkerKind :: * ;
@@ -165,6 +177,16 @@ pub enum LazyRawAnyEExpressionKind<'top> {
165
177
Binary_1_1 ( Never ) , // TODO: RawBinaryEExpression_1_1
166
178
}
167
179
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
+
168
190
impl < ' top > From < RawTextEExpression_1_1 < ' top > > for LazyRawAnyEExpression < ' top > {
169
191
fn from ( text_invocation : RawTextEExpression_1_1 < ' top > ) -> Self {
170
192
LazyRawAnyEExpression {
@@ -278,7 +300,7 @@ pub enum RawReaderKind<'data> {
278
300
Binary_1_1 ( LazyRawBinaryReader_1_1 < ' data > ) ,
279
301
}
280
302
281
- #[ derive( Default , Copy , Clone ) ]
303
+ #[ derive( Default , Debug , Copy , Clone ) ]
282
304
#[ non_exhaustive]
283
305
pub enum IonEncoding {
284
306
// In the absence of a binary IVM, readers must assume Ion 1.0 text data until a
@@ -300,6 +322,24 @@ impl IonEncoding {
300
322
use IonEncoding :: * ;
301
323
matches ! ( * self , Binary_1_0 | Binary_1_1 )
302
324
}
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
+ }
303
343
}
304
344
305
345
impl < ' data > From < LazyRawTextReader_1_0 < ' data > > for LazyRawAnyReader < ' data > {
@@ -421,6 +461,16 @@ impl<'top> LazyRawAnyValue<'top> {
421
461
pub fn kind ( & self ) -> LazyRawValueKind < ' top > {
422
462
self . encoding
423
463
}
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
+ }
424
474
}
425
475
426
476
#[ derive( Debug , Copy , Clone ) ]
0 commit comments