use crate::providers::mariadb::gtid::gtid::Gtid;
use crate::{errors::Error, events::event_header::EventHeader};
use byteorder::{LittleEndian, ReadBytesExt};
use std::io::Cursor;
#[derive(Debug)]
pub struct GtidEvent {
pub gtid: Gtid,
pub flags: u8,
}
impl GtidEvent {
pub fn parse(cursor: &mut Cursor<&[u8]>, header: &EventHeader) -> Result<Self, Error> {
let sequence = cursor.read_u64::<LittleEndian>()?;
let domain_id = cursor.read_u32::<LittleEndian>()?;
let flags = cursor.read_u8()?;
let gtid = Gtid::new(domain_id, header.server_id, sequence);
Ok(Self { gtid, flags })
}
}