mysql_async/conn/binlog_stream/
request.rs1use mysql_common::packets::{
2 binlog_request::BinlogRequest, BinlogDumpFlags, ComRegisterSlave, Sid,
3};
4
5pub struct BinlogStreamRequest<'a> {
7 pub(crate) binlog_request: BinlogRequest<'a>,
8 pub(crate) register_slave: ComRegisterSlave<'a>,
9}
10
11impl<'a> BinlogStreamRequest<'a> {
12 pub fn new(server_id: u32) -> Self {
14 Self {
15 binlog_request: BinlogRequest::new(server_id),
16 register_slave: ComRegisterSlave::new(server_id),
17 }
18 }
19
20 pub fn with_gtid(mut self) -> Self {
22 self.binlog_request = self.binlog_request.with_use_gtid(true);
23 self
24 }
25
26 pub fn with_non_blocking(mut self) -> Self {
28 self.binlog_request = self
29 .binlog_request
30 .with_flags(BinlogDumpFlags::BINLOG_DUMP_NON_BLOCK);
31 self
32 }
33
34 pub fn with_filename(mut self, filename: &'a [u8]) -> Self {
36 self.binlog_request = self.binlog_request.with_filename(filename);
37 self
38 }
39
40 pub fn with_pos(mut self, position: u64) -> Self {
42 self.binlog_request = self.binlog_request.with_pos(position);
43 self
44 }
45
46 pub fn with_gtid_set<T>(mut self, set: T) -> Self
48 where
49 T: IntoIterator<Item = Sid<'a>>,
50 {
51 self.binlog_request = self.binlog_request.with_sids(set);
52 self
53 }
54
55 pub fn with_hostname(mut self, hostname: &'a [u8]) -> Self {
59 self.register_slave = self.register_slave.with_hostname(hostname);
60 self
61 }
62
63 pub fn with_user(mut self, user: &'a [u8]) -> Self {
67 self.register_slave = self.register_slave.with_user(user);
68 self
69 }
70
71 pub fn with_password(mut self, password: &'a [u8]) -> Self {
75 self.register_slave = self.register_slave.with_password(password);
76 self
77 }
78
79 pub fn with_port(mut self, port: u16) -> Self {
83 self.register_slave = self.register_slave.with_port(port);
84 self
85 }
86}