@@ -17,6 +17,7 @@ use crate::types::decimal::Decimal;
17
17
use crate :: types:: integer:: Integer ;
18
18
use crate :: types:: timestamp:: Timestamp ;
19
19
use crate :: { IonType , RawBinaryReader , RawTextReader } ;
20
+ use std:: fmt:: { Display , Formatter } ;
20
21
21
22
/// Configures and constructs new instances of [Reader].
22
23
pub struct ReaderBuilder { }
@@ -145,6 +146,29 @@ pub enum StreamItem {
145
146
Nothing ,
146
147
}
147
148
149
+ impl StreamItem {
150
+ /// If `is_null` is `true`, returns `StreamItem::Value(ion_type)`. Otherwise,
151
+ /// returns `StreamItem::Null(ion_type)`.
152
+ pub fn nullable_value ( ion_type : IonType , is_null : bool ) -> StreamItem {
153
+ if is_null {
154
+ StreamItem :: Null ( ion_type)
155
+ } else {
156
+ StreamItem :: Value ( ion_type)
157
+ }
158
+ }
159
+ }
160
+
161
+ impl Display for StreamItem {
162
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
163
+ use StreamItem :: * ;
164
+ match self {
165
+ Value ( ion_type) => write ! ( f, "{}" , ion_type) ,
166
+ Null ( ion_type) => write ! ( f, "null.{}" , ion_type) ,
167
+ Nothing => Ok ( ( ) ) ,
168
+ }
169
+ }
170
+ }
171
+
148
172
impl < R : RawReader > UserReader < R > {
149
173
pub fn read_raw_symbol ( & mut self ) -> IonResult < RawSymbolToken > {
150
174
self . raw_reader . read_symbol ( )
0 commit comments