@@ -537,6 +537,42 @@ impl<'g> Variable<'g> {
537
537
let extents: Extents = extents. try_into ( ) . map_err ( Into :: into) ?;
538
538
self . values_to_mono ( buffer, & extents)
539
539
}
540
+
541
+ /// Fetches variable and returns the bytes.
542
+ /// It is up to the caller to decide what to do with these bytes,
543
+ /// including interpretation and freeing memory if
544
+ /// this is a vlen/string type
545
+ pub fn get_raw_values < E > ( & self , extents : E ) -> error:: Result < Vec < u8 > >
546
+ where
547
+ E : TryInto < Extents > ,
548
+ E :: Error : Into < error:: Error > ,
549
+ {
550
+ let extents: Extents = extents. try_into ( ) . map_err ( Into :: into) ?;
551
+ let dims = self . dimensions ( ) ;
552
+ let ( _, count, _) = extents. get_start_count_stride ( dims) ?;
553
+ let number_of_elements = count. iter ( ) . copied ( ) . fold ( 1_usize , usize:: saturating_mul) ;
554
+ let varsize = self . vartype ( ) . size ( ) ;
555
+ let mut buffer = vec ! [ 0_u8 ; number_of_elements * varsize] ;
556
+
557
+ super :: putget:: get_raw_values_into ( self , & mut buffer, extents) ?;
558
+
559
+ Ok ( buffer)
560
+ }
561
+
562
+ /// Fetches variable into provided buffer.
563
+ /// This functions returns bytes and it is up to the caller to
564
+ /// decide what to do with it, including freeing memory if
565
+ /// this is a vlen/string type
566
+ pub fn get_raw_values_into < E > ( & self , buffer : & mut [ u8 ] , extents : E ) -> error:: Result < ( ) >
567
+ where
568
+ E : TryInto < Extents > ,
569
+ E :: Error : Into < error:: Error > ,
570
+ {
571
+ let extents: Extents = extents. try_into ( ) . map_err ( Into :: into) ?;
572
+ super :: putget:: get_raw_values_into ( self , buffer, extents) ?;
573
+
574
+ Ok ( ( ) )
575
+ }
540
576
}
541
577
542
578
impl < ' g > VariableMut < ' g > {
0 commit comments