@@ -25,7 +25,7 @@ pub struct Data {
2525 rows : Vec < LogRow > ,
2626 filtered_rows : Option < Vec < usize > > ,
2727 applied_filter : Option < FilterConfig > ,
28- pub file_size : String ,
28+ pub file_size_as_bytes : usize ,
2929}
3030
3131#[ derive( serde:: Deserialize , serde:: Serialize , Default , Debug , PartialEq , Eq , Clone ) ]
@@ -136,6 +136,10 @@ impl LogRow {
136136}
137137
138138impl Data {
139+ pub fn file_size_display ( & self ) -> String {
140+ SizeUnits :: Auto . convert_trimmed ( self . file_size_as_bytes )
141+ }
142+
139143 pub fn rows_iter ( & self ) -> impl Iterator < Item = & ' _ LogRow > {
140144 DataIter :: new ( self )
141145 }
@@ -415,7 +419,7 @@ impl TryFrom<(&DataDisplayOptions, usize, &str)> for LogRow {
415419 if let Some ( config) = data_display_options. row_size_config . as_ref ( ) {
416420 result. or_insert (
417421 config. field_name . clone ( ) ,
418- config. units . convert ( row_size_in_bytes) ,
422+ config. units . convert ( row_size_in_bytes) . into ( ) ,
419423 ) ;
420424 }
421425 Ok ( result)
@@ -465,15 +469,8 @@ impl TryFrom<(&DataDisplayOptions, &str)> for Data {
465469 fn try_from (
466470 ( data_display_options, value) : ( & DataDisplayOptions , & str ) ,
467471 ) -> Result < Self , Self :: Error > {
468- let file_size = SizeUnits :: Auto . convert ( value. len ( ) ) ;
469- let file_size = file_size
470- . as_str ( )
471- . map ( |x| x. to_string ( ) )
472- . unwrap_or_else ( || file_size. to_string ( ) )
473- . trim_matches ( '0' )
474- . to_string ( ) ;
475472 let mut result = Data {
476- file_size ,
473+ file_size_as_bytes : value . len ( ) ,
477474 ..Default :: default ( )
478475 } ;
479476 for ( i, line) in value. lines ( ) . enumerate ( ) {
0 commit comments