@@ -93,7 +93,7 @@ impl<'a> TableMapEvent<'a> {
9393 self . columns_count . 0
9494 }
9595
96- /// Ruturns a number of JSON columns.
96+ /// Returns a number of JSON columns.
9797 pub fn json_column_count ( & self ) -> usize {
9898 self . columns_type
9999 . 0
@@ -265,7 +265,7 @@ impl<'de> MyDeserialize<'de> for TableMapEvent<'de> {
265265 let columns_count: RawInt < LenEnc > = buf. parse ( ( ) ) ?;
266266 let columns_type = buf. parse ( columns_count. 0 as usize ) ?;
267267 let columns_metadata = buf. parse ( ( ) ) ?;
268- let null_bitmask = buf. parse ( ( ( columns_count. 0 + 7 ) / 8 ) as usize ) ?;
268+ let null_bitmask = buf. parse ( columns_count. 0 . div_ceil ( 8 ) as usize ) ?;
269269 let optional_metadata = buf. parse ( ( ) ) ?;
270270
271271 Ok ( TableMapEvent {
@@ -328,8 +328,8 @@ impl<'a> BinlogStruct<'a> for TableMapEvent<'a> {
328328
329329/// Optional metadata field that contains charsets for columns.
330330///
331- /// - contains charsets for caracter columns if it's a [`OptionalMetadataField::DefaultCharset`];
332- /// – contains charsets for ENUM and SET columns if it's a
331+ /// * contains charsets for character columns if it's a [`OptionalMetadataField::DefaultCharset`];
332+ /// * contains charsets for ENUM and SET columns if it's a
333333/// [`OptionalMetadataField::EnumAndSetDefaultCharset`].
334334#[ derive( Debug , Clone , Eq , PartialEq ) ]
335335pub struct DefaultCharset < ' a > {
@@ -449,8 +449,8 @@ impl MySerialize for NonDefaultCharset {
449449
450450/// Contains charset+collation for column.
451451///
452- /// - contains charsets for caracter columns if it's a [`OptionalMetadataField::ColumnCharset`];
453- /// – contains charsets for ENUM and SET columns if it's a
452+ /// * contains charsets for character columns if it's a [`OptionalMetadataField::ColumnCharset`];
453+ /// * contains charsets for ENUM and SET columns if it's a
454454/// [`OptionalMetadataField::EnumAndSetColumnCharset`].
455455#[ derive( Debug , Clone , Eq , PartialEq ) ]
456456pub struct ColumnCharsets < ' a > {
@@ -1215,7 +1215,7 @@ pub struct OptionalMetadataIter<'a> {
12151215
12161216impl < ' a > OptionalMetadataIter < ' a > {
12171217 /// Reads type-length-value value.
1218- fn read_tlv ( & mut self ) -> io:: Result < ( RawConst < u8 , OptionalMetadataFieldType > , & ' a [ u8 ] ) > {
1218+ fn read_tlv ( & mut self ) -> io:: Result < ( u8 , & ' a [ u8 ] ) > {
12191219 let t = self . data . read_u8 ( ) ?;
12201220 // The length is encoded in 1, 3 or 8 bytes (https://github.com/mysql/mysql-server/blob/824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/libs/mysql/binlog/event/binlog_event.h#L812)
12211221 let l = self . data . read_lenenc_int ( ) ? as usize ;
@@ -1230,13 +1230,11 @@ impl<'a> OptionalMetadataIter<'a> {
12301230 }
12311231 } ;
12321232 self . data = & self . data [ l..] ;
1233- Ok ( ( RawConst :: new ( t ) , v) )
1233+ Ok ( ( t , v) )
12341234 }
12351235
12361236 /// Returns next tlv, if any.
1237- fn next_tlv (
1238- & mut self ,
1239- ) -> Option < io:: Result < ( RawConst < u8 , OptionalMetadataFieldType > , & ' a [ u8 ] ) > > {
1237+ fn next_tlv ( & mut self ) -> Option < io:: Result < ( u8 , & ' a [ u8 ] ) > > {
12401238 if self . data . is_empty ( ) {
12411239 return None ;
12421240 }
@@ -1266,19 +1264,17 @@ impl<'a> Iterator for OptionalMetadataIter<'a> {
12661264
12671265 self . next_tlv ( ) ?
12681266 . and_then ( |( t, v) | {
1267+ let t = RawConst :: < u8 , OptionalMetadataFieldType > :: new ( t) ;
12691268 let mut v = ParseBuf ( v) ;
12701269 match t. get ( ) {
12711270 Ok ( t) => match t {
12721271 SIGNEDNESS => {
12731272 let num_numeric = self . count_columns ( ColumnType :: is_numeric_type) ;
1274- let num_flags_bytes = ( num_numeric + 7 ) / 8 ;
1273+ let num_flags_bytes = num_numeric. div_ceil ( 8 ) ;
12751274 let flags: & [ u8 ] = v. parse ( num_flags_bytes) ?;
12761275
12771276 if !v. is_empty ( ) {
1278- return Err ( io:: Error :: new (
1279- io:: ErrorKind :: Other ,
1280- "bytes remaining on stream" ,
1281- ) ) ;
1277+ return Err ( io:: Error :: other ( "bytes remaining on stream" ) ) ;
12821278 }
12831279
12841280 let flags = BitSlice :: from_slice ( flags) ;
@@ -1304,14 +1300,11 @@ impl<'a> Iterator for OptionalMetadataIter<'a> {
13041300 }
13051301 COLUMN_VISIBILITY => {
13061302 let num_columns = self . num_columns ( ) ;
1307- let num_flags_bytes = ( num_columns + 7 ) / 8 ;
1303+ let num_flags_bytes = num_columns. div_ceil ( 8 ) ;
13081304 let flags: & [ u8 ] = v. parse ( num_flags_bytes) ?;
13091305
13101306 if !v. is_empty ( ) {
1311- return Err ( io:: Error :: new (
1312- io:: ErrorKind :: Other ,
1313- "bytes remaining on stream" ,
1314- ) ) ;
1307+ return Err ( io:: Error :: other ( "bytes remaining on stream" ) ) ;
13151308 }
13161309
13171310 let flags = BitSlice :: from_slice ( flags) ;
@@ -1453,7 +1446,7 @@ impl<'a> OptionalMetaExtractor<'a> {
14531446 ///
14541447 /// Returns peekable iterator so that it is possible to observe next PK index.
14551448 ///
1456- /// Emits nothing if there are no PK data in the optinal metadata.
1449+ /// Emits nothing if there are no PK data in the optional metadata.
14571450 pub fn iter_primary_key ( & ' a self ) -> Peekable < impl Iterator < Item = io:: Result < u64 > > + ' a > {
14581451 let simple = self
14591452 . simple_primary_key
0 commit comments