mysql_common/binlog/events/
rand_event.rs1use std::io::{self};
10
11use crate::{
12 binlog::{
13 consts::{BinlogVersion, EventType},
14 BinlogCtx, BinlogEvent, BinlogStruct,
15 },
16 io::ParseBuf,
17 misc::raw::{int::LeU64, RawInt},
18 proto::{MyDeserialize, MySerialize},
19};
20
21#[derive(Debug, Clone, Eq, PartialEq, Hash)]
30pub struct RandEvent {
31 pub seed1: RawInt<LeU64>,
32 pub seed2: RawInt<LeU64>,
33}
34
35impl<'de> MyDeserialize<'de> for RandEvent {
36 const SIZE: Option<usize> = Some(16);
37 type Ctx = BinlogCtx<'de>;
38
39 fn deserialize(_: Self::Ctx, buf: &mut ParseBuf<'de>) -> io::Result<Self> {
40 Ok(Self {
41 seed1: buf.parse_unchecked(())?,
42 seed2: buf.parse_unchecked(())?,
43 })
44 }
45}
46
47impl MySerialize for RandEvent {
48 fn serialize(&self, buf: &mut Vec<u8>) {
49 self.seed1.serialize(&mut *buf);
50 self.seed2.serialize(&mut *buf);
51 }
52}
53
54impl<'a> BinlogEvent<'a> for RandEvent {
55 const EVENT_TYPE: EventType = EventType::RAND_EVENT;
56}
57
58impl<'a> BinlogStruct<'a> for RandEvent {
59 fn len(&self, _version: BinlogVersion) -> usize {
60 8
61 }
62}