@@ -25,7 +25,7 @@ pub struct Data {
25
25
rows : Vec < LogRow > ,
26
26
filtered_rows : Option < Vec < usize > > ,
27
27
applied_filter : Option < FilterConfig > ,
28
- pub file_size : String ,
28
+ pub file_size_as_bytes : usize ,
29
29
}
30
30
31
31
#[ derive( serde:: Deserialize , serde:: Serialize , Default , Debug , PartialEq , Eq , Clone ) ]
@@ -136,6 +136,10 @@ impl LogRow {
136
136
}
137
137
138
138
impl Data {
139
+ pub fn file_size_display ( & self ) -> String {
140
+ SizeUnits :: Auto . convert_trimmed ( self . file_size_as_bytes )
141
+ }
142
+
139
143
pub fn rows_iter ( & self ) -> impl Iterator < Item = & ' _ LogRow > {
140
144
DataIter :: new ( self )
141
145
}
@@ -415,7 +419,7 @@ impl TryFrom<(&DataDisplayOptions, usize, &str)> for LogRow {
415
419
if let Some ( config) = data_display_options. row_size_config . as_ref ( ) {
416
420
result. or_insert (
417
421
config. field_name . clone ( ) ,
418
- config. units . convert ( row_size_in_bytes) ,
422
+ config. units . convert ( row_size_in_bytes) . into ( ) ,
419
423
) ;
420
424
}
421
425
Ok ( result)
@@ -465,15 +469,8 @@ impl TryFrom<(&DataDisplayOptions, &str)> for Data {
465
469
fn try_from (
466
470
( data_display_options, value) : ( & DataDisplayOptions , & str ) ,
467
471
) -> 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 ( ) ;
475
472
let mut result = Data {
476
- file_size ,
473
+ file_size_as_bytes : value . len ( ) ,
477
474
..Default :: default ( )
478
475
} ;
479
476
for ( i, line) in value. lines ( ) . enumerate ( ) {
0 commit comments