@@ -59,11 +59,11 @@ use crate::decoder::stream::header02::{
5959use crate :: decoder:: {
6060 Column02 , ColumnCounts , ColumnKind02 , ColumnType02 , DataType02 , Decoder , DictLayout ,
6161 DictionaryType , FloatLogical , GeoLayout , GeoTypes , Id , IdWidth02 , IndexBase , Layer01 , Layer02 ,
62- LayerHeader02 , LayerLayout , LengthType , LogicalEncoding , MValues , Nested , Presence02 ,
63- RawFloats , RawFloatsEncoding , RawFsstData , RawGeometry , RawId , RawIdValue , RawMValue ,
64- RawPlainData , RawPresence , RawProperty , RawScalar , RawSharedDict , RawSharedDictEncoding ,
65- RawSharedDictItem , RawStream , RawStrings , RawStringsEncoding , SharedDictKind , ValueType02 ,
66- ValuesColumn02 ,
62+ LayerBytes , LayerHeader02 , LayerLayout , LengthType , LogicalEncoding , MValues , Nested ,
63+ Presence02 , RawFloats , RawFloatsEncoding , RawFsstData , RawGeometry , RawId , RawIdValue ,
64+ RawMValue , RawPlainData , RawPresence , RawProperty , RawScalar , RawSharedDict ,
65+ RawSharedDictEncoding , RawSharedDictItem , RawStream , RawStrings , RawStringsEncoding ,
66+ SharedDictKind , ValueType02 , ValuesColumn02 ,
6767} ;
6868use crate :: tile:: { ColumnRole , Extent , reject_taken_name} ;
6969use crate :: utils:: { SetOptionOnce as _, parse_string, parse_u8} ;
@@ -74,6 +74,7 @@ pub(crate) fn parse_layer02<'a>(
7474 input : & ' a [ u8 ] ,
7575 parser : & mut Parser ,
7676) -> MltResult < Layer02 < ' a , Lazy > > {
77+ let mut bytes = LayerBytes :: of_body ( input. len ( ) ) ;
7778 let ( input, layer_name) = parse_string ( input) ?;
7879 if layer_name. is_empty ( ) {
7980 return Err ( MissingLayerName ) ;
@@ -93,7 +94,9 @@ pub(crate) fn parse_layer02<'a>(
9394 let ( input, cols) = parse_shared_presence ( input, layout, feature_count, parser) ?;
9495
9596 // ── Geometry section ──────────────────────────────────────────────────
96- let ( input, geometry) = parse_geometry ( input, header, layout. geometry , feature_count, parser) ?;
97+ let ( rest, geometry) = parse_geometry ( input, header, layout. geometry , feature_count, parser) ?;
98+ bytes. geometry = u32:: try_from ( input. len ( ) - rest. len ( ) ) ?;
99+ let input = rest;
97100
98101 // ── Counted columns ───────────────────────────────────────────────────
99102 let ( mut input, counts) = ColumnCounts :: parse ( input, header. m_values ) ?;
@@ -112,6 +115,7 @@ pub(crate) fn parse_layer02<'a>(
112115 let mut layer_order = vec ! [ crate :: decoder:: fuzzing:: LayerOrdering :: Geometry ] ;
113116
114117 for _ in 0 ..column_count {
118+ let before = input. len ( ) ;
115119 let typ_byte;
116120 ( input, typ_byte) = parse_u8 ( input) ?;
117121 let typ = match cols. column ( typ_byte) ? {
@@ -124,6 +128,7 @@ pub(crate) fn parse_layer02<'a>(
124128 column_names. push ( ( Cow :: Owned ( name) , ColumnRole :: Property ) ) ;
125129 }
126130 properties. push ( Raw ( RawProperty :: SharedDict ( shared_dict) ) ) ;
131+ bytes. properties += u32:: try_from ( before - input. len ( ) ) ?;
127132 #[ cfg( fuzzing) ]
128133 layer_order. push ( crate :: decoder:: fuzzing:: LayerOrdering :: Property ) ;
129134 continue ;
@@ -148,6 +153,7 @@ pub(crate) fn parse_layer02<'a>(
148153 IdWidth02 :: Id64 => RawIdValue :: Id64 ( data) ,
149154 } ;
150155 id_column. set_once ( Raw ( RawId { presence, value } ) ) ?;
156+ bytes. ids += u32:: try_from ( before - input. len ( ) ) ?;
151157 }
152158 ColumnKind02 :: Values ( column) => {
153159 #[ cfg( fuzzing) ]
@@ -164,6 +170,7 @@ pub(crate) fn parse_layer02<'a>(
164170 parser,
165171 ) ?;
166172 properties. push ( Raw ( values. into ( ) ) ) ;
173+ bytes. properties += u32:: try_from ( before - input. len ( ) ) ?;
167174 }
168175 ColumnKind02 :: Nested ( column) => {
169176 #[ cfg( fuzzing) ]
@@ -174,17 +181,20 @@ pub(crate) fn parse_layer02<'a>(
174181 ( input, tree) =
175182 parse_nested ( input, name, presence, column. root , data_count, parser) ?;
176183 nested. push ( Raw ( tree) ) ;
184+ bytes. properties += u32:: try_from ( before - input. len ( ) ) ?;
177185 }
178186 }
179187 }
180188
181189 // ── M-value section ───────────────────────────────────────────────────
190+ let before = input. len ( ) ;
182191 let m_values;
183192 ( input, m_values) = if header. m_values {
184193 parse_m_values ( input, counts. m_values , & cols, & mut column_names, parser) ?
185194 } else {
186195 ( input, Vec :: new ( ) )
187196 } ;
197+ bytes. properties += u32:: try_from ( before - input. len ( ) ) ?;
188198
189199 if !input. is_empty ( ) {
190200 return Err ( TrailingLayerData ( input. len ( ) ) ) ;
@@ -196,6 +206,7 @@ pub(crate) fn parse_layer02<'a>(
196206 id : id_column,
197207 geometry : Raw ( geometry) ,
198208 properties,
209+ bytes,
199210 #[ cfg( fuzzing) ]
200211 layer_order,
201212 } ,
0 commit comments