Skip to main content

nebula_graph_fbthrift_raftex_v2/
lib.rs

1// @generated by Thrift. This file is probably not the place you want to edit!
2
3#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies)]
4
5pub use self::errors::*;
6pub use self::types::*;
7
8pub mod types {
9    #![allow(clippy::redundant_closure)]
10
11
12    pub type ClusterID = ::std::primitive::i64;
13
14    pub type GraphSpaceID = ::std::primitive::i32;
15
16    pub type PartitionID = ::std::primitive::i32;
17
18    pub type TermID = ::std::primitive::i64;
19
20    pub type LogID = ::std::primitive::i64;
21
22    pub type Port = ::std::primitive::i32;
23
24    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
25    pub struct AskForVoteRequest {
26        pub space: crate::types::GraphSpaceID,
27        pub part: crate::types::PartitionID,
28        pub candidate_addr: ::std::string::String,
29        pub candidate_port: crate::types::Port,
30        pub term: crate::types::TermID,
31        pub last_log_id: crate::types::LogID,
32        pub last_log_term: crate::types::TermID,
33    }
34
35    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
36    pub struct AskForVoteResponse {
37        pub error_code: crate::types::ErrorCode,
38    }
39
40    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
41    pub struct LogEntry {
42        pub cluster: crate::types::ClusterID,
43        pub log_str: ::std::vec::Vec<::std::primitive::u8>,
44    }
45
46    #[derive(Clone, Debug, PartialEq)]
47    pub struct AppendLogRequest {
48        pub space: crate::types::GraphSpaceID,
49        pub part: crate::types::PartitionID,
50        pub current_term: crate::types::TermID,
51        pub last_log_id: crate::types::LogID,
52        pub committed_log_id: crate::types::LogID,
53        pub leader_addr: ::std::string::String,
54        pub leader_port: crate::types::Port,
55        pub last_log_term_sent: crate::types::TermID,
56        pub last_log_id_sent: crate::types::LogID,
57        pub log_term: crate::types::TermID,
58        pub log_str_list: ::std::vec::Vec<crate::types::LogEntry>,
59        pub sending_snapshot: ::std::primitive::bool,
60    }
61
62    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
63    pub struct AppendLogResponse {
64        pub error_code: crate::types::ErrorCode,
65        pub current_term: crate::types::TermID,
66        pub leader_addr: ::std::string::String,
67        pub leader_port: crate::types::Port,
68        pub committed_log_id: crate::types::LogID,
69        pub last_log_id: crate::types::LogID,
70        pub last_log_term: crate::types::TermID,
71    }
72
73    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
74    pub struct SendSnapshotRequest {
75        pub space: crate::types::GraphSpaceID,
76        pub part: crate::types::PartitionID,
77        pub term: crate::types::TermID,
78        pub committed_log_id: crate::types::LogID,
79        pub committed_log_term: crate::types::TermID,
80        pub leader_addr: ::std::string::String,
81        pub leader_port: crate::types::Port,
82        pub rows: ::std::vec::Vec<::std::vec::Vec<::std::primitive::u8>>,
83        pub total_size: ::std::primitive::i64,
84        pub total_count: ::std::primitive::i64,
85        pub done: ::std::primitive::bool,
86    }
87
88    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
89    pub struct SendSnapshotResponse {
90        pub error_code: crate::types::ErrorCode,
91    }
92
93    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
94    pub struct ErrorCode(pub ::std::primitive::i32);
95
96    impl ErrorCode {
97        pub const SUCCEEDED: Self = ErrorCode(0i32);
98        pub const E_LOG_GAP: Self = ErrorCode(-1i32);
99        pub const E_LOG_STALE: Self = ErrorCode(-2i32);
100        pub const E_MISSING_COMMIT: Self = ErrorCode(-3i32);
101        pub const E_WAITING_SNAPSHOT: Self = ErrorCode(-4i32);
102        pub const E_UNKNOWN_PART: Self = ErrorCode(-5i32);
103        pub const E_TERM_OUT_OF_DATE: Self = ErrorCode(-6i32);
104        pub const E_LAST_LOG_TERM_TOO_OLD: Self = ErrorCode(-7i32);
105        pub const E_BAD_STATE: Self = ErrorCode(-8i32);
106        pub const E_WRONG_LEADER: Self = ErrorCode(-9i32);
107        pub const E_WAL_FAIL: Self = ErrorCode(-10i32);
108        pub const E_NOT_READY: Self = ErrorCode(-11i32);
109        pub const E_HOST_STOPPED: Self = ErrorCode(-12i32);
110        pub const E_NOT_A_LEADER: Self = ErrorCode(-13i32);
111        pub const E_HOST_DISCONNECTED: Self = ErrorCode(-14i32);
112        pub const E_TOO_MANY_REQUESTS: Self = ErrorCode(-15i32);
113        pub const E_PERSIST_SNAPSHOT_FAILED: Self = ErrorCode(-16i32);
114        pub const E_BAD_ROLE: Self = ErrorCode(-17i32);
115        pub const E_EXCEPTION: Self = ErrorCode(-20i32);
116
117        pub fn variants() -> &'static [&'static str] {
118            &[
119                "SUCCEEDED",
120                "E_LOG_GAP",
121                "E_LOG_STALE",
122                "E_MISSING_COMMIT",
123                "E_WAITING_SNAPSHOT",
124                "E_UNKNOWN_PART",
125                "E_TERM_OUT_OF_DATE",
126                "E_LAST_LOG_TERM_TOO_OLD",
127                "E_BAD_STATE",
128                "E_WRONG_LEADER",
129                "E_WAL_FAIL",
130                "E_NOT_READY",
131                "E_HOST_STOPPED",
132                "E_NOT_A_LEADER",
133                "E_HOST_DISCONNECTED",
134                "E_TOO_MANY_REQUESTS",
135                "E_PERSIST_SNAPSHOT_FAILED",
136                "E_BAD_ROLE",
137                "E_EXCEPTION",
138            ]
139        }
140    }
141
142    impl ::std::default::Default for ErrorCode {
143        fn default() -> Self {
144            ErrorCode(::fbthrift::__UNKNOWN_ID)
145        }
146    }
147
148    impl<'a> ::std::convert::From<&'a ErrorCode> for ::std::primitive::i32 {
149        #[inline]
150        fn from(x: &'a ErrorCode) -> Self {
151            x.0
152        }
153    }
154
155    impl ::std::convert::From<ErrorCode> for ::std::primitive::i32 {
156        #[inline]
157        fn from(x: ErrorCode) -> Self {
158            x.0
159        }
160    }
161
162    impl ::std::convert::From<::std::primitive::i32> for ErrorCode {
163        #[inline]
164        fn from(x: ::std::primitive::i32) -> Self {
165            Self(x)
166        }
167    }
168
169    impl ::std::fmt::Display for ErrorCode {
170        fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
171            let s: &::std::primitive::str = match *self {
172                ErrorCode::SUCCEEDED => "SUCCEEDED",
173                ErrorCode::E_LOG_GAP => "E_LOG_GAP",
174                ErrorCode::E_LOG_STALE => "E_LOG_STALE",
175                ErrorCode::E_MISSING_COMMIT => "E_MISSING_COMMIT",
176                ErrorCode::E_WAITING_SNAPSHOT => "E_WAITING_SNAPSHOT",
177                ErrorCode::E_UNKNOWN_PART => "E_UNKNOWN_PART",
178                ErrorCode::E_TERM_OUT_OF_DATE => "E_TERM_OUT_OF_DATE",
179                ErrorCode::E_LAST_LOG_TERM_TOO_OLD => "E_LAST_LOG_TERM_TOO_OLD",
180                ErrorCode::E_BAD_STATE => "E_BAD_STATE",
181                ErrorCode::E_WRONG_LEADER => "E_WRONG_LEADER",
182                ErrorCode::E_WAL_FAIL => "E_WAL_FAIL",
183                ErrorCode::E_NOT_READY => "E_NOT_READY",
184                ErrorCode::E_HOST_STOPPED => "E_HOST_STOPPED",
185                ErrorCode::E_NOT_A_LEADER => "E_NOT_A_LEADER",
186                ErrorCode::E_HOST_DISCONNECTED => "E_HOST_DISCONNECTED",
187                ErrorCode::E_TOO_MANY_REQUESTS => "E_TOO_MANY_REQUESTS",
188                ErrorCode::E_PERSIST_SNAPSHOT_FAILED => "E_PERSIST_SNAPSHOT_FAILED",
189                ErrorCode::E_BAD_ROLE => "E_BAD_ROLE",
190                ErrorCode::E_EXCEPTION => "E_EXCEPTION",
191                ErrorCode(x) => return write!(fmt, "{}", x),
192            };
193            write!(fmt, "{}", s)
194        }
195    }
196
197    impl ::std::fmt::Debug for ErrorCode {
198        fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
199            write!(fmt, "ErrorCode::{}", self)
200        }
201    }
202
203    impl ::std::str::FromStr for ErrorCode {
204        type Err = ::anyhow::Error;
205
206        fn from_str(string: &::std::primitive::str) -> ::std::result::Result<Self, Self::Err> {
207            match string {
208                "SUCCEEDED" => ::std::result::Result::Ok(ErrorCode::SUCCEEDED),
209                "E_LOG_GAP" => ::std::result::Result::Ok(ErrorCode::E_LOG_GAP),
210                "E_LOG_STALE" => ::std::result::Result::Ok(ErrorCode::E_LOG_STALE),
211                "E_MISSING_COMMIT" => ::std::result::Result::Ok(ErrorCode::E_MISSING_COMMIT),
212                "E_WAITING_SNAPSHOT" => ::std::result::Result::Ok(ErrorCode::E_WAITING_SNAPSHOT),
213                "E_UNKNOWN_PART" => ::std::result::Result::Ok(ErrorCode::E_UNKNOWN_PART),
214                "E_TERM_OUT_OF_DATE" => ::std::result::Result::Ok(ErrorCode::E_TERM_OUT_OF_DATE),
215                "E_LAST_LOG_TERM_TOO_OLD" => ::std::result::Result::Ok(ErrorCode::E_LAST_LOG_TERM_TOO_OLD),
216                "E_BAD_STATE" => ::std::result::Result::Ok(ErrorCode::E_BAD_STATE),
217                "E_WRONG_LEADER" => ::std::result::Result::Ok(ErrorCode::E_WRONG_LEADER),
218                "E_WAL_FAIL" => ::std::result::Result::Ok(ErrorCode::E_WAL_FAIL),
219                "E_NOT_READY" => ::std::result::Result::Ok(ErrorCode::E_NOT_READY),
220                "E_HOST_STOPPED" => ::std::result::Result::Ok(ErrorCode::E_HOST_STOPPED),
221                "E_NOT_A_LEADER" => ::std::result::Result::Ok(ErrorCode::E_NOT_A_LEADER),
222                "E_HOST_DISCONNECTED" => ::std::result::Result::Ok(ErrorCode::E_HOST_DISCONNECTED),
223                "E_TOO_MANY_REQUESTS" => ::std::result::Result::Ok(ErrorCode::E_TOO_MANY_REQUESTS),
224                "E_PERSIST_SNAPSHOT_FAILED" => ::std::result::Result::Ok(ErrorCode::E_PERSIST_SNAPSHOT_FAILED),
225                "E_BAD_ROLE" => ::std::result::Result::Ok(ErrorCode::E_BAD_ROLE),
226                "E_EXCEPTION" => ::std::result::Result::Ok(ErrorCode::E_EXCEPTION),
227                _ => ::anyhow::bail!("Unable to parse {} as ErrorCode", string),
228            }
229        }
230    }
231
232    impl ::fbthrift::GetTType for ErrorCode {
233        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::I32;
234    }
235
236    impl<P> ::fbthrift::Serialize<P> for ErrorCode
237    where
238        P: ::fbthrift::ProtocolWriter,
239    {
240        #[inline]
241        fn write(&self, p: &mut P) {
242            p.write_i32(self.into())
243        }
244    }
245
246    impl<P> ::fbthrift::Deserialize<P> for ErrorCode
247    where
248        P: ::fbthrift::ProtocolReader,
249    {
250        #[inline]
251        fn read(p: &mut P) -> ::anyhow::Result<Self> {
252            ::std::result::Result::Ok(ErrorCode::from(p.read_i32()?))
253        }
254    }
255
256
257
258
259
260
261
262    impl ::std::default::Default for self::AskForVoteRequest {
263        fn default() -> Self {
264            Self {
265                space: ::std::default::Default::default(),
266                part: ::std::default::Default::default(),
267                candidate_addr: ::std::default::Default::default(),
268                candidate_port: ::std::default::Default::default(),
269                term: ::std::default::Default::default(),
270                last_log_id: ::std::default::Default::default(),
271                last_log_term: ::std::default::Default::default(),
272            }
273        }
274    }
275
276    unsafe impl ::std::marker::Send for self::AskForVoteRequest {}
277    unsafe impl ::std::marker::Sync for self::AskForVoteRequest {}
278
279    impl ::fbthrift::GetTType for self::AskForVoteRequest {
280        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
281    }
282
283    impl<P> ::fbthrift::Serialize<P> for self::AskForVoteRequest
284    where
285        P: ::fbthrift::ProtocolWriter,
286    {
287        fn write(&self, p: &mut P) {
288            p.write_struct_begin("AskForVoteRequest");
289            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
290            ::fbthrift::Serialize::write(&self.space, p);
291            p.write_field_end();
292            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
293            ::fbthrift::Serialize::write(&self.part, p);
294            p.write_field_end();
295            p.write_field_begin("candidate_addr", ::fbthrift::TType::String, 3);
296            ::fbthrift::Serialize::write(&self.candidate_addr, p);
297            p.write_field_end();
298            p.write_field_begin("candidate_port", ::fbthrift::TType::I32, 4);
299            ::fbthrift::Serialize::write(&self.candidate_port, p);
300            p.write_field_end();
301            p.write_field_begin("term", ::fbthrift::TType::I64, 5);
302            ::fbthrift::Serialize::write(&self.term, p);
303            p.write_field_end();
304            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 6);
305            ::fbthrift::Serialize::write(&self.last_log_id, p);
306            p.write_field_end();
307            p.write_field_begin("last_log_term", ::fbthrift::TType::I64, 7);
308            ::fbthrift::Serialize::write(&self.last_log_term, p);
309            p.write_field_end();
310            p.write_field_stop();
311            p.write_struct_end();
312        }
313    }
314
315    impl<P> ::fbthrift::Deserialize<P> for self::AskForVoteRequest
316    where
317        P: ::fbthrift::ProtocolReader,
318    {
319        fn read(p: &mut P) -> ::anyhow::Result<Self> {
320            let mut field_space = ::std::option::Option::None;
321            let mut field_part = ::std::option::Option::None;
322            let mut field_candidate_addr = ::std::option::Option::None;
323            let mut field_candidate_port = ::std::option::Option::None;
324            let mut field_term = ::std::option::Option::None;
325            let mut field_last_log_id = ::std::option::Option::None;
326            let mut field_last_log_term = ::std::option::Option::None;
327            let _ = p.read_struct_begin(|_| ())?;
328            loop {
329                let (_, fty, fid) = p.read_field_begin(|_| ())?;
330                match (fty, fid as ::std::primitive::i32) {
331                    (::fbthrift::TType::Stop, _) => break,
332                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
333                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
334                    (::fbthrift::TType::String, 3) => field_candidate_addr = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
335                    (::fbthrift::TType::I32, 4) => field_candidate_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
336                    (::fbthrift::TType::I64, 5) => field_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
337                    (::fbthrift::TType::I64, 6) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
338                    (::fbthrift::TType::I64, 7) => field_last_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
339                    (fty, _) => p.skip(fty)?,
340                }
341                p.read_field_end()?;
342            }
343            p.read_struct_end()?;
344            ::std::result::Result::Ok(Self {
345                space: field_space.unwrap_or_default(),
346                part: field_part.unwrap_or_default(),
347                candidate_addr: field_candidate_addr.unwrap_or_default(),
348                candidate_port: field_candidate_port.unwrap_or_default(),
349                term: field_term.unwrap_or_default(),
350                last_log_id: field_last_log_id.unwrap_or_default(),
351                last_log_term: field_last_log_term.unwrap_or_default(),
352            })
353        }
354    }
355
356
357    impl ::std::default::Default for self::AskForVoteResponse {
358        fn default() -> Self {
359            Self {
360                error_code: ::std::default::Default::default(),
361            }
362        }
363    }
364
365    unsafe impl ::std::marker::Send for self::AskForVoteResponse {}
366    unsafe impl ::std::marker::Sync for self::AskForVoteResponse {}
367
368    impl ::fbthrift::GetTType for self::AskForVoteResponse {
369        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
370    }
371
372    impl<P> ::fbthrift::Serialize<P> for self::AskForVoteResponse
373    where
374        P: ::fbthrift::ProtocolWriter,
375    {
376        fn write(&self, p: &mut P) {
377            p.write_struct_begin("AskForVoteResponse");
378            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
379            ::fbthrift::Serialize::write(&self.error_code, p);
380            p.write_field_end();
381            p.write_field_stop();
382            p.write_struct_end();
383        }
384    }
385
386    impl<P> ::fbthrift::Deserialize<P> for self::AskForVoteResponse
387    where
388        P: ::fbthrift::ProtocolReader,
389    {
390        fn read(p: &mut P) -> ::anyhow::Result<Self> {
391            let mut field_error_code = ::std::option::Option::None;
392            let _ = p.read_struct_begin(|_| ())?;
393            loop {
394                let (_, fty, fid) = p.read_field_begin(|_| ())?;
395                match (fty, fid as ::std::primitive::i32) {
396                    (::fbthrift::TType::Stop, _) => break,
397                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
398                    (fty, _) => p.skip(fty)?,
399                }
400                p.read_field_end()?;
401            }
402            p.read_struct_end()?;
403            ::std::result::Result::Ok(Self {
404                error_code: field_error_code.unwrap_or_default(),
405            })
406        }
407    }
408
409
410    impl ::std::default::Default for self::LogEntry {
411        fn default() -> Self {
412            Self {
413                cluster: ::std::default::Default::default(),
414                log_str: ::std::default::Default::default(),
415            }
416        }
417    }
418
419    unsafe impl ::std::marker::Send for self::LogEntry {}
420    unsafe impl ::std::marker::Sync for self::LogEntry {}
421
422    impl ::fbthrift::GetTType for self::LogEntry {
423        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
424    }
425
426    impl<P> ::fbthrift::Serialize<P> for self::LogEntry
427    where
428        P: ::fbthrift::ProtocolWriter,
429    {
430        fn write(&self, p: &mut P) {
431            p.write_struct_begin("LogEntry");
432            p.write_field_begin("cluster", ::fbthrift::TType::I64, 1);
433            ::fbthrift::Serialize::write(&self.cluster, p);
434            p.write_field_end();
435            p.write_field_begin("log_str", ::fbthrift::TType::String, 2);
436            ::fbthrift::Serialize::write(&self.log_str, p);
437            p.write_field_end();
438            p.write_field_stop();
439            p.write_struct_end();
440        }
441    }
442
443    impl<P> ::fbthrift::Deserialize<P> for self::LogEntry
444    where
445        P: ::fbthrift::ProtocolReader,
446    {
447        fn read(p: &mut P) -> ::anyhow::Result<Self> {
448            let mut field_cluster = ::std::option::Option::None;
449            let mut field_log_str = ::std::option::Option::None;
450            let _ = p.read_struct_begin(|_| ())?;
451            loop {
452                let (_, fty, fid) = p.read_field_begin(|_| ())?;
453                match (fty, fid as ::std::primitive::i32) {
454                    (::fbthrift::TType::Stop, _) => break,
455                    (::fbthrift::TType::I64, 1) => field_cluster = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
456                    (::fbthrift::TType::String, 2) => field_log_str = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
457                    (fty, _) => p.skip(fty)?,
458                }
459                p.read_field_end()?;
460            }
461            p.read_struct_end()?;
462            ::std::result::Result::Ok(Self {
463                cluster: field_cluster.unwrap_or_default(),
464                log_str: field_log_str.unwrap_or_default(),
465            })
466        }
467    }
468
469
470    impl ::std::default::Default for self::AppendLogRequest {
471        fn default() -> Self {
472            Self {
473                space: ::std::default::Default::default(),
474                part: ::std::default::Default::default(),
475                current_term: ::std::default::Default::default(),
476                last_log_id: ::std::default::Default::default(),
477                committed_log_id: ::std::default::Default::default(),
478                leader_addr: ::std::default::Default::default(),
479                leader_port: ::std::default::Default::default(),
480                last_log_term_sent: ::std::default::Default::default(),
481                last_log_id_sent: ::std::default::Default::default(),
482                log_term: ::std::default::Default::default(),
483                log_str_list: ::std::default::Default::default(),
484                sending_snapshot: ::std::default::Default::default(),
485            }
486        }
487    }
488
489    unsafe impl ::std::marker::Send for self::AppendLogRequest {}
490    unsafe impl ::std::marker::Sync for self::AppendLogRequest {}
491
492    impl ::fbthrift::GetTType for self::AppendLogRequest {
493        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
494    }
495
496    impl<P> ::fbthrift::Serialize<P> for self::AppendLogRequest
497    where
498        P: ::fbthrift::ProtocolWriter,
499    {
500        fn write(&self, p: &mut P) {
501            p.write_struct_begin("AppendLogRequest");
502            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
503            ::fbthrift::Serialize::write(&self.space, p);
504            p.write_field_end();
505            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
506            ::fbthrift::Serialize::write(&self.part, p);
507            p.write_field_end();
508            p.write_field_begin("current_term", ::fbthrift::TType::I64, 3);
509            ::fbthrift::Serialize::write(&self.current_term, p);
510            p.write_field_end();
511            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 4);
512            ::fbthrift::Serialize::write(&self.last_log_id, p);
513            p.write_field_end();
514            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 5);
515            ::fbthrift::Serialize::write(&self.committed_log_id, p);
516            p.write_field_end();
517            p.write_field_begin("leader_addr", ::fbthrift::TType::String, 6);
518            ::fbthrift::Serialize::write(&self.leader_addr, p);
519            p.write_field_end();
520            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 7);
521            ::fbthrift::Serialize::write(&self.leader_port, p);
522            p.write_field_end();
523            p.write_field_begin("last_log_term_sent", ::fbthrift::TType::I64, 8);
524            ::fbthrift::Serialize::write(&self.last_log_term_sent, p);
525            p.write_field_end();
526            p.write_field_begin("last_log_id_sent", ::fbthrift::TType::I64, 9);
527            ::fbthrift::Serialize::write(&self.last_log_id_sent, p);
528            p.write_field_end();
529            p.write_field_begin("log_term", ::fbthrift::TType::I64, 10);
530            ::fbthrift::Serialize::write(&self.log_term, p);
531            p.write_field_end();
532            p.write_field_begin("log_str_list", ::fbthrift::TType::List, 11);
533            ::fbthrift::Serialize::write(&self.log_str_list, p);
534            p.write_field_end();
535            p.write_field_begin("sending_snapshot", ::fbthrift::TType::Bool, 12);
536            ::fbthrift::Serialize::write(&self.sending_snapshot, p);
537            p.write_field_end();
538            p.write_field_stop();
539            p.write_struct_end();
540        }
541    }
542
543    impl<P> ::fbthrift::Deserialize<P> for self::AppendLogRequest
544    where
545        P: ::fbthrift::ProtocolReader,
546    {
547        fn read(p: &mut P) -> ::anyhow::Result<Self> {
548            let mut field_space = ::std::option::Option::None;
549            let mut field_part = ::std::option::Option::None;
550            let mut field_current_term = ::std::option::Option::None;
551            let mut field_last_log_id = ::std::option::Option::None;
552            let mut field_committed_log_id = ::std::option::Option::None;
553            let mut field_leader_addr = ::std::option::Option::None;
554            let mut field_leader_port = ::std::option::Option::None;
555            let mut field_last_log_term_sent = ::std::option::Option::None;
556            let mut field_last_log_id_sent = ::std::option::Option::None;
557            let mut field_log_term = ::std::option::Option::None;
558            let mut field_log_str_list = ::std::option::Option::None;
559            let mut field_sending_snapshot = ::std::option::Option::None;
560            let _ = p.read_struct_begin(|_| ())?;
561            loop {
562                let (_, fty, fid) = p.read_field_begin(|_| ())?;
563                match (fty, fid as ::std::primitive::i32) {
564                    (::fbthrift::TType::Stop, _) => break,
565                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
566                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
567                    (::fbthrift::TType::I64, 3) => field_current_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
568                    (::fbthrift::TType::I64, 4) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
569                    (::fbthrift::TType::I64, 5) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
570                    (::fbthrift::TType::String, 6) => field_leader_addr = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
571                    (::fbthrift::TType::I32, 7) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
572                    (::fbthrift::TType::I64, 8) => field_last_log_term_sent = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
573                    (::fbthrift::TType::I64, 9) => field_last_log_id_sent = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
574                    (::fbthrift::TType::I64, 10) => field_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
575                    (::fbthrift::TType::List, 11) => field_log_str_list = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
576                    (::fbthrift::TType::Bool, 12) => field_sending_snapshot = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
577                    (fty, _) => p.skip(fty)?,
578                }
579                p.read_field_end()?;
580            }
581            p.read_struct_end()?;
582            ::std::result::Result::Ok(Self {
583                space: field_space.unwrap_or_default(),
584                part: field_part.unwrap_or_default(),
585                current_term: field_current_term.unwrap_or_default(),
586                last_log_id: field_last_log_id.unwrap_or_default(),
587                committed_log_id: field_committed_log_id.unwrap_or_default(),
588                leader_addr: field_leader_addr.unwrap_or_default(),
589                leader_port: field_leader_port.unwrap_or_default(),
590                last_log_term_sent: field_last_log_term_sent.unwrap_or_default(),
591                last_log_id_sent: field_last_log_id_sent.unwrap_or_default(),
592                log_term: field_log_term.unwrap_or_default(),
593                log_str_list: field_log_str_list.unwrap_or_default(),
594                sending_snapshot: field_sending_snapshot.unwrap_or_default(),
595            })
596        }
597    }
598
599
600    impl ::std::default::Default for self::AppendLogResponse {
601        fn default() -> Self {
602            Self {
603                error_code: ::std::default::Default::default(),
604                current_term: ::std::default::Default::default(),
605                leader_addr: ::std::default::Default::default(),
606                leader_port: ::std::default::Default::default(),
607                committed_log_id: ::std::default::Default::default(),
608                last_log_id: ::std::default::Default::default(),
609                last_log_term: ::std::default::Default::default(),
610            }
611        }
612    }
613
614    unsafe impl ::std::marker::Send for self::AppendLogResponse {}
615    unsafe impl ::std::marker::Sync for self::AppendLogResponse {}
616
617    impl ::fbthrift::GetTType for self::AppendLogResponse {
618        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
619    }
620
621    impl<P> ::fbthrift::Serialize<P> for self::AppendLogResponse
622    where
623        P: ::fbthrift::ProtocolWriter,
624    {
625        fn write(&self, p: &mut P) {
626            p.write_struct_begin("AppendLogResponse");
627            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
628            ::fbthrift::Serialize::write(&self.error_code, p);
629            p.write_field_end();
630            p.write_field_begin("current_term", ::fbthrift::TType::I64, 2);
631            ::fbthrift::Serialize::write(&self.current_term, p);
632            p.write_field_end();
633            p.write_field_begin("leader_addr", ::fbthrift::TType::String, 3);
634            ::fbthrift::Serialize::write(&self.leader_addr, p);
635            p.write_field_end();
636            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 4);
637            ::fbthrift::Serialize::write(&self.leader_port, p);
638            p.write_field_end();
639            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 5);
640            ::fbthrift::Serialize::write(&self.committed_log_id, p);
641            p.write_field_end();
642            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 6);
643            ::fbthrift::Serialize::write(&self.last_log_id, p);
644            p.write_field_end();
645            p.write_field_begin("last_log_term", ::fbthrift::TType::I64, 7);
646            ::fbthrift::Serialize::write(&self.last_log_term, p);
647            p.write_field_end();
648            p.write_field_stop();
649            p.write_struct_end();
650        }
651    }
652
653    impl<P> ::fbthrift::Deserialize<P> for self::AppendLogResponse
654    where
655        P: ::fbthrift::ProtocolReader,
656    {
657        fn read(p: &mut P) -> ::anyhow::Result<Self> {
658            let mut field_error_code = ::std::option::Option::None;
659            let mut field_current_term = ::std::option::Option::None;
660            let mut field_leader_addr = ::std::option::Option::None;
661            let mut field_leader_port = ::std::option::Option::None;
662            let mut field_committed_log_id = ::std::option::Option::None;
663            let mut field_last_log_id = ::std::option::Option::None;
664            let mut field_last_log_term = ::std::option::Option::None;
665            let _ = p.read_struct_begin(|_| ())?;
666            loop {
667                let (_, fty, fid) = p.read_field_begin(|_| ())?;
668                match (fty, fid as ::std::primitive::i32) {
669                    (::fbthrift::TType::Stop, _) => break,
670                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
671                    (::fbthrift::TType::I64, 2) => field_current_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
672                    (::fbthrift::TType::String, 3) => field_leader_addr = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
673                    (::fbthrift::TType::I32, 4) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
674                    (::fbthrift::TType::I64, 5) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
675                    (::fbthrift::TType::I64, 6) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
676                    (::fbthrift::TType::I64, 7) => field_last_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
677                    (fty, _) => p.skip(fty)?,
678                }
679                p.read_field_end()?;
680            }
681            p.read_struct_end()?;
682            ::std::result::Result::Ok(Self {
683                error_code: field_error_code.unwrap_or_default(),
684                current_term: field_current_term.unwrap_or_default(),
685                leader_addr: field_leader_addr.unwrap_or_default(),
686                leader_port: field_leader_port.unwrap_or_default(),
687                committed_log_id: field_committed_log_id.unwrap_or_default(),
688                last_log_id: field_last_log_id.unwrap_or_default(),
689                last_log_term: field_last_log_term.unwrap_or_default(),
690            })
691        }
692    }
693
694
695    impl ::std::default::Default for self::SendSnapshotRequest {
696        fn default() -> Self {
697            Self {
698                space: ::std::default::Default::default(),
699                part: ::std::default::Default::default(),
700                term: ::std::default::Default::default(),
701                committed_log_id: ::std::default::Default::default(),
702                committed_log_term: ::std::default::Default::default(),
703                leader_addr: ::std::default::Default::default(),
704                leader_port: ::std::default::Default::default(),
705                rows: ::std::default::Default::default(),
706                total_size: ::std::default::Default::default(),
707                total_count: ::std::default::Default::default(),
708                done: ::std::default::Default::default(),
709            }
710        }
711    }
712
713    unsafe impl ::std::marker::Send for self::SendSnapshotRequest {}
714    unsafe impl ::std::marker::Sync for self::SendSnapshotRequest {}
715
716    impl ::fbthrift::GetTType for self::SendSnapshotRequest {
717        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
718    }
719
720    impl<P> ::fbthrift::Serialize<P> for self::SendSnapshotRequest
721    where
722        P: ::fbthrift::ProtocolWriter,
723    {
724        fn write(&self, p: &mut P) {
725            p.write_struct_begin("SendSnapshotRequest");
726            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
727            ::fbthrift::Serialize::write(&self.space, p);
728            p.write_field_end();
729            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
730            ::fbthrift::Serialize::write(&self.part, p);
731            p.write_field_end();
732            p.write_field_begin("term", ::fbthrift::TType::I64, 3);
733            ::fbthrift::Serialize::write(&self.term, p);
734            p.write_field_end();
735            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 4);
736            ::fbthrift::Serialize::write(&self.committed_log_id, p);
737            p.write_field_end();
738            p.write_field_begin("committed_log_term", ::fbthrift::TType::I64, 5);
739            ::fbthrift::Serialize::write(&self.committed_log_term, p);
740            p.write_field_end();
741            p.write_field_begin("leader_addr", ::fbthrift::TType::String, 6);
742            ::fbthrift::Serialize::write(&self.leader_addr, p);
743            p.write_field_end();
744            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 7);
745            ::fbthrift::Serialize::write(&self.leader_port, p);
746            p.write_field_end();
747            p.write_field_begin("rows", ::fbthrift::TType::List, 8);
748            ::fbthrift::Serialize::write(&self.rows, p);
749            p.write_field_end();
750            p.write_field_begin("total_size", ::fbthrift::TType::I64, 9);
751            ::fbthrift::Serialize::write(&self.total_size, p);
752            p.write_field_end();
753            p.write_field_begin("total_count", ::fbthrift::TType::I64, 10);
754            ::fbthrift::Serialize::write(&self.total_count, p);
755            p.write_field_end();
756            p.write_field_begin("done", ::fbthrift::TType::Bool, 11);
757            ::fbthrift::Serialize::write(&self.done, p);
758            p.write_field_end();
759            p.write_field_stop();
760            p.write_struct_end();
761        }
762    }
763
764    impl<P> ::fbthrift::Deserialize<P> for self::SendSnapshotRequest
765    where
766        P: ::fbthrift::ProtocolReader,
767    {
768        fn read(p: &mut P) -> ::anyhow::Result<Self> {
769            let mut field_space = ::std::option::Option::None;
770            let mut field_part = ::std::option::Option::None;
771            let mut field_term = ::std::option::Option::None;
772            let mut field_committed_log_id = ::std::option::Option::None;
773            let mut field_committed_log_term = ::std::option::Option::None;
774            let mut field_leader_addr = ::std::option::Option::None;
775            let mut field_leader_port = ::std::option::Option::None;
776            let mut field_rows = ::std::option::Option::None;
777            let mut field_total_size = ::std::option::Option::None;
778            let mut field_total_count = ::std::option::Option::None;
779            let mut field_done = ::std::option::Option::None;
780            let _ = p.read_struct_begin(|_| ())?;
781            loop {
782                let (_, fty, fid) = p.read_field_begin(|_| ())?;
783                match (fty, fid as ::std::primitive::i32) {
784                    (::fbthrift::TType::Stop, _) => break,
785                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
786                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
787                    (::fbthrift::TType::I64, 3) => field_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
788                    (::fbthrift::TType::I64, 4) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
789                    (::fbthrift::TType::I64, 5) => field_committed_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
790                    (::fbthrift::TType::String, 6) => field_leader_addr = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
791                    (::fbthrift::TType::I32, 7) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
792                    (::fbthrift::TType::List, 8) => field_rows = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
793                    (::fbthrift::TType::I64, 9) => field_total_size = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
794                    (::fbthrift::TType::I64, 10) => field_total_count = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
795                    (::fbthrift::TType::Bool, 11) => field_done = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
796                    (fty, _) => p.skip(fty)?,
797                }
798                p.read_field_end()?;
799            }
800            p.read_struct_end()?;
801            ::std::result::Result::Ok(Self {
802                space: field_space.unwrap_or_default(),
803                part: field_part.unwrap_or_default(),
804                term: field_term.unwrap_or_default(),
805                committed_log_id: field_committed_log_id.unwrap_or_default(),
806                committed_log_term: field_committed_log_term.unwrap_or_default(),
807                leader_addr: field_leader_addr.unwrap_or_default(),
808                leader_port: field_leader_port.unwrap_or_default(),
809                rows: field_rows.unwrap_or_default(),
810                total_size: field_total_size.unwrap_or_default(),
811                total_count: field_total_count.unwrap_or_default(),
812                done: field_done.unwrap_or_default(),
813            })
814        }
815    }
816
817
818    impl ::std::default::Default for self::SendSnapshotResponse {
819        fn default() -> Self {
820            Self {
821                error_code: ::std::default::Default::default(),
822            }
823        }
824    }
825
826    unsafe impl ::std::marker::Send for self::SendSnapshotResponse {}
827    unsafe impl ::std::marker::Sync for self::SendSnapshotResponse {}
828
829    impl ::fbthrift::GetTType for self::SendSnapshotResponse {
830        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
831    }
832
833    impl<P> ::fbthrift::Serialize<P> for self::SendSnapshotResponse
834    where
835        P: ::fbthrift::ProtocolWriter,
836    {
837        fn write(&self, p: &mut P) {
838            p.write_struct_begin("SendSnapshotResponse");
839            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
840            ::fbthrift::Serialize::write(&self.error_code, p);
841            p.write_field_end();
842            p.write_field_stop();
843            p.write_struct_end();
844        }
845    }
846
847    impl<P> ::fbthrift::Deserialize<P> for self::SendSnapshotResponse
848    where
849        P: ::fbthrift::ProtocolReader,
850    {
851        fn read(p: &mut P) -> ::anyhow::Result<Self> {
852            let mut field_error_code = ::std::option::Option::None;
853            let _ = p.read_struct_begin(|_| ())?;
854            loop {
855                let (_, fty, fid) = p.read_field_begin(|_| ())?;
856                match (fty, fid as ::std::primitive::i32) {
857                    (::fbthrift::TType::Stop, _) => break,
858                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
859                    (fty, _) => p.skip(fty)?,
860                }
861                p.read_field_end()?;
862            }
863            p.read_struct_end()?;
864            ::std::result::Result::Ok(Self {
865                error_code: field_error_code.unwrap_or_default(),
866            })
867        }
868    }
869
870}
871
872pub mod dependencies {
873}
874
875pub mod services {
876    pub mod raftex_service {
877
878        #[derive(Clone, Debug)]
879        pub enum AskForVoteExn {
880            Success(crate::types::AskForVoteResponse),
881            ApplicationException(::fbthrift::ApplicationException),
882        }
883
884        impl ::std::convert::From<::fbthrift::ApplicationException> for AskForVoteExn {
885            fn from(exn: ::fbthrift::ApplicationException) -> Self {
886                AskForVoteExn::ApplicationException(exn)
887            }
888        }
889
890        impl ::fbthrift::GetTType for AskForVoteExn {
891            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
892        }
893
894        impl<P> ::fbthrift::Serialize<P> for AskForVoteExn
895        where
896            P: ::fbthrift::ProtocolWriter,
897        {
898            fn write(&self, p: &mut P) {
899                p.write_struct_begin("AskForVote");
900                match self {
901                    AskForVoteExn::Success(inner) => {
902                        p.write_field_begin(
903                            "Success",
904                            ::fbthrift::TType::Struct,
905                            0i16,
906                        );
907                        inner.write(p);
908                        p.write_field_end();
909                    }
910                    AskForVoteExn::ApplicationException(_) => panic!(
911                        "Bad union Alt field {} id {}",
912                        "ApplicationException",
913                        -2147483648i32,
914                    ),
915                }
916                p.write_field_stop();
917                p.write_struct_end();
918            }
919        }
920
921        impl<P> ::fbthrift::Deserialize<P> for AskForVoteExn
922        where
923            P: ::fbthrift::ProtocolReader,
924        {
925            fn read(p: &mut P) -> ::anyhow::Result<Self> {
926                let _ = p.read_struct_begin(|_| ())?;
927                let mut once = false;
928                let mut alt = ::std::option::Option::None;
929                loop {
930                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
931                    match ((fty, fid as ::std::primitive::i32), once) {
932                        ((::fbthrift::TType::Stop, _), _) => {
933                            p.read_field_end()?;
934                            break;
935                        }
936                        ((::fbthrift::TType::Struct, 0i32), false) => {
937                            once = true;
938                            alt = ::std::option::Option::Some(AskForVoteExn::Success(::fbthrift::Deserialize::read(p)?));
939                        }
940                        ((ty, _id), false) => p.skip(ty)?,
941                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
942                            ::fbthrift::ApplicationException::new(
943                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
944                                format!(
945                                    "unwanted extra union {} field ty {:?} id {}",
946                                    "AskForVoteExn",
947                                    badty,
948                                    badid,
949                                ),
950                            )
951                        )),
952                    }
953                    p.read_field_end()?;
954                }
955                p.read_struct_end()?;
956                alt.ok_or_else(||
957                    ::fbthrift::ApplicationException::new(
958                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
959                        format!("Empty union {}", "AskForVoteExn"),
960                    )
961                    .into(),
962                )
963            }
964        }
965
966        #[derive(Clone, Debug)]
967        pub enum AppendLogExn {
968            Success(crate::types::AppendLogResponse),
969            ApplicationException(::fbthrift::ApplicationException),
970        }
971
972        impl ::std::convert::From<::fbthrift::ApplicationException> for AppendLogExn {
973            fn from(exn: ::fbthrift::ApplicationException) -> Self {
974                AppendLogExn::ApplicationException(exn)
975            }
976        }
977
978        impl ::fbthrift::GetTType for AppendLogExn {
979            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
980        }
981
982        impl<P> ::fbthrift::Serialize<P> for AppendLogExn
983        where
984            P: ::fbthrift::ProtocolWriter,
985        {
986            fn write(&self, p: &mut P) {
987                p.write_struct_begin("AppendLog");
988                match self {
989                    AppendLogExn::Success(inner) => {
990                        p.write_field_begin(
991                            "Success",
992                            ::fbthrift::TType::Struct,
993                            0i16,
994                        );
995                        inner.write(p);
996                        p.write_field_end();
997                    }
998                    AppendLogExn::ApplicationException(_) => panic!(
999                        "Bad union Alt field {} id {}",
1000                        "ApplicationException",
1001                        -2147483648i32,
1002                    ),
1003                }
1004                p.write_field_stop();
1005                p.write_struct_end();
1006            }
1007        }
1008
1009        impl<P> ::fbthrift::Deserialize<P> for AppendLogExn
1010        where
1011            P: ::fbthrift::ProtocolReader,
1012        {
1013            fn read(p: &mut P) -> ::anyhow::Result<Self> {
1014                let _ = p.read_struct_begin(|_| ())?;
1015                let mut once = false;
1016                let mut alt = ::std::option::Option::None;
1017                loop {
1018                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
1019                    match ((fty, fid as ::std::primitive::i32), once) {
1020                        ((::fbthrift::TType::Stop, _), _) => {
1021                            p.read_field_end()?;
1022                            break;
1023                        }
1024                        ((::fbthrift::TType::Struct, 0i32), false) => {
1025                            once = true;
1026                            alt = ::std::option::Option::Some(AppendLogExn::Success(::fbthrift::Deserialize::read(p)?));
1027                        }
1028                        ((ty, _id), false) => p.skip(ty)?,
1029                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
1030                            ::fbthrift::ApplicationException::new(
1031                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
1032                                format!(
1033                                    "unwanted extra union {} field ty {:?} id {}",
1034                                    "AppendLogExn",
1035                                    badty,
1036                                    badid,
1037                                ),
1038                            )
1039                        )),
1040                    }
1041                    p.read_field_end()?;
1042                }
1043                p.read_struct_end()?;
1044                alt.ok_or_else(||
1045                    ::fbthrift::ApplicationException::new(
1046                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
1047                        format!("Empty union {}", "AppendLogExn"),
1048                    )
1049                    .into(),
1050                )
1051            }
1052        }
1053
1054        #[derive(Clone, Debug)]
1055        pub enum SendSnapshotExn {
1056            Success(crate::types::SendSnapshotResponse),
1057            ApplicationException(::fbthrift::ApplicationException),
1058        }
1059
1060        impl ::std::convert::From<::fbthrift::ApplicationException> for SendSnapshotExn {
1061            fn from(exn: ::fbthrift::ApplicationException) -> Self {
1062                SendSnapshotExn::ApplicationException(exn)
1063            }
1064        }
1065
1066        impl ::fbthrift::GetTType for SendSnapshotExn {
1067            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
1068        }
1069
1070        impl<P> ::fbthrift::Serialize<P> for SendSnapshotExn
1071        where
1072            P: ::fbthrift::ProtocolWriter,
1073        {
1074            fn write(&self, p: &mut P) {
1075                p.write_struct_begin("SendSnapshot");
1076                match self {
1077                    SendSnapshotExn::Success(inner) => {
1078                        p.write_field_begin(
1079                            "Success",
1080                            ::fbthrift::TType::Struct,
1081                            0i16,
1082                        );
1083                        inner.write(p);
1084                        p.write_field_end();
1085                    }
1086                    SendSnapshotExn::ApplicationException(_) => panic!(
1087                        "Bad union Alt field {} id {}",
1088                        "ApplicationException",
1089                        -2147483648i32,
1090                    ),
1091                }
1092                p.write_field_stop();
1093                p.write_struct_end();
1094            }
1095        }
1096
1097        impl<P> ::fbthrift::Deserialize<P> for SendSnapshotExn
1098        where
1099            P: ::fbthrift::ProtocolReader,
1100        {
1101            fn read(p: &mut P) -> ::anyhow::Result<Self> {
1102                let _ = p.read_struct_begin(|_| ())?;
1103                let mut once = false;
1104                let mut alt = ::std::option::Option::None;
1105                loop {
1106                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
1107                    match ((fty, fid as ::std::primitive::i32), once) {
1108                        ((::fbthrift::TType::Stop, _), _) => {
1109                            p.read_field_end()?;
1110                            break;
1111                        }
1112                        ((::fbthrift::TType::Struct, 0i32), false) => {
1113                            once = true;
1114                            alt = ::std::option::Option::Some(SendSnapshotExn::Success(::fbthrift::Deserialize::read(p)?));
1115                        }
1116                        ((ty, _id), false) => p.skip(ty)?,
1117                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
1118                            ::fbthrift::ApplicationException::new(
1119                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
1120                                format!(
1121                                    "unwanted extra union {} field ty {:?} id {}",
1122                                    "SendSnapshotExn",
1123                                    badty,
1124                                    badid,
1125                                ),
1126                            )
1127                        )),
1128                    }
1129                    p.read_field_end()?;
1130                }
1131                p.read_struct_end()?;
1132                alt.ok_or_else(||
1133                    ::fbthrift::ApplicationException::new(
1134                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
1135                        format!("Empty union {}", "SendSnapshotExn"),
1136                    )
1137                    .into(),
1138                )
1139            }
1140        }
1141    }
1142}
1143
1144pub mod client {
1145
1146    pub struct RaftexServiceImpl<P, T> {
1147        transport: T,
1148        _phantom: ::std::marker::PhantomData<fn() -> P>,
1149    }
1150
1151    impl<P, T> RaftexServiceImpl<P, T> {
1152        pub fn new(
1153            transport: T,
1154        ) -> Self {
1155            Self {
1156                transport,
1157                _phantom: ::std::marker::PhantomData,
1158            }
1159        }
1160
1161        pub fn transport(&self) -> &T {
1162            &self.transport
1163        }
1164    }
1165
1166    pub trait RaftexService: ::std::marker::Send {
1167        fn askForVote(
1168            &self,
1169            arg_req: &crate::types::AskForVoteRequest,
1170        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>>;
1171        fn appendLog(
1172            &self,
1173            arg_req: &crate::types::AppendLogRequest,
1174        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>>;
1175        fn sendSnapshot(
1176            &self,
1177            arg_req: &crate::types::SendSnapshotRequest,
1178        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>>;
1179    }
1180
1181    impl<P, T> RaftexService for RaftexServiceImpl<P, T>
1182    where
1183        P: ::fbthrift::Protocol,
1184        T: ::fbthrift::Transport,
1185        P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
1186        ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
1187    {        fn askForVote(
1188            &self,
1189            arg_req: &crate::types::AskForVoteRequest,
1190        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
1191            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
1192            use ::futures::future::{FutureExt as _, TryFutureExt as _};
1193            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1194                p,
1195                "askForVote",
1196                ::fbthrift::MessageType::Call,
1197                // Note: we send a 0 message sequence ID from clients because
1198                // this field should not be used by the server (except for some
1199                // language implementations).
1200                0,
1201                |p| {
1202                    p.write_struct_begin("args");
1203                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
1204                    ::fbthrift::Serialize::write(&arg_req, p);
1205                    p.write_field_end();
1206                    p.write_field_stop();
1207                    p.write_struct_end();
1208                },
1209            ));
1210            self.transport()
1211                .call(request)
1212                .map_err(::std::convert::From::from)
1213                .and_then(|reply| ::futures::future::ready({
1214                    let de = P::deserializer(reply);
1215                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError> {
1216                        let p = &mut p;
1217                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
1218                        let result = match message_type {
1219                            ::fbthrift::MessageType::Reply => {
1220                                let exn: crate::services::raftex_service::AskForVoteExn = ::fbthrift::Deserialize::read(p)?;
1221                                match exn {
1222                                    crate::services::raftex_service::AskForVoteExn::Success(x) => ::std::result::Result::Ok(x),
1223                                    crate::services::raftex_service::AskForVoteExn::ApplicationException(ae) => {
1224                                        ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(ae))
1225                                    }
1226                                }
1227                            }
1228                            ::fbthrift::MessageType::Exception => {
1229                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
1230                                ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(ae))
1231                            }
1232                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
1233                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
1234                                ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ThriftError(err))
1235                            }
1236                        };
1237                        p.read_message_end()?;
1238                        result
1239                    }(de)
1240                }))
1241                .boxed()
1242        }
1243        fn appendLog(
1244            &self,
1245            arg_req: &crate::types::AppendLogRequest,
1246        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
1247            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
1248            use ::futures::future::{FutureExt as _, TryFutureExt as _};
1249            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1250                p,
1251                "appendLog",
1252                ::fbthrift::MessageType::Call,
1253                // Note: we send a 0 message sequence ID from clients because
1254                // this field should not be used by the server (except for some
1255                // language implementations).
1256                0,
1257                |p| {
1258                    p.write_struct_begin("args");
1259                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
1260                    ::fbthrift::Serialize::write(&arg_req, p);
1261                    p.write_field_end();
1262                    p.write_field_stop();
1263                    p.write_struct_end();
1264                },
1265            ));
1266            self.transport()
1267                .call(request)
1268                .map_err(::std::convert::From::from)
1269                .and_then(|reply| ::futures::future::ready({
1270                    let de = P::deserializer(reply);
1271                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError> {
1272                        let p = &mut p;
1273                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
1274                        let result = match message_type {
1275                            ::fbthrift::MessageType::Reply => {
1276                                let exn: crate::services::raftex_service::AppendLogExn = ::fbthrift::Deserialize::read(p)?;
1277                                match exn {
1278                                    crate::services::raftex_service::AppendLogExn::Success(x) => ::std::result::Result::Ok(x),
1279                                    crate::services::raftex_service::AppendLogExn::ApplicationException(ae) => {
1280                                        ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(ae))
1281                                    }
1282                                }
1283                            }
1284                            ::fbthrift::MessageType::Exception => {
1285                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
1286                                ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(ae))
1287                            }
1288                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
1289                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
1290                                ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ThriftError(err))
1291                            }
1292                        };
1293                        p.read_message_end()?;
1294                        result
1295                    }(de)
1296                }))
1297                .boxed()
1298        }
1299        fn sendSnapshot(
1300            &self,
1301            arg_req: &crate::types::SendSnapshotRequest,
1302        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
1303            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
1304            use ::futures::future::{FutureExt as _, TryFutureExt as _};
1305            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1306                p,
1307                "sendSnapshot",
1308                ::fbthrift::MessageType::Call,
1309                // Note: we send a 0 message sequence ID from clients because
1310                // this field should not be used by the server (except for some
1311                // language implementations).
1312                0,
1313                |p| {
1314                    p.write_struct_begin("args");
1315                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
1316                    ::fbthrift::Serialize::write(&arg_req, p);
1317                    p.write_field_end();
1318                    p.write_field_stop();
1319                    p.write_struct_end();
1320                },
1321            ));
1322            self.transport()
1323                .call(request)
1324                .map_err(::std::convert::From::from)
1325                .and_then(|reply| ::futures::future::ready({
1326                    let de = P::deserializer(reply);
1327                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError> {
1328                        let p = &mut p;
1329                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
1330                        let result = match message_type {
1331                            ::fbthrift::MessageType::Reply => {
1332                                let exn: crate::services::raftex_service::SendSnapshotExn = ::fbthrift::Deserialize::read(p)?;
1333                                match exn {
1334                                    crate::services::raftex_service::SendSnapshotExn::Success(x) => ::std::result::Result::Ok(x),
1335                                    crate::services::raftex_service::SendSnapshotExn::ApplicationException(ae) => {
1336                                        ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(ae))
1337                                    }
1338                                }
1339                            }
1340                            ::fbthrift::MessageType::Exception => {
1341                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
1342                                ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(ae))
1343                            }
1344                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
1345                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
1346                                ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ThriftError(err))
1347                            }
1348                        };
1349                        p.read_message_end()?;
1350                        result
1351                    }(de)
1352                }))
1353                .boxed()
1354        }
1355    }
1356
1357    impl<'a, T> RaftexService for T
1358    where
1359        T: ::std::convert::AsRef<dyn RaftexService + 'a>,
1360        T: ::std::marker::Send,
1361    {
1362        fn askForVote(
1363            &self,
1364            arg_req: &crate::types::AskForVoteRequest,
1365        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
1366            self.as_ref().askForVote(
1367                arg_req,
1368            )
1369        }
1370        fn appendLog(
1371            &self,
1372            arg_req: &crate::types::AppendLogRequest,
1373        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
1374            self.as_ref().appendLog(
1375                arg_req,
1376            )
1377        }
1378        fn sendSnapshot(
1379            &self,
1380            arg_req: &crate::types::SendSnapshotRequest,
1381        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
1382            self.as_ref().sendSnapshot(
1383                arg_req,
1384            )
1385        }
1386    }
1387
1388    pub struct make_RaftexService;
1389
1390    /// To be called by user directly setting up a client. Avoids
1391    /// needing ClientFactory trait in scope, avoids unidiomatic
1392    /// make_Trait name.
1393    ///
1394    /// ```
1395    /// use bgs::client::BuckGraphService;
1396    ///
1397    /// let protocol = BinaryProtocol::new();
1398    /// let transport = HttpClient::new();
1399    /// let client = BuckGraphService::new(protocol, transport);
1400    /// ```
1401    impl dyn RaftexService {
1402        pub fn new<P, T>(
1403            protocol: P,
1404            transport: T,
1405        ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + 'static>
1406        where
1407            P: ::fbthrift::Protocol<Frame = T>,
1408            T: ::fbthrift::Transport,
1409        {
1410            let _ = protocol;
1411            ::std::sync::Arc::new(RaftexServiceImpl::<P, T>::new(transport))
1412        }
1413    }
1414
1415    /// The same thing, but to be called from generic contexts where we are
1416    /// working with a type parameter `C: ClientFactory` to produce clients.
1417    impl ::fbthrift::ClientFactory for make_RaftexService {
1418        type Api = dyn RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static;
1419
1420        fn new<P, T>(protocol: P, transport: T) -> ::std::sync::Arc<Self::Api>
1421        where
1422            P: ::fbthrift::Protocol<Frame = T>,
1423            T: ::fbthrift::Transport + ::std::marker::Sync,
1424        {
1425            RaftexService::new(protocol, transport)
1426        }
1427    }
1428}
1429
1430pub mod server {
1431    #[::async_trait::async_trait]
1432    pub trait RaftexService: ::std::marker::Send + ::std::marker::Sync + 'static {
1433        async fn askForVote(
1434            &self,
1435            _req: crate::types::AskForVoteRequest,
1436        ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
1437            ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(
1438                ::fbthrift::ApplicationException::unimplemented_method(
1439                    "RaftexService",
1440                    "askForVote",
1441                ),
1442            ))
1443        }
1444        async fn appendLog(
1445            &self,
1446            _req: crate::types::AppendLogRequest,
1447        ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
1448            ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(
1449                ::fbthrift::ApplicationException::unimplemented_method(
1450                    "RaftexService",
1451                    "appendLog",
1452                ),
1453            ))
1454        }
1455        async fn sendSnapshot(
1456            &self,
1457            _req: crate::types::SendSnapshotRequest,
1458        ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
1459            ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(
1460                ::fbthrift::ApplicationException::unimplemented_method(
1461                    "RaftexService",
1462                    "sendSnapshot",
1463                ),
1464            ))
1465        }
1466    }
1467
1468    #[derive(Clone, Debug)]
1469    pub struct RaftexServiceProcessor<P, H, R> {
1470        service: H,
1471        supa: ::fbthrift::NullServiceProcessor<P, R>,
1472        _phantom: ::std::marker::PhantomData<(P, H, R)>,
1473    }
1474
1475    impl<P, H, R> RaftexServiceProcessor<P, H, R>
1476    where
1477        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1478        P::Deserializer: ::std::marker::Send,
1479        H: RaftexService,
1480    {
1481        pub fn new(service: H) -> Self {
1482            Self {
1483                service,
1484                supa: ::fbthrift::NullServiceProcessor::new(),
1485                _phantom: ::std::marker::PhantomData,
1486            }
1487        }
1488
1489        pub fn into_inner(self) -> H {
1490            self.service
1491        }
1492
1493        async fn handle_askForVote<'a>(
1494            &'a self,
1495            p: &'a mut P::Deserializer,
1496            _req_ctxt: &R,
1497            seqid: ::std::primitive::u32,
1498        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
1499            use ::fbthrift::ProtocolReader as _;
1500            let mut field_req = ::std::option::Option::None;
1501            let _ = p.read_struct_begin(|_| ())?;
1502            loop {
1503                let (_, fty, fid) = p.read_field_begin(|_| ())?;
1504                match (fty, fid as ::std::primitive::i32) {
1505                    (::fbthrift::TType::Stop, _) => break,
1506                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1507                    (fty, _) => p.skip(fty)?,
1508                }
1509                p.read_field_end()?;
1510            }
1511            p.read_struct_end()?;
1512            let res = self.service.askForVote(
1513                field_req.ok_or_else(|| {
1514                    ::fbthrift::ApplicationException::missing_arg(
1515                        "askForVote",
1516                        "req",
1517                    )
1518                })?,
1519            ).await;
1520            let res = match res {
1521                ::std::result::Result::Ok(res) => {
1522                    crate::services::raftex_service::AskForVoteExn::Success(res)
1523                }
1524                ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn)) => {
1525                    return ::std::result::Result::Err(aexn.into())
1526                }
1527                ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::Success(_)) => {
1528                    panic!(
1529                        "{} attempted to return success via error",
1530                        "askForVote",
1531                    )
1532                }
1533            };
1534            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1535                p,
1536                "askForVote",
1537                ::fbthrift::MessageType::Reply,
1538                seqid,
1539                |p| ::fbthrift::Serialize::write(&res, p),
1540            ));
1541            ::std::result::Result::Ok(res)
1542        }
1543
1544        async fn handle_appendLog<'a>(
1545            &'a self,
1546            p: &'a mut P::Deserializer,
1547            _req_ctxt: &R,
1548            seqid: ::std::primitive::u32,
1549        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
1550            use ::fbthrift::ProtocolReader as _;
1551            let mut field_req = ::std::option::Option::None;
1552            let _ = p.read_struct_begin(|_| ())?;
1553            loop {
1554                let (_, fty, fid) = p.read_field_begin(|_| ())?;
1555                match (fty, fid as ::std::primitive::i32) {
1556                    (::fbthrift::TType::Stop, _) => break,
1557                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1558                    (fty, _) => p.skip(fty)?,
1559                }
1560                p.read_field_end()?;
1561            }
1562            p.read_struct_end()?;
1563            let res = self.service.appendLog(
1564                field_req.ok_or_else(|| {
1565                    ::fbthrift::ApplicationException::missing_arg(
1566                        "appendLog",
1567                        "req",
1568                    )
1569                })?,
1570            ).await;
1571            let res = match res {
1572                ::std::result::Result::Ok(res) => {
1573                    crate::services::raftex_service::AppendLogExn::Success(res)
1574                }
1575                ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(aexn)) => {
1576                    return ::std::result::Result::Err(aexn.into())
1577                }
1578                ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::Success(_)) => {
1579                    panic!(
1580                        "{} attempted to return success via error",
1581                        "appendLog",
1582                    )
1583                }
1584            };
1585            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1586                p,
1587                "appendLog",
1588                ::fbthrift::MessageType::Reply,
1589                seqid,
1590                |p| ::fbthrift::Serialize::write(&res, p),
1591            ));
1592            ::std::result::Result::Ok(res)
1593        }
1594
1595        async fn handle_sendSnapshot<'a>(
1596            &'a self,
1597            p: &'a mut P::Deserializer,
1598            _req_ctxt: &R,
1599            seqid: ::std::primitive::u32,
1600        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
1601            use ::fbthrift::ProtocolReader as _;
1602            let mut field_req = ::std::option::Option::None;
1603            let _ = p.read_struct_begin(|_| ())?;
1604            loop {
1605                let (_, fty, fid) = p.read_field_begin(|_| ())?;
1606                match (fty, fid as ::std::primitive::i32) {
1607                    (::fbthrift::TType::Stop, _) => break,
1608                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1609                    (fty, _) => p.skip(fty)?,
1610                }
1611                p.read_field_end()?;
1612            }
1613            p.read_struct_end()?;
1614            let res = self.service.sendSnapshot(
1615                field_req.ok_or_else(|| {
1616                    ::fbthrift::ApplicationException::missing_arg(
1617                        "sendSnapshot",
1618                        "req",
1619                    )
1620                })?,
1621            ).await;
1622            let res = match res {
1623                ::std::result::Result::Ok(res) => {
1624                    crate::services::raftex_service::SendSnapshotExn::Success(res)
1625                }
1626                ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn)) => {
1627                    return ::std::result::Result::Err(aexn.into())
1628                }
1629                ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::Success(_)) => {
1630                    panic!(
1631                        "{} attempted to return success via error",
1632                        "sendSnapshot",
1633                    )
1634                }
1635            };
1636            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
1637                p,
1638                "sendSnapshot",
1639                ::fbthrift::MessageType::Reply,
1640                seqid,
1641                |p| ::fbthrift::Serialize::write(&res, p),
1642            ));
1643            ::std::result::Result::Ok(res)
1644        }
1645    }
1646
1647    #[::async_trait::async_trait]
1648    impl<P, H, R> ::fbthrift::ServiceProcessor<P> for RaftexServiceProcessor<P, H, R>
1649    where
1650        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1651        P::Deserializer: ::std::marker::Send,
1652        H: RaftexService,
1653        R: ::std::marker::Send + ::std::marker::Sync + 'static,
1654    {
1655        type RequestContext = R;
1656
1657        #[inline]
1658        fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> {
1659            match name {
1660                b"askForVote" => ::std::result::Result::Ok(0usize),
1661                b"appendLog" => ::std::result::Result::Ok(1usize),
1662                b"sendSnapshot" => ::std::result::Result::Ok(2usize),
1663                _ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()),
1664            }
1665        }
1666
1667        async fn handle_method(
1668            &self,
1669            idx: ::std::primitive::usize,
1670            _p: &mut P::Deserializer,
1671            _r: &R,
1672            _seqid: ::std::primitive::u32,
1673        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
1674            match idx {
1675                0usize => self.handle_askForVote(_p, _r, _seqid).await,
1676                1usize => self.handle_appendLog(_p, _r, _seqid).await,
1677                2usize => self.handle_sendSnapshot(_p, _r, _seqid).await,
1678                bad => panic!(
1679                    "{}: unexpected method idx {}",
1680                    "RaftexServiceProcessor",
1681                    bad
1682                ),
1683            }
1684        }
1685    }
1686
1687    #[::async_trait::async_trait]
1688    impl<P, H, R> ::fbthrift::ThriftService<P::Frame> for RaftexServiceProcessor<P, H, R>
1689    where
1690        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1691        P::Deserializer: ::std::marker::Send,
1692        P::Frame: ::std::marker::Send + 'static,
1693        H: RaftexService,
1694        R: ::std::marker::Send + ::std::marker::Sync + 'static,
1695    {
1696        type Handler = H;
1697        type RequestContext = R;
1698
1699        async fn call(
1700            &self,
1701            req: ::fbthrift::ProtocolDecoded<P>,
1702            req_ctxt: &R,
1703        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
1704            use ::fbthrift::{BufExt as _, ProtocolReader as _, ServiceProcessor as _};
1705            let mut p = P::deserializer(req);
1706            let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?;
1707            if mty != ::fbthrift::MessageType::Call {
1708                return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new(
1709                    ::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType,
1710                    format!("message type {:?} not handled", mty)
1711                )));
1712            }
1713            let idx = match idx {
1714                ::std::result::Result::Ok(idx) => idx,
1715                ::std::result::Result::Err(_) => {
1716                    let cur = P::into_buffer(p).reset();
1717                    return self.supa.call(cur, req_ctxt).await;
1718                }
1719            };
1720            let res = self.handle_method(idx, &mut p, req_ctxt, seqid).await;
1721            p.read_message_end()?;
1722            match res {
1723                ::std::result::Result::Ok(bytes) => ::std::result::Result::Ok(bytes),
1724                ::std::result::Result::Err(err) => match err.downcast_ref::<::fbthrift::ProtocolError>() {
1725                    ::std::option::Option::Some(::fbthrift::ProtocolError::ApplicationException(ae)) => {
1726                        let res = ::fbthrift::serialize!(P, |p| {
1727                            ::fbthrift::protocol::write_message(
1728                                p,
1729                                "RaftexServiceProcessor",
1730                                ::fbthrift::MessageType::Exception,
1731                                seqid,
1732                                |p| ::fbthrift::Serialize::write(&ae, p),
1733                            )
1734                        });
1735                        ::std::result::Result::Ok(res)
1736                    }
1737                    _ => ::std::result::Result::Err(err),
1738                },
1739            }
1740        }
1741    }
1742
1743    pub fn make_RaftexService_server<F, H, R>(
1744        proto: ::fbthrift::ProtocolID,
1745        handler: H,
1746    ) -> ::std::result::Result<::std::boxed::Box<dyn ::fbthrift::ThriftService<F, Handler = H, RequestContext = R> + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException>
1747    where
1748        F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static,
1749        H: RaftexService,
1750        R: ::std::marker::Send + ::std::marker::Sync + 'static,
1751    {
1752        match proto {
1753            ::fbthrift::ProtocolID::BinaryProtocol => {
1754                ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::BinaryProtocol<F>, H, R>::new(handler)))
1755            }
1756            ::fbthrift::ProtocolID::CompactProtocol => {
1757                ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::CompactProtocol<F>, H, R>::new(handler)))
1758            }
1759            bad => ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)),
1760        }
1761    }
1762}
1763
1764/// Client mocks. For every service, a struct mock::TheService that implements
1765/// client::TheService.
1766///
1767/// As an example of the generated API, for the following thrift service:
1768///
1769///     service MyService {
1770///         FunctionResponse myFunction(
1771///             1: FunctionRequest request,
1772///         ) throws {
1773///             1: StorageException s,
1774///             2: NotFoundException n,
1775///         ),
1776///
1777///         // other functions
1778///     }
1779///
1780///
1781/// we would end up with this mock object under crate::mock::MyService:
1782///
1783///     impl crate::client::MyService for MyService<'mock> {...}
1784///
1785///     pub struct MyService<'mock> {
1786///         pub myFunction: myFunction<'mock>,
1787///         // ...
1788///     }
1789///
1790///     impl dyn crate::client::MyService {
1791///         pub fn mock<'mock>() -> MyService<'mock>;
1792///     }
1793///
1794///     impl myFunction<'mock> {
1795///         // directly return the given success response
1796///         pub fn ret(&self, value: FunctionResponse);
1797///
1798///         // invoke closure to compute success response
1799///         pub fn mock(
1800///             &self,
1801///             mock: impl FnMut(FunctionRequest) -> FunctionResponse + Send + Sync + 'mock,
1802///         );
1803///
1804///         // return one of the function's declared exceptions
1805///         pub fn throw<E>(&self, exception: E)
1806///         where
1807///             E: Clone + Into<crate::services::MyService::MyFunctionExn> + Send + Sync + 'mock;
1808///     }
1809///
1810///     impl From<StorageException> for MyFunctionExn {...}
1811///     impl From<NotFoundException> for MyFunctionExn {...}
1812///
1813///
1814/// The intended usage from a test would be:
1815///
1816///     use std::sync::Arc;
1817///     use thrift_if::client::MyService;
1818///
1819///     #[test]
1820///     fn test_my_client() {
1821///         let mock = Arc::new(MyService::mock());
1822///
1823///         // directly return a success response
1824///         let resp = FunctionResponse {...};
1825///         mock.myFunction.ret(resp);
1826///
1827///         // or give a closure to compute the success response
1828///         mock.myFunction.mock(|request| FunctionResponse {...});
1829///
1830///         // or throw one of the function's exceptions
1831///         mock.myFunction.throw(StorageException::ItFailed);
1832///
1833///         let out = do_the_thing(mock).wait().unwrap();
1834///         assert!(out.what_i_expected());
1835///     }
1836///
1837///     fn do_the_thing(
1838///         client: Arc<dyn MyService + Send + Sync + 'static>,
1839///     ) -> impl Future<Item = Out> {...}
1840pub mod mock {
1841    pub struct RaftexService<'mock> {
1842        pub askForVote: r#impl::raftex_service::askForVote<'mock>,
1843        pub appendLog: r#impl::raftex_service::appendLog<'mock>,
1844        pub sendSnapshot: r#impl::raftex_service::sendSnapshot<'mock>,
1845        _marker: ::std::marker::PhantomData<&'mock ()>,
1846    }
1847
1848    impl dyn super::client::RaftexService {
1849        pub fn mock<'mock>() -> RaftexService<'mock> {
1850            RaftexService {
1851                askForVote: r#impl::raftex_service::askForVote::unimplemented(),
1852                appendLog: r#impl::raftex_service::appendLog::unimplemented(),
1853                sendSnapshot: r#impl::raftex_service::sendSnapshot::unimplemented(),
1854                _marker: ::std::marker::PhantomData,
1855            }
1856        }
1857    }
1858
1859    #[::async_trait::async_trait]
1860    impl<'mock> super::client::RaftexService for RaftexService<'mock> {
1861        fn askForVote(
1862            &self,
1863            arg_req: &crate::types::AskForVoteRequest,
1864        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
1865            let mut closure = self.askForVote.closure.lock().unwrap();
1866            let closure: &mut dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> _ = &mut **closure;
1867            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1868        }
1869        fn appendLog(
1870            &self,
1871            arg_req: &crate::types::AppendLogRequest,
1872        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
1873            let mut closure = self.appendLog.closure.lock().unwrap();
1874            let closure: &mut dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> _ = &mut **closure;
1875            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1876        }
1877        fn sendSnapshot(
1878            &self,
1879            arg_req: &crate::types::SendSnapshotRequest,
1880        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
1881            let mut closure = self.sendSnapshot.closure.lock().unwrap();
1882            let closure: &mut dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> _ = &mut **closure;
1883            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1884        }
1885    }
1886
1887    mod r#impl {
1888        pub mod raftex_service {
1889
1890            pub struct askForVote<'mock> {
1891                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1892                    dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<
1893                        crate::types::AskForVoteResponse,
1894                        crate::errors::raftex_service::AskForVoteError,
1895                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1896                >>,
1897            }
1898
1899            impl<'mock> askForVote<'mock> {
1900                pub fn unimplemented() -> Self {
1901                    askForVote {
1902                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AskForVoteRequest| panic!(
1903                            "{}::{} is not mocked",
1904                            "RaftexService",
1905                            "askForVote",
1906                        ))),
1907                    }
1908                }
1909
1910                pub fn ret(&self, value: crate::types::AskForVoteResponse) {
1911                    self.mock(move |_: crate::types::AskForVoteRequest| value.clone());
1912                }
1913
1914                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> crate::types::AskForVoteResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1915                    let mut closure = self.closure.lock().unwrap();
1916                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1917                }
1918
1919                pub fn throw<E>(&self, exception: E)
1920                where
1921                    E: ::std::convert::Into<crate::errors::raftex_service::AskForVoteError>,
1922                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
1923                {
1924                    let mut closure = self.closure.lock().unwrap();
1925                    *closure = ::std::boxed::Box::new(move |_: crate::types::AskForVoteRequest| ::std::result::Result::Err(exception.clone().into()));
1926                }
1927            }
1928
1929            pub struct appendLog<'mock> {
1930                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1931                    dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<
1932                        crate::types::AppendLogResponse,
1933                        crate::errors::raftex_service::AppendLogError,
1934                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1935                >>,
1936            }
1937
1938            impl<'mock> appendLog<'mock> {
1939                pub fn unimplemented() -> Self {
1940                    appendLog {
1941                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AppendLogRequest| panic!(
1942                            "{}::{} is not mocked",
1943                            "RaftexService",
1944                            "appendLog",
1945                        ))),
1946                    }
1947                }
1948
1949                pub fn ret(&self, value: crate::types::AppendLogResponse) {
1950                    self.mock(move |_: crate::types::AppendLogRequest| value.clone());
1951                }
1952
1953                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> crate::types::AppendLogResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1954                    let mut closure = self.closure.lock().unwrap();
1955                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1956                }
1957
1958                pub fn throw<E>(&self, exception: E)
1959                where
1960                    E: ::std::convert::Into<crate::errors::raftex_service::AppendLogError>,
1961                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
1962                {
1963                    let mut closure = self.closure.lock().unwrap();
1964                    *closure = ::std::boxed::Box::new(move |_: crate::types::AppendLogRequest| ::std::result::Result::Err(exception.clone().into()));
1965                }
1966            }
1967
1968            pub struct sendSnapshot<'mock> {
1969                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1970                    dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<
1971                        crate::types::SendSnapshotResponse,
1972                        crate::errors::raftex_service::SendSnapshotError,
1973                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1974                >>,
1975            }
1976
1977            impl<'mock> sendSnapshot<'mock> {
1978                pub fn unimplemented() -> Self {
1979                    sendSnapshot {
1980                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::SendSnapshotRequest| panic!(
1981                            "{}::{} is not mocked",
1982                            "RaftexService",
1983                            "sendSnapshot",
1984                        ))),
1985                    }
1986                }
1987
1988                pub fn ret(&self, value: crate::types::SendSnapshotResponse) {
1989                    self.mock(move |_: crate::types::SendSnapshotRequest| value.clone());
1990                }
1991
1992                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> crate::types::SendSnapshotResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1993                    let mut closure = self.closure.lock().unwrap();
1994                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1995                }
1996
1997                pub fn throw<E>(&self, exception: E)
1998                where
1999                    E: ::std::convert::Into<crate::errors::raftex_service::SendSnapshotError>,
2000                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2001                {
2002                    let mut closure = self.closure.lock().unwrap();
2003                    *closure = ::std::boxed::Box::new(move |_: crate::types::SendSnapshotRequest| ::std::result::Result::Err(exception.clone().into()));
2004                }
2005            }
2006        }
2007    }
2008}
2009
2010pub mod errors {
2011    pub mod raftex_service {
2012
2013        pub type AskForVoteError = ::fbthrift::NonthrowingFunctionError;
2014
2015        pub type AppendLogError = ::fbthrift::NonthrowingFunctionError;
2016
2017        pub type SendSnapshotError = ::fbthrift::NonthrowingFunctionError;
2018
2019    }
2020
2021}