mysql_common/binlog/events/
anonymous_gtid_event.rs

1// Copyright (c) 2021 Anatoly Ikorsky
2//
3// Licensed under the Apache License, Version 2.0
4// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
5// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6// option. All files in the project carrying such notice may not be copied,
7// modified, or distributed except according to those terms.
8
9use std::io::{self};
10
11use crate::{
12    binlog::{
13        consts::{BinlogVersion, EventType},
14        BinlogCtx, BinlogEvent, BinlogStruct,
15    },
16    io::ParseBuf,
17    proto::{MyDeserialize, MySerialize},
18};
19
20use super::GtidEvent;
21
22/// Anonymous GTID event.
23#[repr(transparent)]
24#[derive(Debug, Clone, Eq, PartialEq, Hash)]
25pub struct AnonymousGtidEvent(pub GtidEvent);
26
27impl<'de> MyDeserialize<'de> for AnonymousGtidEvent {
28    const SIZE: Option<usize> = GtidEvent::SIZE;
29    type Ctx = BinlogCtx<'de>;
30
31    fn deserialize(ctx: Self::Ctx, buf: &mut ParseBuf<'de>) -> io::Result<Self> {
32        buf.parse_unchecked(ctx).map(Self)
33    }
34}
35
36impl MySerialize for AnonymousGtidEvent {
37    fn serialize(&self, buf: &mut Vec<u8>) {
38        self.0.serialize(buf)
39    }
40}
41
42impl<'a> BinlogStruct<'a> for AnonymousGtidEvent {
43    fn len(&self, version: BinlogVersion) -> usize {
44        self.0.len(version)
45    }
46}
47
48impl<'a> BinlogEvent<'a> for AnonymousGtidEvent {
49    const EVENT_TYPE: EventType = EventType::ANONYMOUS_GTID_EVENT;
50}