File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -262,6 +262,51 @@ impl ProvenanceTable {
262
262
make_provenance_row ( self , row. into ( ) . 0 )
263
263
}
264
264
265
+ /// Obtain a [`ProvenanceTableRowView`] for row `row`.
266
+ ///
267
+ /// # Returns
268
+ ///
269
+ /// * `Some(row view)` if `r` is valid
270
+ /// * `None` otherwise
271
+ pub fn row_view < P : Into < ProvenanceId > + Copy > ( & self , row : P ) -> Option < ProvenanceTableRowView > {
272
+ match u64:: try_from ( row. into ( ) . 0 ) . ok ( ) {
273
+ Some ( x) if x < self . num_rows ( ) => {
274
+ let record_slice = unsafe_tsk_ragged_char_column_access_to_slice_u8 ! (
275
+ row. into( ) . 0 ,
276
+ 0 ,
277
+ self . num_rows( ) ,
278
+ self . as_ref( ) ,
279
+ record,
280
+ record_offset,
281
+ record_length
282
+ ) ;
283
+ let timestamp_slice = unsafe_tsk_ragged_char_column_access_to_slice_u8 ! (
284
+ row. into( ) . 0 ,
285
+ 0 ,
286
+ self . num_rows( ) ,
287
+ self . as_ref( ) ,
288
+ timestamp,
289
+ timestamp_offset,
290
+ timestamp_length
291
+ ) ;
292
+ let view = ProvenanceTableRowView {
293
+ table : self ,
294
+ id : row. into ( ) ,
295
+ record : match record_slice {
296
+ Some ( r) => std:: str:: from_utf8 ( r) . unwrap ( ) ,
297
+ None => "" ,
298
+ } ,
299
+ timestamp : match timestamp_slice {
300
+ Some ( t) => std:: str:: from_utf8 ( t) . unwrap ( ) ,
301
+ None => "" ,
302
+ } ,
303
+ } ;
304
+ Some ( view)
305
+ }
306
+ _ => None ,
307
+ }
308
+ }
309
+
265
310
/// Return an iterator over rows of the table.
266
311
/// The value of the iterator is [`ProvenanceTableRow`].
267
312
pub fn iter ( & self ) -> impl Iterator < Item = ProvenanceTableRow > + ' _ {
You can’t perform that action at this time.
0 commit comments