1#![recursion_limit = "100000000"]
5#![allow(bare_trait_objects)]
6#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies, clippy::all)]
7
8pub use self::errors::*;
9pub use self::types::*;
10
11pub mod types;
12
13#[doc(hidden)]
14pub mod dependencies {
15 pub use common as common;
16}
17
18pub mod services {
19 pub mod raftex_service {
20 #[derive(Clone, Debug)]
21 pub enum AskForVoteExn {
22 #[doc(hidden)]
23 Success(crate::types::AskForVoteResponse),
24 ApplicationException(::fbthrift::ApplicationException),
25 }
26
27 impl ::std::convert::From<crate::errors::raftex_service::AskForVoteError> for AskForVoteExn {
28 fn from(err: crate::errors::raftex_service::AskForVoteError) -> Self {
29 match err {
30 crate::errors::raftex_service::AskForVoteError::ApplicationException(aexn) => AskForVoteExn::ApplicationException(aexn),
31 crate::errors::raftex_service::AskForVoteError::ThriftError(err) => AskForVoteExn::ApplicationException(::fbthrift::ApplicationException {
32 message: err.to_string(),
33 type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
34 }),
35 }
36 }
37 }
38
39 impl ::std::convert::From<::fbthrift::ApplicationException> for AskForVoteExn {
40 fn from(exn: ::fbthrift::ApplicationException) -> Self {
41 Self::ApplicationException(exn)
42 }
43 }
44
45 impl ::fbthrift::ExceptionInfo for AskForVoteExn {
46 fn exn_name(&self) -> &'static str {
47 match self {
48 Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
49 Self::ApplicationException(aexn) => aexn.exn_name(),
50 }
51 }
52
53 fn exn_value(&self) -> String {
54 match self {
55 Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
56 Self::ApplicationException(aexn) => aexn.exn_value(),
57 }
58 }
59
60 fn exn_is_declared(&self) -> bool {
61 match self {
62 Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
63 Self::ApplicationException(aexn) => aexn.exn_is_declared(),
64 }
65 }
66 }
67
68 impl ::fbthrift::ResultInfo for AskForVoteExn {
69 fn result_type(&self) -> ::fbthrift::ResultType {
70 match self {
71 Self::Success(_) => ::fbthrift::ResultType::Return,
72 Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
73 }
74 }
75 }
76
77 impl ::fbthrift::GetTType for AskForVoteExn {
78 const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
79 }
80
81 impl<P> ::fbthrift::Serialize<P> for AskForVoteExn
82 where
83 P: ::fbthrift::ProtocolWriter,
84 {
85 fn write(&self, p: &mut P) {
86 if let Self::ApplicationException(aexn) = self {
87 return aexn.write(p);
88 }
89 p.write_struct_begin("AskForVote");
90 match self {
91 Self::Success(inner) => {
92 p.write_field_begin(
93 "Success",
94 ::fbthrift::TType::Struct,
95 0i16,
96 );
97 inner.write(p);
98 p.write_field_end();
99 }
100 Self::ApplicationException(_aexn) => unreachable!(),
101 }
102 p.write_field_stop();
103 p.write_struct_end();
104 }
105 }
106
107 impl<P> ::fbthrift::Deserialize<P> for AskForVoteExn
108 where
109 P: ::fbthrift::ProtocolReader,
110 {
111 fn read(p: &mut P) -> ::anyhow::Result<Self> {
112 static RETURNS: &[::fbthrift::Field] = &[
113 ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
114 ];
115 let _ = p.read_struct_begin(|_| ())?;
116 let mut once = false;
117 let mut alt = ::std::option::Option::None;
118 loop {
119 let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
120 match ((fty, fid as ::std::primitive::i32), once) {
121 ((::fbthrift::TType::Stop, _), _) => {
122 p.read_field_end()?;
123 break;
124 }
125 ((::fbthrift::TType::Struct, 0i32), false) => {
126 once = true;
127 alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
128 }
129 ((ty, _id), false) => p.skip(ty)?,
130 ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
131 ::fbthrift::ApplicationException::new(
132 ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
133 format!(
134 "unwanted extra union {} field ty {:?} id {}",
135 "AskForVoteExn",
136 badty,
137 badid,
138 ),
139 )
140 )),
141 }
142 p.read_field_end()?;
143 }
144 p.read_struct_end()?;
145 alt.ok_or_else(||
146 ::fbthrift::ApplicationException::new(
147 ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
148 format!("Empty union {}", "AskForVoteExn"),
149 )
150 .into(),
151 )
152 }
153 }
154
155 #[derive(Clone, Debug)]
156 pub enum AppendLogExn {
157 #[doc(hidden)]
158 Success(crate::types::AppendLogResponse),
159 ApplicationException(::fbthrift::ApplicationException),
160 }
161
162 impl ::std::convert::From<crate::errors::raftex_service::AppendLogError> for AppendLogExn {
163 fn from(err: crate::errors::raftex_service::AppendLogError) -> Self {
164 match err {
165 crate::errors::raftex_service::AppendLogError::ApplicationException(aexn) => AppendLogExn::ApplicationException(aexn),
166 crate::errors::raftex_service::AppendLogError::ThriftError(err) => AppendLogExn::ApplicationException(::fbthrift::ApplicationException {
167 message: err.to_string(),
168 type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
169 }),
170 }
171 }
172 }
173
174 impl ::std::convert::From<::fbthrift::ApplicationException> for AppendLogExn {
175 fn from(exn: ::fbthrift::ApplicationException) -> Self {
176 Self::ApplicationException(exn)
177 }
178 }
179
180 impl ::fbthrift::ExceptionInfo for AppendLogExn {
181 fn exn_name(&self) -> &'static str {
182 match self {
183 Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
184 Self::ApplicationException(aexn) => aexn.exn_name(),
185 }
186 }
187
188 fn exn_value(&self) -> String {
189 match self {
190 Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
191 Self::ApplicationException(aexn) => aexn.exn_value(),
192 }
193 }
194
195 fn exn_is_declared(&self) -> bool {
196 match self {
197 Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
198 Self::ApplicationException(aexn) => aexn.exn_is_declared(),
199 }
200 }
201 }
202
203 impl ::fbthrift::ResultInfo for AppendLogExn {
204 fn result_type(&self) -> ::fbthrift::ResultType {
205 match self {
206 Self::Success(_) => ::fbthrift::ResultType::Return,
207 Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
208 }
209 }
210 }
211
212 impl ::fbthrift::GetTType for AppendLogExn {
213 const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
214 }
215
216 impl<P> ::fbthrift::Serialize<P> for AppendLogExn
217 where
218 P: ::fbthrift::ProtocolWriter,
219 {
220 fn write(&self, p: &mut P) {
221 if let Self::ApplicationException(aexn) = self {
222 return aexn.write(p);
223 }
224 p.write_struct_begin("AppendLog");
225 match self {
226 Self::Success(inner) => {
227 p.write_field_begin(
228 "Success",
229 ::fbthrift::TType::Struct,
230 0i16,
231 );
232 inner.write(p);
233 p.write_field_end();
234 }
235 Self::ApplicationException(_aexn) => unreachable!(),
236 }
237 p.write_field_stop();
238 p.write_struct_end();
239 }
240 }
241
242 impl<P> ::fbthrift::Deserialize<P> for AppendLogExn
243 where
244 P: ::fbthrift::ProtocolReader,
245 {
246 fn read(p: &mut P) -> ::anyhow::Result<Self> {
247 static RETURNS: &[::fbthrift::Field] = &[
248 ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
249 ];
250 let _ = p.read_struct_begin(|_| ())?;
251 let mut once = false;
252 let mut alt = ::std::option::Option::None;
253 loop {
254 let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
255 match ((fty, fid as ::std::primitive::i32), once) {
256 ((::fbthrift::TType::Stop, _), _) => {
257 p.read_field_end()?;
258 break;
259 }
260 ((::fbthrift::TType::Struct, 0i32), false) => {
261 once = true;
262 alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
263 }
264 ((ty, _id), false) => p.skip(ty)?,
265 ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
266 ::fbthrift::ApplicationException::new(
267 ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
268 format!(
269 "unwanted extra union {} field ty {:?} id {}",
270 "AppendLogExn",
271 badty,
272 badid,
273 ),
274 )
275 )),
276 }
277 p.read_field_end()?;
278 }
279 p.read_struct_end()?;
280 alt.ok_or_else(||
281 ::fbthrift::ApplicationException::new(
282 ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
283 format!("Empty union {}", "AppendLogExn"),
284 )
285 .into(),
286 )
287 }
288 }
289
290 #[derive(Clone, Debug)]
291 pub enum SendSnapshotExn {
292 #[doc(hidden)]
293 Success(crate::types::SendSnapshotResponse),
294 ApplicationException(::fbthrift::ApplicationException),
295 }
296
297 impl ::std::convert::From<crate::errors::raftex_service::SendSnapshotError> for SendSnapshotExn {
298 fn from(err: crate::errors::raftex_service::SendSnapshotError) -> Self {
299 match err {
300 crate::errors::raftex_service::SendSnapshotError::ApplicationException(aexn) => SendSnapshotExn::ApplicationException(aexn),
301 crate::errors::raftex_service::SendSnapshotError::ThriftError(err) => SendSnapshotExn::ApplicationException(::fbthrift::ApplicationException {
302 message: err.to_string(),
303 type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
304 }),
305 }
306 }
307 }
308
309 impl ::std::convert::From<::fbthrift::ApplicationException> for SendSnapshotExn {
310 fn from(exn: ::fbthrift::ApplicationException) -> Self {
311 Self::ApplicationException(exn)
312 }
313 }
314
315 impl ::fbthrift::ExceptionInfo for SendSnapshotExn {
316 fn exn_name(&self) -> &'static str {
317 match self {
318 Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
319 Self::ApplicationException(aexn) => aexn.exn_name(),
320 }
321 }
322
323 fn exn_value(&self) -> String {
324 match self {
325 Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
326 Self::ApplicationException(aexn) => aexn.exn_value(),
327 }
328 }
329
330 fn exn_is_declared(&self) -> bool {
331 match self {
332 Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
333 Self::ApplicationException(aexn) => aexn.exn_is_declared(),
334 }
335 }
336 }
337
338 impl ::fbthrift::ResultInfo for SendSnapshotExn {
339 fn result_type(&self) -> ::fbthrift::ResultType {
340 match self {
341 Self::Success(_) => ::fbthrift::ResultType::Return,
342 Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
343 }
344 }
345 }
346
347 impl ::fbthrift::GetTType for SendSnapshotExn {
348 const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
349 }
350
351 impl<P> ::fbthrift::Serialize<P> for SendSnapshotExn
352 where
353 P: ::fbthrift::ProtocolWriter,
354 {
355 fn write(&self, p: &mut P) {
356 if let Self::ApplicationException(aexn) = self {
357 return aexn.write(p);
358 }
359 p.write_struct_begin("SendSnapshot");
360 match self {
361 Self::Success(inner) => {
362 p.write_field_begin(
363 "Success",
364 ::fbthrift::TType::Struct,
365 0i16,
366 );
367 inner.write(p);
368 p.write_field_end();
369 }
370 Self::ApplicationException(_aexn) => unreachable!(),
371 }
372 p.write_field_stop();
373 p.write_struct_end();
374 }
375 }
376
377 impl<P> ::fbthrift::Deserialize<P> for SendSnapshotExn
378 where
379 P: ::fbthrift::ProtocolReader,
380 {
381 fn read(p: &mut P) -> ::anyhow::Result<Self> {
382 static RETURNS: &[::fbthrift::Field] = &[
383 ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
384 ];
385 let _ = p.read_struct_begin(|_| ())?;
386 let mut once = false;
387 let mut alt = ::std::option::Option::None;
388 loop {
389 let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
390 match ((fty, fid as ::std::primitive::i32), once) {
391 ((::fbthrift::TType::Stop, _), _) => {
392 p.read_field_end()?;
393 break;
394 }
395 ((::fbthrift::TType::Struct, 0i32), false) => {
396 once = true;
397 alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
398 }
399 ((ty, _id), false) => p.skip(ty)?,
400 ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
401 ::fbthrift::ApplicationException::new(
402 ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
403 format!(
404 "unwanted extra union {} field ty {:?} id {}",
405 "SendSnapshotExn",
406 badty,
407 badid,
408 ),
409 )
410 )),
411 }
412 p.read_field_end()?;
413 }
414 p.read_struct_end()?;
415 alt.ok_or_else(||
416 ::fbthrift::ApplicationException::new(
417 ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
418 format!("Empty union {}", "SendSnapshotExn"),
419 )
420 .into(),
421 )
422 }
423 }
424
425 #[derive(Clone, Debug)]
426 pub enum HeartbeatExn {
427 #[doc(hidden)]
428 Success(crate::types::HeartbeatResponse),
429 ApplicationException(::fbthrift::ApplicationException),
430 }
431
432 impl ::std::convert::From<crate::errors::raftex_service::HeartbeatError> for HeartbeatExn {
433 fn from(err: crate::errors::raftex_service::HeartbeatError) -> Self {
434 match err {
435 crate::errors::raftex_service::HeartbeatError::ApplicationException(aexn) => HeartbeatExn::ApplicationException(aexn),
436 crate::errors::raftex_service::HeartbeatError::ThriftError(err) => HeartbeatExn::ApplicationException(::fbthrift::ApplicationException {
437 message: err.to_string(),
438 type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
439 }),
440 }
441 }
442 }
443
444 impl ::std::convert::From<::fbthrift::ApplicationException> for HeartbeatExn {
445 fn from(exn: ::fbthrift::ApplicationException) -> Self {
446 Self::ApplicationException(exn)
447 }
448 }
449
450 impl ::fbthrift::ExceptionInfo for HeartbeatExn {
451 fn exn_name(&self) -> &'static str {
452 match self {
453 Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
454 Self::ApplicationException(aexn) => aexn.exn_name(),
455 }
456 }
457
458 fn exn_value(&self) -> String {
459 match self {
460 Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
461 Self::ApplicationException(aexn) => aexn.exn_value(),
462 }
463 }
464
465 fn exn_is_declared(&self) -> bool {
466 match self {
467 Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
468 Self::ApplicationException(aexn) => aexn.exn_is_declared(),
469 }
470 }
471 }
472
473 impl ::fbthrift::ResultInfo for HeartbeatExn {
474 fn result_type(&self) -> ::fbthrift::ResultType {
475 match self {
476 Self::Success(_) => ::fbthrift::ResultType::Return,
477 Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
478 }
479 }
480 }
481
482 impl ::fbthrift::GetTType for HeartbeatExn {
483 const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
484 }
485
486 impl<P> ::fbthrift::Serialize<P> for HeartbeatExn
487 where
488 P: ::fbthrift::ProtocolWriter,
489 {
490 fn write(&self, p: &mut P) {
491 if let Self::ApplicationException(aexn) = self {
492 return aexn.write(p);
493 }
494 p.write_struct_begin("Heartbeat");
495 match self {
496 Self::Success(inner) => {
497 p.write_field_begin(
498 "Success",
499 ::fbthrift::TType::Struct,
500 0i16,
501 );
502 inner.write(p);
503 p.write_field_end();
504 }
505 Self::ApplicationException(_aexn) => unreachable!(),
506 }
507 p.write_field_stop();
508 p.write_struct_end();
509 }
510 }
511
512 impl<P> ::fbthrift::Deserialize<P> for HeartbeatExn
513 where
514 P: ::fbthrift::ProtocolReader,
515 {
516 fn read(p: &mut P) -> ::anyhow::Result<Self> {
517 static RETURNS: &[::fbthrift::Field] = &[
518 ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
519 ];
520 let _ = p.read_struct_begin(|_| ())?;
521 let mut once = false;
522 let mut alt = ::std::option::Option::None;
523 loop {
524 let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
525 match ((fty, fid as ::std::primitive::i32), once) {
526 ((::fbthrift::TType::Stop, _), _) => {
527 p.read_field_end()?;
528 break;
529 }
530 ((::fbthrift::TType::Struct, 0i32), false) => {
531 once = true;
532 alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
533 }
534 ((ty, _id), false) => p.skip(ty)?,
535 ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
536 ::fbthrift::ApplicationException::new(
537 ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
538 format!(
539 "unwanted extra union {} field ty {:?} id {}",
540 "HeartbeatExn",
541 badty,
542 badid,
543 ),
544 )
545 )),
546 }
547 p.read_field_end()?;
548 }
549 p.read_struct_end()?;
550 alt.ok_or_else(||
551 ::fbthrift::ApplicationException::new(
552 ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
553 format!("Empty union {}", "HeartbeatExn"),
554 )
555 .into(),
556 )
557 }
558 }
559
560 #[derive(Clone, Debug)]
561 pub enum GetStateExn {
562 #[doc(hidden)]
563 Success(crate::types::GetStateResponse),
564 ApplicationException(::fbthrift::ApplicationException),
565 }
566
567 impl ::std::convert::From<crate::errors::raftex_service::GetStateError> for GetStateExn {
568 fn from(err: crate::errors::raftex_service::GetStateError) -> Self {
569 match err {
570 crate::errors::raftex_service::GetStateError::ApplicationException(aexn) => GetStateExn::ApplicationException(aexn),
571 crate::errors::raftex_service::GetStateError::ThriftError(err) => GetStateExn::ApplicationException(::fbthrift::ApplicationException {
572 message: err.to_string(),
573 type_: ::fbthrift::ApplicationExceptionErrorCode::InternalError,
574 }),
575 }
576 }
577 }
578
579 impl ::std::convert::From<::fbthrift::ApplicationException> for GetStateExn {
580 fn from(exn: ::fbthrift::ApplicationException) -> Self {
581 Self::ApplicationException(exn)
582 }
583 }
584
585 impl ::fbthrift::ExceptionInfo for GetStateExn {
586 fn exn_name(&self) -> &'static str {
587 match self {
588 Self::Success(_) => panic!("ExceptionInfo::exn_name called on Success"),
589 Self::ApplicationException(aexn) => aexn.exn_name(),
590 }
591 }
592
593 fn exn_value(&self) -> String {
594 match self {
595 Self::Success(_) => panic!("ExceptionInfo::exn_value called on Success"),
596 Self::ApplicationException(aexn) => aexn.exn_value(),
597 }
598 }
599
600 fn exn_is_declared(&self) -> bool {
601 match self {
602 Self::Success(_) => panic!("ExceptionInfo::exn_is_declared called on Success"),
603 Self::ApplicationException(aexn) => aexn.exn_is_declared(),
604 }
605 }
606 }
607
608 impl ::fbthrift::ResultInfo for GetStateExn {
609 fn result_type(&self) -> ::fbthrift::ResultType {
610 match self {
611 Self::Success(_) => ::fbthrift::ResultType::Return,
612 Self::ApplicationException(_aexn) => ::fbthrift::ResultType::Exception,
613 }
614 }
615 }
616
617 impl ::fbthrift::GetTType for GetStateExn {
618 const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
619 }
620
621 impl<P> ::fbthrift::Serialize<P> for GetStateExn
622 where
623 P: ::fbthrift::ProtocolWriter,
624 {
625 fn write(&self, p: &mut P) {
626 if let Self::ApplicationException(aexn) = self {
627 return aexn.write(p);
628 }
629 p.write_struct_begin("GetState");
630 match self {
631 Self::Success(inner) => {
632 p.write_field_begin(
633 "Success",
634 ::fbthrift::TType::Struct,
635 0i16,
636 );
637 inner.write(p);
638 p.write_field_end();
639 }
640 Self::ApplicationException(_aexn) => unreachable!(),
641 }
642 p.write_field_stop();
643 p.write_struct_end();
644 }
645 }
646
647 impl<P> ::fbthrift::Deserialize<P> for GetStateExn
648 where
649 P: ::fbthrift::ProtocolReader,
650 {
651 fn read(p: &mut P) -> ::anyhow::Result<Self> {
652 static RETURNS: &[::fbthrift::Field] = &[
653 ::fbthrift::Field::new("Success", ::fbthrift::TType::Struct, 0),
654 ];
655 let _ = p.read_struct_begin(|_| ())?;
656 let mut once = false;
657 let mut alt = ::std::option::Option::None;
658 loop {
659 let (_, fty, fid) = p.read_field_begin(|_| (), RETURNS)?;
660 match ((fty, fid as ::std::primitive::i32), once) {
661 ((::fbthrift::TType::Stop, _), _) => {
662 p.read_field_end()?;
663 break;
664 }
665 ((::fbthrift::TType::Struct, 0i32), false) => {
666 once = true;
667 alt = ::std::option::Option::Some(Self::Success(::fbthrift::Deserialize::read(p)?));
668 }
669 ((ty, _id), false) => p.skip(ty)?,
670 ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
671 ::fbthrift::ApplicationException::new(
672 ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
673 format!(
674 "unwanted extra union {} field ty {:?} id {}",
675 "GetStateExn",
676 badty,
677 badid,
678 ),
679 )
680 )),
681 }
682 p.read_field_end()?;
683 }
684 p.read_struct_end()?;
685 alt.ok_or_else(||
686 ::fbthrift::ApplicationException::new(
687 ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
688 format!("Empty union {}", "GetStateExn"),
689 )
690 .into(),
691 )
692 }
693 }
694 }
695}
696
697pub mod client {
699
700 pub struct RaftexServiceImpl<P, T, S = ::fbthrift::NoopSpawner> {
701 transport: T,
702 _phantom: ::std::marker::PhantomData<fn() -> (P, S)>,
703 }
704
705 impl<P, T, S> RaftexServiceImpl<P, T, S>
706 where
707 P: ::fbthrift::Protocol,
708 T: ::fbthrift::Transport,
709 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
710 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
711 P::Deserializer: ::std::marker::Send,
712 S: ::fbthrift::help::Spawner,
713 {
714 pub fn new(
715 transport: T,
716 ) -> Self {
717 Self {
718 transport,
719 _phantom: ::std::marker::PhantomData,
720 }
721 }
722
723 pub fn transport(&self) -> &T {
724 &self.transport
725 }
726
727
728 fn _askForVote_impl(
729 &self,
730 arg_req: &crate::types::AskForVoteRequest,
731 rpc_options: T::RpcOptions,
732 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
733 use ::const_cstr::const_cstr;
734 use ::tracing::Instrument as _;
735 use ::futures::FutureExt as _;
736
737 const_cstr! {
738 SERVICE_NAME = "RaftexService";
739 METHOD_NAME = "RaftexService.askForVote";
740 }
741 let args = self::Args_RaftexService_askForVote {
742 req: arg_req,
743 _phantom: ::std::marker::PhantomData,
744 };
745
746 let transport = self.transport();
747
748 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("askForVote", &args) {
750 ::std::result::Result::Ok(res) => res,
751 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
752 };
753
754 let call = transport
755 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
756 .instrument(::tracing::trace_span!("call", function = "RaftexService.askForVote"));
757
758 async move {
759 let reply_env = call.await?;
760
761 let de = P::deserializer(reply_env);
762 let (res, _de): (::std::result::Result<crate::services::raftex_service::AskForVoteExn, _>, _) =
763 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
764
765 let res = match res {
766 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
767 ::std::result::Result::Err(aexn) =>
768 ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(aexn))
769 };
770 res
771 }
772 .instrument(::tracing::info_span!("RaftexService.askForVote"))
773 .boxed()
774 }
775
776 fn _appendLog_impl(
777 &self,
778 arg_req: &crate::types::AppendLogRequest,
779 rpc_options: T::RpcOptions,
780 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
781 use ::const_cstr::const_cstr;
782 use ::tracing::Instrument as _;
783 use ::futures::FutureExt as _;
784
785 const_cstr! {
786 SERVICE_NAME = "RaftexService";
787 METHOD_NAME = "RaftexService.appendLog";
788 }
789 let args = self::Args_RaftexService_appendLog {
790 req: arg_req,
791 _phantom: ::std::marker::PhantomData,
792 };
793
794 let transport = self.transport();
795
796 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("appendLog", &args) {
798 ::std::result::Result::Ok(res) => res,
799 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
800 };
801
802 let call = transport
803 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
804 .instrument(::tracing::trace_span!("call", function = "RaftexService.appendLog"));
805
806 async move {
807 let reply_env = call.await?;
808
809 let de = P::deserializer(reply_env);
810 let (res, _de): (::std::result::Result<crate::services::raftex_service::AppendLogExn, _>, _) =
811 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
812
813 let res = match res {
814 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
815 ::std::result::Result::Err(aexn) =>
816 ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(aexn))
817 };
818 res
819 }
820 .instrument(::tracing::info_span!("RaftexService.appendLog"))
821 .boxed()
822 }
823
824 fn _sendSnapshot_impl(
825 &self,
826 arg_req: &crate::types::SendSnapshotRequest,
827 rpc_options: T::RpcOptions,
828 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
829 use ::const_cstr::const_cstr;
830 use ::tracing::Instrument as _;
831 use ::futures::FutureExt as _;
832
833 const_cstr! {
834 SERVICE_NAME = "RaftexService";
835 METHOD_NAME = "RaftexService.sendSnapshot";
836 }
837 let args = self::Args_RaftexService_sendSnapshot {
838 req: arg_req,
839 _phantom: ::std::marker::PhantomData,
840 };
841
842 let transport = self.transport();
843
844 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("sendSnapshot", &args) {
846 ::std::result::Result::Ok(res) => res,
847 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
848 };
849
850 let call = transport
851 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
852 .instrument(::tracing::trace_span!("call", function = "RaftexService.sendSnapshot"));
853
854 async move {
855 let reply_env = call.await?;
856
857 let de = P::deserializer(reply_env);
858 let (res, _de): (::std::result::Result<crate::services::raftex_service::SendSnapshotExn, _>, _) =
859 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
860
861 let res = match res {
862 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
863 ::std::result::Result::Err(aexn) =>
864 ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(aexn))
865 };
866 res
867 }
868 .instrument(::tracing::info_span!("RaftexService.sendSnapshot"))
869 .boxed()
870 }
871
872 fn _heartbeat_impl(
873 &self,
874 arg_req: &crate::types::HeartbeatRequest,
875 rpc_options: T::RpcOptions,
876 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
877 use ::const_cstr::const_cstr;
878 use ::tracing::Instrument as _;
879 use ::futures::FutureExt as _;
880
881 const_cstr! {
882 SERVICE_NAME = "RaftexService";
883 METHOD_NAME = "RaftexService.heartbeat";
884 }
885 let args = self::Args_RaftexService_heartbeat {
886 req: arg_req,
887 _phantom: ::std::marker::PhantomData,
888 };
889
890 let transport = self.transport();
891
892 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("heartbeat", &args) {
894 ::std::result::Result::Ok(res) => res,
895 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
896 };
897
898 let call = transport
899 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
900 .instrument(::tracing::trace_span!("call", function = "RaftexService.heartbeat"));
901
902 async move {
903 let reply_env = call.await?;
904
905 let de = P::deserializer(reply_env);
906 let (res, _de): (::std::result::Result<crate::services::raftex_service::HeartbeatExn, _>, _) =
907 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
908
909 let res = match res {
910 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
911 ::std::result::Result::Err(aexn) =>
912 ::std::result::Result::Err(crate::errors::raftex_service::HeartbeatError::ApplicationException(aexn))
913 };
914 res
915 }
916 .instrument(::tracing::info_span!("RaftexService.heartbeat"))
917 .boxed()
918 }
919
920 fn _getState_impl(
921 &self,
922 arg_req: &crate::types::GetStateRequest,
923 rpc_options: T::RpcOptions,
924 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
925 use ::const_cstr::const_cstr;
926 use ::tracing::Instrument as _;
927 use ::futures::FutureExt as _;
928
929 const_cstr! {
930 SERVICE_NAME = "RaftexService";
931 METHOD_NAME = "RaftexService.getState";
932 }
933 let args = self::Args_RaftexService_getState {
934 req: arg_req,
935 _phantom: ::std::marker::PhantomData,
936 };
937
938 let transport = self.transport();
939
940 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("getState", &args) {
942 ::std::result::Result::Ok(res) => res,
943 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
944 };
945
946 let call = transport
947 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
948 .instrument(::tracing::trace_span!("call", function = "RaftexService.getState"));
949
950 async move {
951 let reply_env = call.await?;
952
953 let de = P::deserializer(reply_env);
954 let (res, _de): (::std::result::Result<crate::services::raftex_service::GetStateExn, _>, _) =
955 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
956
957 let res = match res {
958 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
959 ::std::result::Result::Err(aexn) =>
960 ::std::result::Result::Err(crate::errors::raftex_service::GetStateError::ApplicationException(aexn))
961 };
962 res
963 }
964 .instrument(::tracing::info_span!("RaftexService.getState"))
965 .boxed()
966 }
967 }
968
969 pub trait RaftexService: ::std::marker::Send {
970 fn askForVote(
971 &self,
972 arg_req: &crate::types::AskForVoteRequest,
973 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
974
975 fn appendLog(
976 &self,
977 arg_req: &crate::types::AppendLogRequest,
978 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
979
980 fn sendSnapshot(
981 &self,
982 arg_req: &crate::types::SendSnapshotRequest,
983 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
984
985 fn heartbeat(
986 &self,
987 arg_req: &crate::types::HeartbeatRequest,
988 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>>;
989
990 fn getState(
991 &self,
992 arg_req: &crate::types::GetStateRequest,
993 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>>;
994 }
995
996 pub trait RaftexServiceExt<T>: RaftexService
997 where
998 T: ::fbthrift::Transport,
999 {
1000 fn askForVote_with_rpc_opts(
1001 &self,
1002 arg_req: &crate::types::AskForVoteRequest,
1003 rpc_options: T::RpcOptions,
1004 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
1005 fn appendLog_with_rpc_opts(
1006 &self,
1007 arg_req: &crate::types::AppendLogRequest,
1008 rpc_options: T::RpcOptions,
1009 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
1010 fn sendSnapshot_with_rpc_opts(
1011 &self,
1012 arg_req: &crate::types::SendSnapshotRequest,
1013 rpc_options: T::RpcOptions,
1014 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
1015 fn heartbeat_with_rpc_opts(
1016 &self,
1017 arg_req: &crate::types::HeartbeatRequest,
1018 rpc_options: T::RpcOptions,
1019 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>>;
1020 fn getState_with_rpc_opts(
1021 &self,
1022 arg_req: &crate::types::GetStateRequest,
1023 rpc_options: T::RpcOptions,
1024 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>>;
1025 }
1026
1027 struct Args_RaftexService_askForVote<'a> {
1028 req: &'a crate::types::AskForVoteRequest,
1029 _phantom: ::std::marker::PhantomData<&'a ()>,
1030 }
1031
1032 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_askForVote<'a> {
1033 #[inline]
1034 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.askForVote"))]
1035 fn write(&self, p: &mut P) {
1036 p.write_struct_begin("args");
1037 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
1038 ::fbthrift::Serialize::write(&self.req, p);
1039 p.write_field_end();
1040 p.write_field_stop();
1041 p.write_struct_end();
1042 }
1043 }
1044
1045 struct Args_RaftexService_appendLog<'a> {
1046 req: &'a crate::types::AppendLogRequest,
1047 _phantom: ::std::marker::PhantomData<&'a ()>,
1048 }
1049
1050 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_appendLog<'a> {
1051 #[inline]
1052 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.appendLog"))]
1053 fn write(&self, p: &mut P) {
1054 p.write_struct_begin("args");
1055 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
1056 ::fbthrift::Serialize::write(&self.req, p);
1057 p.write_field_end();
1058 p.write_field_stop();
1059 p.write_struct_end();
1060 }
1061 }
1062
1063 struct Args_RaftexService_sendSnapshot<'a> {
1064 req: &'a crate::types::SendSnapshotRequest,
1065 _phantom: ::std::marker::PhantomData<&'a ()>,
1066 }
1067
1068 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_sendSnapshot<'a> {
1069 #[inline]
1070 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.sendSnapshot"))]
1071 fn write(&self, p: &mut P) {
1072 p.write_struct_begin("args");
1073 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
1074 ::fbthrift::Serialize::write(&self.req, p);
1075 p.write_field_end();
1076 p.write_field_stop();
1077 p.write_struct_end();
1078 }
1079 }
1080
1081 struct Args_RaftexService_heartbeat<'a> {
1082 req: &'a crate::types::HeartbeatRequest,
1083 _phantom: ::std::marker::PhantomData<&'a ()>,
1084 }
1085
1086 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_heartbeat<'a> {
1087 #[inline]
1088 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.heartbeat"))]
1089 fn write(&self, p: &mut P) {
1090 p.write_struct_begin("args");
1091 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
1092 ::fbthrift::Serialize::write(&self.req, p);
1093 p.write_field_end();
1094 p.write_field_stop();
1095 p.write_struct_end();
1096 }
1097 }
1098
1099 struct Args_RaftexService_getState<'a> {
1100 req: &'a crate::types::GetStateRequest,
1101 _phantom: ::std::marker::PhantomData<&'a ()>,
1102 }
1103
1104 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_getState<'a> {
1105 #[inline]
1106 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.getState"))]
1107 fn write(&self, p: &mut P) {
1108 p.write_struct_begin("args");
1109 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
1110 ::fbthrift::Serialize::write(&self.req, p);
1111 p.write_field_end();
1112 p.write_field_stop();
1113 p.write_struct_end();
1114 }
1115 }
1116
1117 impl<P, T, S> RaftexService for RaftexServiceImpl<P, T, S>
1118 where
1119 P: ::fbthrift::Protocol,
1120 T: ::fbthrift::Transport,
1121 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
1122 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
1123 P::Deserializer: ::std::marker::Send,
1124 S: ::fbthrift::help::Spawner,
1125 {
1126 fn askForVote(
1127 &self,
1128 arg_req: &crate::types::AskForVoteRequest,
1129 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
1130 let rpc_options = T::RpcOptions::default();
1131 self._askForVote_impl(
1132 arg_req,
1133 rpc_options,
1134 )
1135 }
1136 fn appendLog(
1137 &self,
1138 arg_req: &crate::types::AppendLogRequest,
1139 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
1140 let rpc_options = T::RpcOptions::default();
1141 self._appendLog_impl(
1142 arg_req,
1143 rpc_options,
1144 )
1145 }
1146 fn sendSnapshot(
1147 &self,
1148 arg_req: &crate::types::SendSnapshotRequest,
1149 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
1150 let rpc_options = T::RpcOptions::default();
1151 self._sendSnapshot_impl(
1152 arg_req,
1153 rpc_options,
1154 )
1155 }
1156 fn heartbeat(
1157 &self,
1158 arg_req: &crate::types::HeartbeatRequest,
1159 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
1160 let rpc_options = T::RpcOptions::default();
1161 self._heartbeat_impl(
1162 arg_req,
1163 rpc_options,
1164 )
1165 }
1166 fn getState(
1167 &self,
1168 arg_req: &crate::types::GetStateRequest,
1169 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
1170 let rpc_options = T::RpcOptions::default();
1171 self._getState_impl(
1172 arg_req,
1173 rpc_options,
1174 )
1175 }
1176 }
1177
1178 impl<P, T, S> RaftexServiceExt<T> for RaftexServiceImpl<P, T, S>
1179 where
1180 P: ::fbthrift::Protocol,
1181 T: ::fbthrift::Transport,
1182 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
1183 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
1184 P::Deserializer: ::std::marker::Send,
1185 S: ::fbthrift::help::Spawner,
1186 {
1187 fn askForVote_with_rpc_opts(
1188 &self,
1189 arg_req: &crate::types::AskForVoteRequest,
1190 rpc_options: T::RpcOptions,
1191 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
1192 self._askForVote_impl(
1193 arg_req,
1194 rpc_options,
1195 )
1196 }
1197 fn appendLog_with_rpc_opts(
1198 &self,
1199 arg_req: &crate::types::AppendLogRequest,
1200 rpc_options: T::RpcOptions,
1201 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
1202 self._appendLog_impl(
1203 arg_req,
1204 rpc_options,
1205 )
1206 }
1207 fn sendSnapshot_with_rpc_opts(
1208 &self,
1209 arg_req: &crate::types::SendSnapshotRequest,
1210 rpc_options: T::RpcOptions,
1211 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
1212 self._sendSnapshot_impl(
1213 arg_req,
1214 rpc_options,
1215 )
1216 }
1217 fn heartbeat_with_rpc_opts(
1218 &self,
1219 arg_req: &crate::types::HeartbeatRequest,
1220 rpc_options: T::RpcOptions,
1221 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
1222 self._heartbeat_impl(
1223 arg_req,
1224 rpc_options,
1225 )
1226 }
1227 fn getState_with_rpc_opts(
1228 &self,
1229 arg_req: &crate::types::GetStateRequest,
1230 rpc_options: T::RpcOptions,
1231 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
1232 self._getState_impl(
1233 arg_req,
1234 rpc_options,
1235 )
1236 }
1237 }
1238
1239 impl<'a, S> RaftexService for S
1240 where
1241 S: ::std::convert::AsRef<dyn RaftexService + 'a>,
1242 S: ::std::marker::Send,
1243 {
1244 fn askForVote(
1245 &self,
1246 arg_req: &crate::types::AskForVoteRequest,
1247 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
1248 self.as_ref().askForVote(
1249 arg_req,
1250 )
1251 }
1252 fn appendLog(
1253 &self,
1254 arg_req: &crate::types::AppendLogRequest,
1255 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
1256 self.as_ref().appendLog(
1257 arg_req,
1258 )
1259 }
1260 fn sendSnapshot(
1261 &self,
1262 arg_req: &crate::types::SendSnapshotRequest,
1263 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
1264 self.as_ref().sendSnapshot(
1265 arg_req,
1266 )
1267 }
1268 fn heartbeat(
1269 &self,
1270 arg_req: &crate::types::HeartbeatRequest,
1271 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
1272 self.as_ref().heartbeat(
1273 arg_req,
1274 )
1275 }
1276 fn getState(
1277 &self,
1278 arg_req: &crate::types::GetStateRequest,
1279 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
1280 self.as_ref().getState(
1281 arg_req,
1282 )
1283 }
1284 }
1285
1286 impl<'a, S, T> RaftexServiceExt<T> for S
1287 where
1288 S: ::std::convert::AsRef<dyn RaftexService + 'a>,
1289 S: ::std::convert::AsRef<dyn RaftexServiceExt<T> + 'a>,
1290 S: ::std::marker::Send,
1291 T: ::fbthrift::Transport,
1292 {
1293 fn askForVote_with_rpc_opts(
1294 &self,
1295 arg_req: &crate::types::AskForVoteRequest,
1296 rpc_options: T::RpcOptions,
1297 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
1298 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).askForVote_with_rpc_opts(
1299 arg_req,
1300 rpc_options,
1301 )
1302 }
1303 fn appendLog_with_rpc_opts(
1304 &self,
1305 arg_req: &crate::types::AppendLogRequest,
1306 rpc_options: T::RpcOptions,
1307 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
1308 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).appendLog_with_rpc_opts(
1309 arg_req,
1310 rpc_options,
1311 )
1312 }
1313 fn sendSnapshot_with_rpc_opts(
1314 &self,
1315 arg_req: &crate::types::SendSnapshotRequest,
1316 rpc_options: T::RpcOptions,
1317 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
1318 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).sendSnapshot_with_rpc_opts(
1319 arg_req,
1320 rpc_options,
1321 )
1322 }
1323 fn heartbeat_with_rpc_opts(
1324 &self,
1325 arg_req: &crate::types::HeartbeatRequest,
1326 rpc_options: T::RpcOptions,
1327 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
1328 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).heartbeat_with_rpc_opts(
1329 arg_req,
1330 rpc_options,
1331 )
1332 }
1333 fn getState_with_rpc_opts(
1334 &self,
1335 arg_req: &crate::types::GetStateRequest,
1336 rpc_options: T::RpcOptions,
1337 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
1338 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).getState_with_rpc_opts(
1339 arg_req,
1340 rpc_options,
1341 )
1342 }
1343 }
1344
1345 #[derive(Clone)]
1346 pub struct make_RaftexService;
1347
1348 impl dyn RaftexService {
1362 pub fn new<P, T>(
1363 protocol: P,
1364 transport: T,
1365 ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
1366 where
1367 P: ::fbthrift::Protocol<Frame = T>,
1368 T: ::fbthrift::Transport,
1369 P::Deserializer: ::std::marker::Send,
1370 {
1371 let spawner = ::fbthrift::help::NoopSpawner;
1372 Self::with_spawner(protocol, transport, spawner)
1373 }
1374
1375 pub fn with_spawner<P, T, S>(
1376 protocol: P,
1377 transport: T,
1378 spawner: S,
1379 ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
1380 where
1381 P: ::fbthrift::Protocol<Frame = T>,
1382 T: ::fbthrift::Transport,
1383 P::Deserializer: ::std::marker::Send,
1384 S: ::fbthrift::help::Spawner,
1385 {
1386 let _ = protocol;
1387 let _ = spawner;
1388 ::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
1389 }
1390 }
1391
1392 impl<T> dyn RaftexServiceExt<T>
1393 where
1394 T: ::fbthrift::Transport,
1395 {
1396 pub fn new<P>(
1397 protocol: P,
1398 transport: T,
1399 ) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
1400 where
1401 P: ::fbthrift::Protocol<Frame = T>,
1402 P::Deserializer: ::std::marker::Send,
1403 {
1404 let spawner = ::fbthrift::help::NoopSpawner;
1405 Self::with_spawner(protocol, transport, spawner)
1406 }
1407
1408 pub fn with_spawner<P, S>(
1409 protocol: P,
1410 transport: T,
1411 spawner: S,
1412 ) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
1413 where
1414 P: ::fbthrift::Protocol<Frame = T>,
1415 P::Deserializer: ::std::marker::Send,
1416 S: ::fbthrift::help::Spawner,
1417 {
1418 let _ = protocol;
1419 let _ = spawner;
1420 ::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
1421 }
1422 }
1423
1424 pub type RaftexServiceDynClient = <make_RaftexService as ::fbthrift::ClientFactory>::Api;
1425 pub type RaftexServiceClient = ::std::sync::Arc<RaftexServiceDynClient>;
1426
1427 impl ::fbthrift::ClientFactory for make_RaftexService {
1430 type Api = dyn RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static;
1431
1432 fn with_spawner<P, T, S>(protocol: P, transport: T, spawner: S) -> ::std::sync::Arc<Self::Api>
1433 where
1434 P: ::fbthrift::Protocol<Frame = T>,
1435 T: ::fbthrift::Transport,
1436 P::Deserializer: ::std::marker::Send,
1437 S: ::fbthrift::help::Spawner,
1438 {
1439 <dyn RaftexService>::with_spawner(protocol, transport, spawner)
1440 }
1441 }
1442
1443}
1444
1445pub mod server {
1447 #[::async_trait::async_trait]
1448 pub trait RaftexService: ::std::marker::Send + ::std::marker::Sync + 'static {
1449 async fn askForVote(
1450 &self,
1451 _req: crate::types::AskForVoteRequest,
1452 ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
1453 ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(
1454 ::fbthrift::ApplicationException::unimplemented_method(
1455 "RaftexService",
1456 "askForVote",
1457 ),
1458 ))
1459 }
1460 async fn appendLog(
1461 &self,
1462 _req: crate::types::AppendLogRequest,
1463 ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
1464 ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(
1465 ::fbthrift::ApplicationException::unimplemented_method(
1466 "RaftexService",
1467 "appendLog",
1468 ),
1469 ))
1470 }
1471 async fn sendSnapshot(
1472 &self,
1473 _req: crate::types::SendSnapshotRequest,
1474 ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
1475 ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(
1476 ::fbthrift::ApplicationException::unimplemented_method(
1477 "RaftexService",
1478 "sendSnapshot",
1479 ),
1480 ))
1481 }
1482 async fn heartbeat(
1483 &self,
1484 _req: crate::types::HeartbeatRequest,
1485 ) -> ::std::result::Result<crate::types::HeartbeatResponse, crate::services::raftex_service::HeartbeatExn> {
1486 ::std::result::Result::Err(crate::services::raftex_service::HeartbeatExn::ApplicationException(
1487 ::fbthrift::ApplicationException::unimplemented_method(
1488 "RaftexService",
1489 "heartbeat",
1490 ),
1491 ))
1492 }
1493 async fn getState(
1494 &self,
1495 _req: crate::types::GetStateRequest,
1496 ) -> ::std::result::Result<crate::types::GetStateResponse, crate::services::raftex_service::GetStateExn> {
1497 ::std::result::Result::Err(crate::services::raftex_service::GetStateExn::ApplicationException(
1498 ::fbthrift::ApplicationException::unimplemented_method(
1499 "RaftexService",
1500 "getState",
1501 ),
1502 ))
1503 }
1504 }
1505
1506 #[::async_trait::async_trait]
1507 impl<T> RaftexService for ::std::boxed::Box<T>
1508 where
1509 T: RaftexService + Send + Sync + ?Sized,
1510 {
1511 async fn askForVote(
1512 &self,
1513 req: crate::types::AskForVoteRequest,
1514 ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
1515 (**self).askForVote(
1516 req,
1517 ).await
1518 }
1519 async fn appendLog(
1520 &self,
1521 req: crate::types::AppendLogRequest,
1522 ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
1523 (**self).appendLog(
1524 req,
1525 ).await
1526 }
1527 async fn sendSnapshot(
1528 &self,
1529 req: crate::types::SendSnapshotRequest,
1530 ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
1531 (**self).sendSnapshot(
1532 req,
1533 ).await
1534 }
1535 async fn heartbeat(
1536 &self,
1537 req: crate::types::HeartbeatRequest,
1538 ) -> ::std::result::Result<crate::types::HeartbeatResponse, crate::services::raftex_service::HeartbeatExn> {
1539 (**self).heartbeat(
1540 req,
1541 ).await
1542 }
1543 async fn getState(
1544 &self,
1545 req: crate::types::GetStateRequest,
1546 ) -> ::std::result::Result<crate::types::GetStateResponse, crate::services::raftex_service::GetStateExn> {
1547 (**self).getState(
1548 req,
1549 ).await
1550 }
1551 }
1552
1553 #[derive(Clone, Debug)]
1555 pub struct RaftexServiceProcessor<P, H, R, RS> {
1556 service: H,
1557 supa: ::fbthrift::NullServiceProcessor<P, R, RS>,
1558 _phantom: ::std::marker::PhantomData<(P, H, R, RS)>,
1559 }
1560
1561 struct Args_RaftexService_askForVote {
1562 req: crate::types::AskForVoteRequest,
1563 }
1564 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_askForVote {
1565 #[inline]
1566 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.askForVote"))]
1567 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1568 static ARGS: &[::fbthrift::Field] = &[
1569 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1570 ];
1571 let mut field_req = ::std::option::Option::None;
1572 let _ = p.read_struct_begin(|_| ())?;
1573 loop {
1574 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1575 match (fty, fid as ::std::primitive::i32) {
1576 (::fbthrift::TType::Stop, _) => break,
1577 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1578 (fty, _) => p.skip(fty)?,
1579 }
1580 p.read_field_end()?;
1581 }
1582 p.read_struct_end()?;
1583 ::std::result::Result::Ok(Self {
1584 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.askForVote", "req"))?,
1585 })
1586 }
1587 }
1588
1589 struct Args_RaftexService_appendLog {
1590 req: crate::types::AppendLogRequest,
1591 }
1592 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_appendLog {
1593 #[inline]
1594 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.appendLog"))]
1595 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1596 static ARGS: &[::fbthrift::Field] = &[
1597 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1598 ];
1599 let mut field_req = ::std::option::Option::None;
1600 let _ = p.read_struct_begin(|_| ())?;
1601 loop {
1602 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1603 match (fty, fid as ::std::primitive::i32) {
1604 (::fbthrift::TType::Stop, _) => break,
1605 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1606 (fty, _) => p.skip(fty)?,
1607 }
1608 p.read_field_end()?;
1609 }
1610 p.read_struct_end()?;
1611 ::std::result::Result::Ok(Self {
1612 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.appendLog", "req"))?,
1613 })
1614 }
1615 }
1616
1617 struct Args_RaftexService_sendSnapshot {
1618 req: crate::types::SendSnapshotRequest,
1619 }
1620 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_sendSnapshot {
1621 #[inline]
1622 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.sendSnapshot"))]
1623 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1624 static ARGS: &[::fbthrift::Field] = &[
1625 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1626 ];
1627 let mut field_req = ::std::option::Option::None;
1628 let _ = p.read_struct_begin(|_| ())?;
1629 loop {
1630 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1631 match (fty, fid as ::std::primitive::i32) {
1632 (::fbthrift::TType::Stop, _) => break,
1633 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1634 (fty, _) => p.skip(fty)?,
1635 }
1636 p.read_field_end()?;
1637 }
1638 p.read_struct_end()?;
1639 ::std::result::Result::Ok(Self {
1640 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.sendSnapshot", "req"))?,
1641 })
1642 }
1643 }
1644
1645 struct Args_RaftexService_heartbeat {
1646 req: crate::types::HeartbeatRequest,
1647 }
1648 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_heartbeat {
1649 #[inline]
1650 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.heartbeat"))]
1651 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1652 static ARGS: &[::fbthrift::Field] = &[
1653 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1654 ];
1655 let mut field_req = ::std::option::Option::None;
1656 let _ = p.read_struct_begin(|_| ())?;
1657 loop {
1658 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1659 match (fty, fid as ::std::primitive::i32) {
1660 (::fbthrift::TType::Stop, _) => break,
1661 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1662 (fty, _) => p.skip(fty)?,
1663 }
1664 p.read_field_end()?;
1665 }
1666 p.read_struct_end()?;
1667 ::std::result::Result::Ok(Self {
1668 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.heartbeat", "req"))?,
1669 })
1670 }
1671 }
1672
1673 struct Args_RaftexService_getState {
1674 req: crate::types::GetStateRequest,
1675 }
1676 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_getState {
1677 #[inline]
1678 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.getState"))]
1679 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1680 static ARGS: &[::fbthrift::Field] = &[
1681 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1682 ];
1683 let mut field_req = ::std::option::Option::None;
1684 let _ = p.read_struct_begin(|_| ())?;
1685 loop {
1686 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1687 match (fty, fid as ::std::primitive::i32) {
1688 (::fbthrift::TType::Stop, _) => break,
1689 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1690 (fty, _) => p.skip(fty)?,
1691 }
1692 p.read_field_end()?;
1693 }
1694 p.read_struct_end()?;
1695 ::std::result::Result::Ok(Self {
1696 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.getState", "req"))?,
1697 })
1698 }
1699 }
1700
1701
1702 impl<P, H, R, RS> RaftexServiceProcessor<P, H, R, RS>
1703 where
1704 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1705 P::Frame: ::std::marker::Send + 'static,
1706 P::Deserializer: ::std::marker::Send,
1707 H: RaftexService,
1708 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
1709 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static,
1710 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
1711 + ::std::marker::Send + ::std::marker::Sync,
1712 {
1713 pub fn new(service: H) -> Self {
1714 Self {
1715 service,
1716 supa: ::fbthrift::NullServiceProcessor::new(),
1717 _phantom: ::std::marker::PhantomData,
1718 }
1719 }
1720
1721 pub fn into_inner(self) -> H {
1722 self.service
1723 }
1724
1725 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.askForVote"))]
1726 async fn handle_askForVote<'a>(
1727 &'a self,
1728 p: &'a mut P::Deserializer,
1729 req_ctxt: &R,
1730 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1731 _seqid: ::std::primitive::u32,
1732 ) -> ::anyhow::Result<()> {
1733 use ::const_cstr::const_cstr;
1734 use ::futures::FutureExt as _;
1735
1736 const_cstr! {
1737 SERVICE_NAME = "RaftexService";
1738 METHOD_NAME = "RaftexService.askForVote";
1739 }
1740 let mut ctx_stack = req_ctxt.get_context_stack(
1741 SERVICE_NAME.as_cstr(),
1742 METHOD_NAME.as_cstr(),
1743 )?;
1744 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1745 let _args: self::Args_RaftexService_askForVote = ::fbthrift::Deserialize::read(p)?;
1746 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1747 protocol: P::PROTOCOL_ID,
1748 method_name: METHOD_NAME.as_cstr(),
1749 buffer: ::std::marker::PhantomData, })?;
1751 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1752
1753 let res = ::std::panic::AssertUnwindSafe(
1754 self.service.askForVote(
1755 _args.req,
1756 )
1757 )
1758 .catch_unwind()
1759 .await;
1760
1761 let res = match res {
1763 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1764 ::tracing::info!("success");
1765 crate::services::raftex_service::AskForVoteExn::Success(res)
1766 }
1767 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::Success(_))) => {
1768 panic!(
1769 "{} attempted to return success via error",
1770 "askForVote",
1771 )
1772 }
1773 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1774 ::tracing::error!(exception = ?exn);
1775 exn
1776 }
1777 ::std::result::Result::Err(exn) => {
1778 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.askForVote", exn);
1779 crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn)
1780 }
1781 };
1782
1783 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1784 "askForVote",
1785 METHOD_NAME.as_cstr(),
1786 _seqid,
1787 req_ctxt,
1788 &mut ctx_stack,
1789 res
1790 )?;
1791 reply_state.lock().unwrap().send_reply(env);
1792 Ok(())
1793 }
1794
1795 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.appendLog"))]
1796 async fn handle_appendLog<'a>(
1797 &'a self,
1798 p: &'a mut P::Deserializer,
1799 req_ctxt: &R,
1800 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1801 _seqid: ::std::primitive::u32,
1802 ) -> ::anyhow::Result<()> {
1803 use ::const_cstr::const_cstr;
1804 use ::futures::FutureExt as _;
1805
1806 const_cstr! {
1807 SERVICE_NAME = "RaftexService";
1808 METHOD_NAME = "RaftexService.appendLog";
1809 }
1810 let mut ctx_stack = req_ctxt.get_context_stack(
1811 SERVICE_NAME.as_cstr(),
1812 METHOD_NAME.as_cstr(),
1813 )?;
1814 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1815 let _args: self::Args_RaftexService_appendLog = ::fbthrift::Deserialize::read(p)?;
1816 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1817 protocol: P::PROTOCOL_ID,
1818 method_name: METHOD_NAME.as_cstr(),
1819 buffer: ::std::marker::PhantomData, })?;
1821 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1822
1823 let res = ::std::panic::AssertUnwindSafe(
1824 self.service.appendLog(
1825 _args.req,
1826 )
1827 )
1828 .catch_unwind()
1829 .await;
1830
1831 let res = match res {
1833 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1834 ::tracing::info!("success");
1835 crate::services::raftex_service::AppendLogExn::Success(res)
1836 }
1837 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::Success(_))) => {
1838 panic!(
1839 "{} attempted to return success via error",
1840 "appendLog",
1841 )
1842 }
1843 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1844 ::tracing::error!(exception = ?exn);
1845 exn
1846 }
1847 ::std::result::Result::Err(exn) => {
1848 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.appendLog", exn);
1849 crate::services::raftex_service::AppendLogExn::ApplicationException(aexn)
1850 }
1851 };
1852
1853 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1854 "appendLog",
1855 METHOD_NAME.as_cstr(),
1856 _seqid,
1857 req_ctxt,
1858 &mut ctx_stack,
1859 res
1860 )?;
1861 reply_state.lock().unwrap().send_reply(env);
1862 Ok(())
1863 }
1864
1865 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.sendSnapshot"))]
1866 async fn handle_sendSnapshot<'a>(
1867 &'a self,
1868 p: &'a mut P::Deserializer,
1869 req_ctxt: &R,
1870 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1871 _seqid: ::std::primitive::u32,
1872 ) -> ::anyhow::Result<()> {
1873 use ::const_cstr::const_cstr;
1874 use ::futures::FutureExt as _;
1875
1876 const_cstr! {
1877 SERVICE_NAME = "RaftexService";
1878 METHOD_NAME = "RaftexService.sendSnapshot";
1879 }
1880 let mut ctx_stack = req_ctxt.get_context_stack(
1881 SERVICE_NAME.as_cstr(),
1882 METHOD_NAME.as_cstr(),
1883 )?;
1884 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1885 let _args: self::Args_RaftexService_sendSnapshot = ::fbthrift::Deserialize::read(p)?;
1886 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1887 protocol: P::PROTOCOL_ID,
1888 method_name: METHOD_NAME.as_cstr(),
1889 buffer: ::std::marker::PhantomData, })?;
1891 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1892
1893 let res = ::std::panic::AssertUnwindSafe(
1894 self.service.sendSnapshot(
1895 _args.req,
1896 )
1897 )
1898 .catch_unwind()
1899 .await;
1900
1901 let res = match res {
1903 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1904 ::tracing::info!("success");
1905 crate::services::raftex_service::SendSnapshotExn::Success(res)
1906 }
1907 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::Success(_))) => {
1908 panic!(
1909 "{} attempted to return success via error",
1910 "sendSnapshot",
1911 )
1912 }
1913 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1914 ::tracing::error!(exception = ?exn);
1915 exn
1916 }
1917 ::std::result::Result::Err(exn) => {
1918 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.sendSnapshot", exn);
1919 crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn)
1920 }
1921 };
1922
1923 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1924 "sendSnapshot",
1925 METHOD_NAME.as_cstr(),
1926 _seqid,
1927 req_ctxt,
1928 &mut ctx_stack,
1929 res
1930 )?;
1931 reply_state.lock().unwrap().send_reply(env);
1932 Ok(())
1933 }
1934
1935 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.heartbeat"))]
1936 async fn handle_heartbeat<'a>(
1937 &'a self,
1938 p: &'a mut P::Deserializer,
1939 req_ctxt: &R,
1940 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1941 _seqid: ::std::primitive::u32,
1942 ) -> ::anyhow::Result<()> {
1943 use ::const_cstr::const_cstr;
1944 use ::futures::FutureExt as _;
1945
1946 const_cstr! {
1947 SERVICE_NAME = "RaftexService";
1948 METHOD_NAME = "RaftexService.heartbeat";
1949 }
1950 let mut ctx_stack = req_ctxt.get_context_stack(
1951 SERVICE_NAME.as_cstr(),
1952 METHOD_NAME.as_cstr(),
1953 )?;
1954 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1955 let _args: self::Args_RaftexService_heartbeat = ::fbthrift::Deserialize::read(p)?;
1956 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1957 protocol: P::PROTOCOL_ID,
1958 method_name: METHOD_NAME.as_cstr(),
1959 buffer: ::std::marker::PhantomData, })?;
1961 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1962
1963 let res = ::std::panic::AssertUnwindSafe(
1964 self.service.heartbeat(
1965 _args.req,
1966 )
1967 )
1968 .catch_unwind()
1969 .await;
1970
1971 let res = match res {
1973 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1974 ::tracing::info!("success");
1975 crate::services::raftex_service::HeartbeatExn::Success(res)
1976 }
1977 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::HeartbeatExn::Success(_))) => {
1978 panic!(
1979 "{} attempted to return success via error",
1980 "heartbeat",
1981 )
1982 }
1983 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1984 ::tracing::error!(exception = ?exn);
1985 exn
1986 }
1987 ::std::result::Result::Err(exn) => {
1988 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.heartbeat", exn);
1989 crate::services::raftex_service::HeartbeatExn::ApplicationException(aexn)
1990 }
1991 };
1992
1993 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1994 "heartbeat",
1995 METHOD_NAME.as_cstr(),
1996 _seqid,
1997 req_ctxt,
1998 &mut ctx_stack,
1999 res
2000 )?;
2001 reply_state.lock().unwrap().send_reply(env);
2002 Ok(())
2003 }
2004
2005 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.getState"))]
2006 async fn handle_getState<'a>(
2007 &'a self,
2008 p: &'a mut P::Deserializer,
2009 req_ctxt: &R,
2010 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
2011 _seqid: ::std::primitive::u32,
2012 ) -> ::anyhow::Result<()> {
2013 use ::const_cstr::const_cstr;
2014 use ::futures::FutureExt as _;
2015
2016 const_cstr! {
2017 SERVICE_NAME = "RaftexService";
2018 METHOD_NAME = "RaftexService.getState";
2019 }
2020 let mut ctx_stack = req_ctxt.get_context_stack(
2021 SERVICE_NAME.as_cstr(),
2022 METHOD_NAME.as_cstr(),
2023 )?;
2024 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
2025 let _args: self::Args_RaftexService_getState = ::fbthrift::Deserialize::read(p)?;
2026 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
2027 protocol: P::PROTOCOL_ID,
2028 method_name: METHOD_NAME.as_cstr(),
2029 buffer: ::std::marker::PhantomData, })?;
2031 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
2032
2033 let res = ::std::panic::AssertUnwindSafe(
2034 self.service.getState(
2035 _args.req,
2036 )
2037 )
2038 .catch_unwind()
2039 .await;
2040
2041 let res = match res {
2043 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
2044 ::tracing::info!("success");
2045 crate::services::raftex_service::GetStateExn::Success(res)
2046 }
2047 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::GetStateExn::Success(_))) => {
2048 panic!(
2049 "{} attempted to return success via error",
2050 "getState",
2051 )
2052 }
2053 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
2054 ::tracing::error!(exception = ?exn);
2055 exn
2056 }
2057 ::std::result::Result::Err(exn) => {
2058 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.getState", exn);
2059 crate::services::raftex_service::GetStateExn::ApplicationException(aexn)
2060 }
2061 };
2062
2063 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
2064 "getState",
2065 METHOD_NAME.as_cstr(),
2066 _seqid,
2067 req_ctxt,
2068 &mut ctx_stack,
2069 res
2070 )?;
2071 reply_state.lock().unwrap().send_reply(env);
2072 Ok(())
2073 }
2074 }
2075
2076 #[::async_trait::async_trait]
2077 impl<P, H, R, RS> ::fbthrift::ServiceProcessor<P> for RaftexServiceProcessor<P, H, R, RS>
2078 where
2079 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
2080 P::Deserializer: ::std::marker::Send,
2081 H: RaftexService,
2082 P::Frame: ::std::marker::Send + 'static,
2083 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
2084 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
2085 + ::std::marker::Send + ::std::marker::Sync + 'static,
2086 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
2087 {
2088 type RequestContext = R;
2089 type ReplyState = RS;
2090
2091 #[inline]
2092 fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> {
2093 match name {
2094 b"askForVote" => ::std::result::Result::Ok(0usize),
2095 b"appendLog" => ::std::result::Result::Ok(1usize),
2096 b"sendSnapshot" => ::std::result::Result::Ok(2usize),
2097 b"heartbeat" => ::std::result::Result::Ok(3usize),
2098 b"getState" => ::std::result::Result::Ok(4usize),
2099 _ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()),
2100 }
2101 }
2102
2103 #[allow(clippy::match_single_binding)]
2104 async fn handle_method(
2105 &self,
2106 idx: ::std::primitive::usize,
2107 _p: &mut P::Deserializer,
2108 _r: &R,
2109 _reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
2110 _seqid: ::std::primitive::u32,
2111 ) -> ::anyhow::Result<()> {
2112 match idx {
2113 0usize => {
2114 self.handle_askForVote(_p, _r, _reply_state, _seqid).await
2115 }
2116 1usize => {
2117 self.handle_appendLog(_p, _r, _reply_state, _seqid).await
2118 }
2119 2usize => {
2120 self.handle_sendSnapshot(_p, _r, _reply_state, _seqid).await
2121 }
2122 3usize => {
2123 self.handle_heartbeat(_p, _r, _reply_state, _seqid).await
2124 }
2125 4usize => {
2126 self.handle_getState(_p, _r, _reply_state, _seqid).await
2127 }
2128 bad => panic!(
2129 "{}: unexpected method idx {}",
2130 "RaftexServiceProcessor",
2131 bad
2132 ),
2133 }
2134 }
2135
2136 #[allow(clippy::match_single_binding)]
2137 #[inline]
2138 fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> {
2139 match name {
2140 _ => ::anyhow::bail!("Unknown interaction"),
2141 }
2142 }
2143
2144 #[allow(clippy::match_single_binding)]
2145 fn handle_create_interaction(
2146 &self,
2147 idx: ::std::primitive::usize,
2148 ) -> ::anyhow::Result<
2149 ::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = Self::RequestContext, ReplyState = Self::ReplyState> + ::std::marker::Send + 'static>
2150 > {
2151 match idx {
2152 bad => panic!(
2153 "{}: unexpected method idx {}",
2154 "RaftexServiceProcessor",
2155 bad
2156 ),
2157 }
2158 }
2159 }
2160
2161 #[::async_trait::async_trait]
2162 impl<P, H, R, RS> ::fbthrift::ThriftService<P::Frame> for RaftexServiceProcessor<P, H, R, RS>
2163 where
2164 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
2165 P::Deserializer: ::std::marker::Send,
2166 P::Frame: ::std::marker::Send + 'static,
2167 H: RaftexService,
2168 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
2169 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
2170 + ::std::marker::Send + ::std::marker::Sync + 'static,
2171 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
2172 {
2173 type Handler = H;
2174 type RequestContext = R;
2175 type ReplyState = RS;
2176
2177 #[tracing::instrument(level="trace", skip_all, fields(service = "RaftexService"))]
2178 async fn call(
2179 &self,
2180 req: ::fbthrift::ProtocolDecoded<P>,
2181 req_ctxt: &R,
2182 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
2183 ) -> ::anyhow::Result<()> {
2184 use ::fbthrift::{BufExt as _, ProtocolReader as _, ServiceProcessor as _};
2185 let mut p = P::deserializer(req);
2186 let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?;
2187 if mty != ::fbthrift::MessageType::Call {
2188 return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new(
2189 ::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType,
2190 format!("message type {:?} not handled", mty)
2191 )));
2192 }
2193 let idx = match idx {
2194 ::std::result::Result::Ok(idx) => idx,
2195 ::std::result::Result::Err(_) => {
2196 let cur = P::into_buffer(p).reset();
2197 return self.supa.call(cur, req_ctxt, reply_state).await;
2198 }
2199 };
2200 self.handle_method(idx, &mut p, req_ctxt, reply_state, seqid).await?;
2201 p.read_message_end()?;
2202
2203 Ok(())
2204 }
2205
2206 fn create_interaction(
2207 &self,
2208 name: &str,
2209 ) -> ::anyhow::Result<
2210 ::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>
2211 > {
2212 use ::fbthrift::{ServiceProcessor as _};
2213 let idx = self.create_interaction_idx(name);
2214 let idx = match idx {
2215 ::anyhow::Result::Ok(idx) => idx,
2216 ::anyhow::Result::Err(_) => {
2217 return self.supa.create_interaction(name);
2218 }
2219 };
2220 self.handle_create_interaction(idx)
2221 }
2222
2223 fn get_method_names(&self) -> &'static [&'static str] {
2224 &[
2225 "askForVote",
2227 "appendLog",
2228 "sendSnapshot",
2229 "heartbeat",
2230 "getState",
2231 ]
2232 }
2233 }
2234
2235 #[::tracing::instrument(level="debug", skip_all, fields(proto = ?proto))]
2240 pub fn make_RaftexService_server<F, H, R, RS>(
2241 proto: ::fbthrift::ProtocolID,
2242 handler: H,
2243 ) -> ::std::result::Result<::std::boxed::Box<dyn ::fbthrift::ThriftService<F, Handler = H, RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException>
2244 where
2245 F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static,
2246 H: RaftexService,
2247 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
2248 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = F::DecBuf> + ::std::marker::Send + ::std::marker::Sync + 'static,
2249 RS: ::fbthrift::ReplyState<F, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
2250 {
2251 match proto {
2252 ::fbthrift::ProtocolID::BinaryProtocol => {
2253 ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::BinaryProtocol<F>, H, R, RS>::new(handler)))
2254 }
2255 ::fbthrift::ProtocolID::CompactProtocol => {
2256 ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::CompactProtocol<F>, H, R, RS>::new(handler)))
2257 }
2258 bad => {
2259 ::tracing::error!(method = "RaftexService.", invalid_protocol = ?bad);
2260 ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad))
2261 }
2262 }
2263 }
2264}
2265
2266pub mod mock {
2360 pub struct RaftexService<'mock> {
2361 pub askForVote: r#impl::raftex_service::askForVote<'mock>,
2362 pub appendLog: r#impl::raftex_service::appendLog<'mock>,
2363 pub sendSnapshot: r#impl::raftex_service::sendSnapshot<'mock>,
2364 pub heartbeat: r#impl::raftex_service::heartbeat<'mock>,
2365 pub getState: r#impl::raftex_service::getState<'mock>,
2366 _marker: ::std::marker::PhantomData<&'mock ()>,
2367 }
2368
2369 impl dyn super::client::RaftexService {
2370 pub fn mock<'mock>() -> RaftexService<'mock> {
2371 RaftexService {
2372 askForVote: r#impl::raftex_service::askForVote::unimplemented(),
2373 appendLog: r#impl::raftex_service::appendLog::unimplemented(),
2374 sendSnapshot: r#impl::raftex_service::sendSnapshot::unimplemented(),
2375 heartbeat: r#impl::raftex_service::heartbeat::unimplemented(),
2376 getState: r#impl::raftex_service::getState::unimplemented(),
2377 _marker: ::std::marker::PhantomData,
2378 }
2379 }
2380 }
2381
2382 impl<'mock> super::client::RaftexService for RaftexService<'mock> {
2383 fn askForVote(
2384 &self,
2385 arg_req: &crate::types::AskForVoteRequest,
2386 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
2387 let mut closure = self.askForVote.closure.lock().unwrap();
2388 let closure: &mut dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> _ = &mut **closure;
2389 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
2390 }
2391 fn appendLog(
2392 &self,
2393 arg_req: &crate::types::AppendLogRequest,
2394 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
2395 let mut closure = self.appendLog.closure.lock().unwrap();
2396 let closure: &mut dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> _ = &mut **closure;
2397 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
2398 }
2399 fn sendSnapshot(
2400 &self,
2401 arg_req: &crate::types::SendSnapshotRequest,
2402 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
2403 let mut closure = self.sendSnapshot.closure.lock().unwrap();
2404 let closure: &mut dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> _ = &mut **closure;
2405 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
2406 }
2407 fn heartbeat(
2408 &self,
2409 arg_req: &crate::types::HeartbeatRequest,
2410 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError>> {
2411 let mut closure = self.heartbeat.closure.lock().unwrap();
2412 let closure: &mut dyn ::std::ops::FnMut(crate::types::HeartbeatRequest) -> _ = &mut **closure;
2413 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
2414 }
2415 fn getState(
2416 &self,
2417 arg_req: &crate::types::GetStateRequest,
2418 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError>> {
2419 let mut closure = self.getState.closure.lock().unwrap();
2420 let closure: &mut dyn ::std::ops::FnMut(crate::types::GetStateRequest) -> _ = &mut **closure;
2421 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
2422 }
2423 }
2424
2425 mod r#impl {
2426 pub mod raftex_service {
2427
2428 pub struct askForVote<'mock> {
2429 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
2430 dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<
2431 crate::types::AskForVoteResponse,
2432 crate::errors::raftex_service::AskForVoteError,
2433 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
2434 >>,
2435 }
2436
2437 #[allow(clippy::redundant_closure)]
2438 impl<'mock> askForVote<'mock> {
2439 pub fn unimplemented() -> Self {
2440 Self {
2441 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AskForVoteRequest| panic!(
2442 "{}::{} is not mocked",
2443 "RaftexService",
2444 "askForVote",
2445 ))),
2446 }
2447 }
2448
2449 pub fn ret(&self, value: crate::types::AskForVoteResponse) {
2450 self.mock(move |_: crate::types::AskForVoteRequest| value.clone());
2451 }
2452
2453 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> crate::types::AskForVoteResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2454 let mut closure = self.closure.lock().unwrap();
2455 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
2456 }
2457
2458 pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2459 let mut closure = self.closure.lock().unwrap();
2460 *closure = ::std::boxed::Box::new(move |req| mock(req));
2461 }
2462
2463 pub fn throw<E>(&self, exception: E)
2464 where
2465 E: ::std::convert::Into<crate::errors::raftex_service::AskForVoteError>,
2466 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2467 {
2468 let mut closure = self.closure.lock().unwrap();
2469 *closure = ::std::boxed::Box::new(move |_: crate::types::AskForVoteRequest| ::std::result::Result::Err(exception.clone().into()));
2470 }
2471 }
2472
2473 pub struct appendLog<'mock> {
2474 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
2475 dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<
2476 crate::types::AppendLogResponse,
2477 crate::errors::raftex_service::AppendLogError,
2478 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
2479 >>,
2480 }
2481
2482 #[allow(clippy::redundant_closure)]
2483 impl<'mock> appendLog<'mock> {
2484 pub fn unimplemented() -> Self {
2485 Self {
2486 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AppendLogRequest| panic!(
2487 "{}::{} is not mocked",
2488 "RaftexService",
2489 "appendLog",
2490 ))),
2491 }
2492 }
2493
2494 pub fn ret(&self, value: crate::types::AppendLogResponse) {
2495 self.mock(move |_: crate::types::AppendLogRequest| value.clone());
2496 }
2497
2498 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> crate::types::AppendLogResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2499 let mut closure = self.closure.lock().unwrap();
2500 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
2501 }
2502
2503 pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2504 let mut closure = self.closure.lock().unwrap();
2505 *closure = ::std::boxed::Box::new(move |req| mock(req));
2506 }
2507
2508 pub fn throw<E>(&self, exception: E)
2509 where
2510 E: ::std::convert::Into<crate::errors::raftex_service::AppendLogError>,
2511 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2512 {
2513 let mut closure = self.closure.lock().unwrap();
2514 *closure = ::std::boxed::Box::new(move |_: crate::types::AppendLogRequest| ::std::result::Result::Err(exception.clone().into()));
2515 }
2516 }
2517
2518 pub struct sendSnapshot<'mock> {
2519 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
2520 dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<
2521 crate::types::SendSnapshotResponse,
2522 crate::errors::raftex_service::SendSnapshotError,
2523 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
2524 >>,
2525 }
2526
2527 #[allow(clippy::redundant_closure)]
2528 impl<'mock> sendSnapshot<'mock> {
2529 pub fn unimplemented() -> Self {
2530 Self {
2531 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::SendSnapshotRequest| panic!(
2532 "{}::{} is not mocked",
2533 "RaftexService",
2534 "sendSnapshot",
2535 ))),
2536 }
2537 }
2538
2539 pub fn ret(&self, value: crate::types::SendSnapshotResponse) {
2540 self.mock(move |_: crate::types::SendSnapshotRequest| value.clone());
2541 }
2542
2543 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> crate::types::SendSnapshotResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2544 let mut closure = self.closure.lock().unwrap();
2545 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
2546 }
2547
2548 pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2549 let mut closure = self.closure.lock().unwrap();
2550 *closure = ::std::boxed::Box::new(move |req| mock(req));
2551 }
2552
2553 pub fn throw<E>(&self, exception: E)
2554 where
2555 E: ::std::convert::Into<crate::errors::raftex_service::SendSnapshotError>,
2556 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2557 {
2558 let mut closure = self.closure.lock().unwrap();
2559 *closure = ::std::boxed::Box::new(move |_: crate::types::SendSnapshotRequest| ::std::result::Result::Err(exception.clone().into()));
2560 }
2561 }
2562
2563 pub struct heartbeat<'mock> {
2564 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
2565 dyn ::std::ops::FnMut(crate::types::HeartbeatRequest) -> ::std::result::Result<
2566 crate::types::HeartbeatResponse,
2567 crate::errors::raftex_service::HeartbeatError,
2568 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
2569 >>,
2570 }
2571
2572 #[allow(clippy::redundant_closure)]
2573 impl<'mock> heartbeat<'mock> {
2574 pub fn unimplemented() -> Self {
2575 Self {
2576 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::HeartbeatRequest| panic!(
2577 "{}::{} is not mocked",
2578 "RaftexService",
2579 "heartbeat",
2580 ))),
2581 }
2582 }
2583
2584 pub fn ret(&self, value: crate::types::HeartbeatResponse) {
2585 self.mock(move |_: crate::types::HeartbeatRequest| value.clone());
2586 }
2587
2588 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::HeartbeatRequest) -> crate::types::HeartbeatResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2589 let mut closure = self.closure.lock().unwrap();
2590 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
2591 }
2592
2593 pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::HeartbeatRequest) -> ::std::result::Result<crate::types::HeartbeatResponse, crate::errors::raftex_service::HeartbeatError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2594 let mut closure = self.closure.lock().unwrap();
2595 *closure = ::std::boxed::Box::new(move |req| mock(req));
2596 }
2597
2598 pub fn throw<E>(&self, exception: E)
2599 where
2600 E: ::std::convert::Into<crate::errors::raftex_service::HeartbeatError>,
2601 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2602 {
2603 let mut closure = self.closure.lock().unwrap();
2604 *closure = ::std::boxed::Box::new(move |_: crate::types::HeartbeatRequest| ::std::result::Result::Err(exception.clone().into()));
2605 }
2606 }
2607
2608 pub struct getState<'mock> {
2609 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
2610 dyn ::std::ops::FnMut(crate::types::GetStateRequest) -> ::std::result::Result<
2611 crate::types::GetStateResponse,
2612 crate::errors::raftex_service::GetStateError,
2613 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
2614 >>,
2615 }
2616
2617 #[allow(clippy::redundant_closure)]
2618 impl<'mock> getState<'mock> {
2619 pub fn unimplemented() -> Self {
2620 Self {
2621 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::GetStateRequest| panic!(
2622 "{}::{} is not mocked",
2623 "RaftexService",
2624 "getState",
2625 ))),
2626 }
2627 }
2628
2629 pub fn ret(&self, value: crate::types::GetStateResponse) {
2630 self.mock(move |_: crate::types::GetStateRequest| value.clone());
2631 }
2632
2633 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::GetStateRequest) -> crate::types::GetStateResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2634 let mut closure = self.closure.lock().unwrap();
2635 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
2636 }
2637
2638 pub fn mock_result(&self, mut mock: impl ::std::ops::FnMut(crate::types::GetStateRequest) -> ::std::result::Result<crate::types::GetStateResponse, crate::errors::raftex_service::GetStateError> + ::std::marker::Send + ::std::marker::Sync + 'mock) {
2639 let mut closure = self.closure.lock().unwrap();
2640 *closure = ::std::boxed::Box::new(move |req| mock(req));
2641 }
2642
2643 pub fn throw<E>(&self, exception: E)
2644 where
2645 E: ::std::convert::Into<crate::errors::raftex_service::GetStateError>,
2646 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
2647 {
2648 let mut closure = self.closure.lock().unwrap();
2649 *closure = ::std::boxed::Box::new(move |_: crate::types::GetStateRequest| ::std::result::Result::Err(exception.clone().into()));
2650 }
2651 }
2652 }
2653 }
2654}
2655
2656pub mod errors {
2658 pub mod raftex_service {
2660
2661 pub type AskForVoteError = ::fbthrift::NonthrowingFunctionError;
2662
2663 impl ::std::convert::From<crate::services::raftex_service::AskForVoteExn> for
2664 ::std::result::Result<crate::types::AskForVoteResponse, AskForVoteError>
2665 {
2666 fn from(e: crate::services::raftex_service::AskForVoteExn) -> Self {
2667 match e {
2668 crate::services::raftex_service::AskForVoteExn::Success(res) => {
2669 ::std::result::Result::Ok(res)
2670 }
2671 crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn) =>
2672 ::std::result::Result::Err(AskForVoteError::ApplicationException(aexn)),
2673 }
2674 }
2675 }
2676
2677 pub type AppendLogError = ::fbthrift::NonthrowingFunctionError;
2678
2679 impl ::std::convert::From<crate::services::raftex_service::AppendLogExn> for
2680 ::std::result::Result<crate::types::AppendLogResponse, AppendLogError>
2681 {
2682 fn from(e: crate::services::raftex_service::AppendLogExn) -> Self {
2683 match e {
2684 crate::services::raftex_service::AppendLogExn::Success(res) => {
2685 ::std::result::Result::Ok(res)
2686 }
2687 crate::services::raftex_service::AppendLogExn::ApplicationException(aexn) =>
2688 ::std::result::Result::Err(AppendLogError::ApplicationException(aexn)),
2689 }
2690 }
2691 }
2692
2693 pub type SendSnapshotError = ::fbthrift::NonthrowingFunctionError;
2694
2695 impl ::std::convert::From<crate::services::raftex_service::SendSnapshotExn> for
2696 ::std::result::Result<crate::types::SendSnapshotResponse, SendSnapshotError>
2697 {
2698 fn from(e: crate::services::raftex_service::SendSnapshotExn) -> Self {
2699 match e {
2700 crate::services::raftex_service::SendSnapshotExn::Success(res) => {
2701 ::std::result::Result::Ok(res)
2702 }
2703 crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn) =>
2704 ::std::result::Result::Err(SendSnapshotError::ApplicationException(aexn)),
2705 }
2706 }
2707 }
2708
2709 pub type HeartbeatError = ::fbthrift::NonthrowingFunctionError;
2710
2711 impl ::std::convert::From<crate::services::raftex_service::HeartbeatExn> for
2712 ::std::result::Result<crate::types::HeartbeatResponse, HeartbeatError>
2713 {
2714 fn from(e: crate::services::raftex_service::HeartbeatExn) -> Self {
2715 match e {
2716 crate::services::raftex_service::HeartbeatExn::Success(res) => {
2717 ::std::result::Result::Ok(res)
2718 }
2719 crate::services::raftex_service::HeartbeatExn::ApplicationException(aexn) =>
2720 ::std::result::Result::Err(HeartbeatError::ApplicationException(aexn)),
2721 }
2722 }
2723 }
2724
2725 pub type GetStateError = ::fbthrift::NonthrowingFunctionError;
2726
2727 impl ::std::convert::From<crate::services::raftex_service::GetStateExn> for
2728 ::std::result::Result<crate::types::GetStateResponse, GetStateError>
2729 {
2730 fn from(e: crate::services::raftex_service::GetStateExn) -> Self {
2731 match e {
2732 crate::services::raftex_service::GetStateExn::Success(res) => {
2733 ::std::result::Result::Ok(res)
2734 }
2735 crate::services::raftex_service::GetStateExn::ApplicationException(aexn) =>
2736 ::std::result::Result::Err(GetStateError::ApplicationException(aexn)),
2737 }
2738 }
2739 }
2740
2741 }
2742
2743}