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}
426
427pub mod client {
429
430 pub struct RaftexServiceImpl<P, T, S = ::fbthrift::NoopSpawner> {
431 transport: T,
432 _phantom: ::std::marker::PhantomData<fn() -> (P, S)>,
433 }
434
435 impl<P, T, S> RaftexServiceImpl<P, T, S>
436 where
437 P: ::fbthrift::Protocol,
438 T: ::fbthrift::Transport,
439 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
440 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
441 P::Deserializer: ::std::marker::Send,
442 S: ::fbthrift::help::Spawner,
443 {
444 pub fn new(
445 transport: T,
446 ) -> Self {
447 Self {
448 transport,
449 _phantom: ::std::marker::PhantomData,
450 }
451 }
452
453 pub fn transport(&self) -> &T {
454 &self.transport
455 }
456
457
458 fn _askForVote_impl(
459 &self,
460 arg_req: &crate::types::AskForVoteRequest,
461 rpc_options: T::RpcOptions,
462 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
463 use ::const_cstr::const_cstr;
464 use ::tracing::Instrument as _;
465 use ::futures::FutureExt as _;
466
467 const_cstr! {
468 SERVICE_NAME = "RaftexService";
469 METHOD_NAME = "RaftexService.askForVote";
470 }
471 let args = self::Args_RaftexService_askForVote {
472 req: arg_req,
473 _phantom: ::std::marker::PhantomData,
474 };
475
476 let transport = self.transport();
477
478 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("askForVote", &args) {
480 ::std::result::Result::Ok(res) => res,
481 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
482 };
483
484 let call = transport
485 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
486 .instrument(::tracing::trace_span!("call", function = "RaftexService.askForVote"));
487
488 async move {
489 let reply_env = call.await?;
490
491 let de = P::deserializer(reply_env);
492 let (res, _de): (::std::result::Result<crate::services::raftex_service::AskForVoteExn, _>, _) =
493 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
494
495 let res = match res {
496 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
497 ::std::result::Result::Err(aexn) =>
498 ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(aexn))
499 };
500 res
501 }
502 .instrument(::tracing::info_span!("RaftexService.askForVote"))
503 .boxed()
504 }
505
506 fn _appendLog_impl(
507 &self,
508 arg_req: &crate::types::AppendLogRequest,
509 rpc_options: T::RpcOptions,
510 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
511 use ::const_cstr::const_cstr;
512 use ::tracing::Instrument as _;
513 use ::futures::FutureExt as _;
514
515 const_cstr! {
516 SERVICE_NAME = "RaftexService";
517 METHOD_NAME = "RaftexService.appendLog";
518 }
519 let args = self::Args_RaftexService_appendLog {
520 req: arg_req,
521 _phantom: ::std::marker::PhantomData,
522 };
523
524 let transport = self.transport();
525
526 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("appendLog", &args) {
528 ::std::result::Result::Ok(res) => res,
529 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
530 };
531
532 let call = transport
533 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
534 .instrument(::tracing::trace_span!("call", function = "RaftexService.appendLog"));
535
536 async move {
537 let reply_env = call.await?;
538
539 let de = P::deserializer(reply_env);
540 let (res, _de): (::std::result::Result<crate::services::raftex_service::AppendLogExn, _>, _) =
541 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
542
543 let res = match res {
544 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
545 ::std::result::Result::Err(aexn) =>
546 ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(aexn))
547 };
548 res
549 }
550 .instrument(::tracing::info_span!("RaftexService.appendLog"))
551 .boxed()
552 }
553
554 fn _sendSnapshot_impl(
555 &self,
556 arg_req: &crate::types::SendSnapshotRequest,
557 rpc_options: T::RpcOptions,
558 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
559 use ::const_cstr::const_cstr;
560 use ::tracing::Instrument as _;
561 use ::futures::FutureExt as _;
562
563 const_cstr! {
564 SERVICE_NAME = "RaftexService";
565 METHOD_NAME = "RaftexService.sendSnapshot";
566 }
567 let args = self::Args_RaftexService_sendSnapshot {
568 req: arg_req,
569 _phantom: ::std::marker::PhantomData,
570 };
571
572 let transport = self.transport();
573
574 let request_env = match ::fbthrift::help::serialize_request_envelope::<P, _>("sendSnapshot", &args) {
576 ::std::result::Result::Ok(res) => res,
577 ::std::result::Result::Err(err) => return ::futures::future::err(err.into()).boxed(),
578 };
579
580 let call = transport
581 .call(SERVICE_NAME.as_cstr(), METHOD_NAME.as_cstr(), request_env, rpc_options)
582 .instrument(::tracing::trace_span!("call", function = "RaftexService.sendSnapshot"));
583
584 async move {
585 let reply_env = call.await?;
586
587 let de = P::deserializer(reply_env);
588 let (res, _de): (::std::result::Result<crate::services::raftex_service::SendSnapshotExn, _>, _) =
589 ::fbthrift::help::async_deserialize_response_envelope::<P, _, S>(de).await?;
590
591 let res = match res {
592 ::std::result::Result::Ok(exn) => ::std::convert::From::from(exn),
593 ::std::result::Result::Err(aexn) =>
594 ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(aexn))
595 };
596 res
597 }
598 .instrument(::tracing::info_span!("RaftexService.sendSnapshot"))
599 .boxed()
600 }
601 }
602
603 pub trait RaftexService: ::std::marker::Send {
604 fn askForVote(
605 &self,
606 arg_req: &crate::types::AskForVoteRequest,
607 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
608
609 fn appendLog(
610 &self,
611 arg_req: &crate::types::AppendLogRequest,
612 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
613
614 fn sendSnapshot(
615 &self,
616 arg_req: &crate::types::SendSnapshotRequest,
617 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
618 }
619
620 pub trait RaftexServiceExt<T>: RaftexService
621 where
622 T: ::fbthrift::Transport,
623 {
624 fn askForVote_with_rpc_opts(
625 &self,
626 arg_req: &crate::types::AskForVoteRequest,
627 rpc_options: T::RpcOptions,
628 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>>;
629 fn appendLog_with_rpc_opts(
630 &self,
631 arg_req: &crate::types::AppendLogRequest,
632 rpc_options: T::RpcOptions,
633 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>>;
634 fn sendSnapshot_with_rpc_opts(
635 &self,
636 arg_req: &crate::types::SendSnapshotRequest,
637 rpc_options: T::RpcOptions,
638 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>>;
639 }
640
641 struct Args_RaftexService_askForVote<'a> {
642 req: &'a crate::types::AskForVoteRequest,
643 _phantom: ::std::marker::PhantomData<&'a ()>,
644 }
645
646 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_askForVote<'a> {
647 #[inline]
648 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.askForVote"))]
649 fn write(&self, p: &mut P) {
650 p.write_struct_begin("args");
651 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
652 ::fbthrift::Serialize::write(&self.req, p);
653 p.write_field_end();
654 p.write_field_stop();
655 p.write_struct_end();
656 }
657 }
658
659 struct Args_RaftexService_appendLog<'a> {
660 req: &'a crate::types::AppendLogRequest,
661 _phantom: ::std::marker::PhantomData<&'a ()>,
662 }
663
664 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_appendLog<'a> {
665 #[inline]
666 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.appendLog"))]
667 fn write(&self, p: &mut P) {
668 p.write_struct_begin("args");
669 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
670 ::fbthrift::Serialize::write(&self.req, p);
671 p.write_field_end();
672 p.write_field_stop();
673 p.write_struct_end();
674 }
675 }
676
677 struct Args_RaftexService_sendSnapshot<'a> {
678 req: &'a crate::types::SendSnapshotRequest,
679 _phantom: ::std::marker::PhantomData<&'a ()>,
680 }
681
682 impl<'a, P: ::fbthrift::ProtocolWriter> ::fbthrift::Serialize<P> for self::Args_RaftexService_sendSnapshot<'a> {
683 #[inline]
684 #[::tracing::instrument(skip_all, level = "trace", name = "serialize_args", fields(method = "RaftexService.sendSnapshot"))]
685 fn write(&self, p: &mut P) {
686 p.write_struct_begin("args");
687 p.write_field_begin("req", ::fbthrift::TType::Struct, 1i16);
688 ::fbthrift::Serialize::write(&self.req, p);
689 p.write_field_end();
690 p.write_field_stop();
691 p.write_struct_end();
692 }
693 }
694
695 impl<P, T, S> RaftexService for RaftexServiceImpl<P, T, S>
696 where
697 P: ::fbthrift::Protocol,
698 T: ::fbthrift::Transport,
699 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
700 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
701 P::Deserializer: ::std::marker::Send,
702 S: ::fbthrift::help::Spawner,
703 {
704 fn askForVote(
705 &self,
706 arg_req: &crate::types::AskForVoteRequest,
707 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
708 let rpc_options = T::RpcOptions::default();
709 self._askForVote_impl(
710 arg_req,
711 rpc_options,
712 )
713 }
714 fn appendLog(
715 &self,
716 arg_req: &crate::types::AppendLogRequest,
717 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
718 let rpc_options = T::RpcOptions::default();
719 self._appendLog_impl(
720 arg_req,
721 rpc_options,
722 )
723 }
724 fn sendSnapshot(
725 &self,
726 arg_req: &crate::types::SendSnapshotRequest,
727 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
728 let rpc_options = T::RpcOptions::default();
729 self._sendSnapshot_impl(
730 arg_req,
731 rpc_options,
732 )
733 }
734 }
735
736 impl<P, T, S> RaftexServiceExt<T> for RaftexServiceImpl<P, T, S>
737 where
738 P: ::fbthrift::Protocol,
739 T: ::fbthrift::Transport,
740 P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
741 ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
742 P::Deserializer: ::std::marker::Send,
743 S: ::fbthrift::help::Spawner,
744 {
745 fn askForVote_with_rpc_opts(
746 &self,
747 arg_req: &crate::types::AskForVoteRequest,
748 rpc_options: T::RpcOptions,
749 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
750 self._askForVote_impl(
751 arg_req,
752 rpc_options,
753 )
754 }
755 fn appendLog_with_rpc_opts(
756 &self,
757 arg_req: &crate::types::AppendLogRequest,
758 rpc_options: T::RpcOptions,
759 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
760 self._appendLog_impl(
761 arg_req,
762 rpc_options,
763 )
764 }
765 fn sendSnapshot_with_rpc_opts(
766 &self,
767 arg_req: &crate::types::SendSnapshotRequest,
768 rpc_options: T::RpcOptions,
769 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
770 self._sendSnapshot_impl(
771 arg_req,
772 rpc_options,
773 )
774 }
775 }
776
777 impl<'a, S> RaftexService for S
778 where
779 S: ::std::convert::AsRef<dyn RaftexService + 'a>,
780 S: ::std::marker::Send,
781 {
782 fn askForVote(
783 &self,
784 arg_req: &crate::types::AskForVoteRequest,
785 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
786 self.as_ref().askForVote(
787 arg_req,
788 )
789 }
790 fn appendLog(
791 &self,
792 arg_req: &crate::types::AppendLogRequest,
793 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
794 self.as_ref().appendLog(
795 arg_req,
796 )
797 }
798 fn sendSnapshot(
799 &self,
800 arg_req: &crate::types::SendSnapshotRequest,
801 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
802 self.as_ref().sendSnapshot(
803 arg_req,
804 )
805 }
806 }
807
808 impl<'a, S, T> RaftexServiceExt<T> for S
809 where
810 S: ::std::convert::AsRef<dyn RaftexService + 'a>,
811 S: ::std::convert::AsRef<dyn RaftexServiceExt<T> + 'a>,
812 S: ::std::marker::Send,
813 T: ::fbthrift::Transport,
814 {
815 fn askForVote_with_rpc_opts(
816 &self,
817 arg_req: &crate::types::AskForVoteRequest,
818 rpc_options: T::RpcOptions,
819 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
820 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).askForVote_with_rpc_opts(
821 arg_req,
822 rpc_options,
823 )
824 }
825 fn appendLog_with_rpc_opts(
826 &self,
827 arg_req: &crate::types::AppendLogRequest,
828 rpc_options: T::RpcOptions,
829 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
830 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).appendLog_with_rpc_opts(
831 arg_req,
832 rpc_options,
833 )
834 }
835 fn sendSnapshot_with_rpc_opts(
836 &self,
837 arg_req: &crate::types::SendSnapshotRequest,
838 rpc_options: T::RpcOptions,
839 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
840 <Self as ::std::convert::AsRef<dyn RaftexServiceExt<T>>>::as_ref(self).sendSnapshot_with_rpc_opts(
841 arg_req,
842 rpc_options,
843 )
844 }
845 }
846
847 #[derive(Clone)]
848 pub struct make_RaftexService;
849
850 impl dyn RaftexService {
864 pub fn new<P, T>(
865 protocol: P,
866 transport: T,
867 ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
868 where
869 P: ::fbthrift::Protocol<Frame = T>,
870 T: ::fbthrift::Transport,
871 P::Deserializer: ::std::marker::Send,
872 {
873 let spawner = ::fbthrift::help::NoopSpawner;
874 Self::with_spawner(protocol, transport, spawner)
875 }
876
877 pub fn with_spawner<P, T, S>(
878 protocol: P,
879 transport: T,
880 spawner: S,
881 ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static>
882 where
883 P: ::fbthrift::Protocol<Frame = T>,
884 T: ::fbthrift::Transport,
885 P::Deserializer: ::std::marker::Send,
886 S: ::fbthrift::help::Spawner,
887 {
888 let _ = protocol;
889 let _ = spawner;
890 ::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
891 }
892 }
893
894 impl<T> dyn RaftexServiceExt<T>
895 where
896 T: ::fbthrift::Transport,
897 {
898 pub fn new<P>(
899 protocol: P,
900 transport: T,
901 ) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
902 where
903 P: ::fbthrift::Protocol<Frame = T>,
904 P::Deserializer: ::std::marker::Send,
905 {
906 let spawner = ::fbthrift::help::NoopSpawner;
907 Self::with_spawner(protocol, transport, spawner)
908 }
909
910 pub fn with_spawner<P, S>(
911 protocol: P,
912 transport: T,
913 spawner: S,
914 ) -> ::std::sync::Arc<impl RaftexServiceExt<T> + ::std::marker::Send + ::std::marker::Sync + 'static>
915 where
916 P: ::fbthrift::Protocol<Frame = T>,
917 P::Deserializer: ::std::marker::Send,
918 S: ::fbthrift::help::Spawner,
919 {
920 let _ = protocol;
921 let _ = spawner;
922 ::std::sync::Arc::new(RaftexServiceImpl::<P, T, S>::new(transport))
923 }
924 }
925
926 pub type RaftexServiceDynClient = <make_RaftexService as ::fbthrift::ClientFactory>::Api;
927 pub type RaftexServiceClient = ::std::sync::Arc<RaftexServiceDynClient>;
928
929 impl ::fbthrift::ClientFactory for make_RaftexService {
932 type Api = dyn RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static;
933
934 fn with_spawner<P, T, S>(protocol: P, transport: T, spawner: S) -> ::std::sync::Arc<Self::Api>
935 where
936 P: ::fbthrift::Protocol<Frame = T>,
937 T: ::fbthrift::Transport,
938 P::Deserializer: ::std::marker::Send,
939 S: ::fbthrift::help::Spawner,
940 {
941 <dyn RaftexService>::with_spawner(protocol, transport, spawner)
942 }
943 }
944
945}
946
947pub mod server {
949 #[::async_trait::async_trait]
950 pub trait RaftexService: ::std::marker::Send + ::std::marker::Sync + 'static {
951 async fn askForVote(
952 &self,
953 _req: crate::types::AskForVoteRequest,
954 ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
955 ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(
956 ::fbthrift::ApplicationException::unimplemented_method(
957 "RaftexService",
958 "askForVote",
959 ),
960 ))
961 }
962 async fn appendLog(
963 &self,
964 _req: crate::types::AppendLogRequest,
965 ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
966 ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(
967 ::fbthrift::ApplicationException::unimplemented_method(
968 "RaftexService",
969 "appendLog",
970 ),
971 ))
972 }
973 async fn sendSnapshot(
974 &self,
975 _req: crate::types::SendSnapshotRequest,
976 ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
977 ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(
978 ::fbthrift::ApplicationException::unimplemented_method(
979 "RaftexService",
980 "sendSnapshot",
981 ),
982 ))
983 }
984 }
985
986 #[::async_trait::async_trait]
987 impl<T> RaftexService for ::std::boxed::Box<T>
988 where
989 T: RaftexService + Send + Sync + ?Sized,
990 {
991 async fn askForVote(
992 &self,
993 req: crate::types::AskForVoteRequest,
994 ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
995 (**self).askForVote(
996 req,
997 ).await
998 }
999 async fn appendLog(
1000 &self,
1001 req: crate::types::AppendLogRequest,
1002 ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
1003 (**self).appendLog(
1004 req,
1005 ).await
1006 }
1007 async fn sendSnapshot(
1008 &self,
1009 req: crate::types::SendSnapshotRequest,
1010 ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
1011 (**self).sendSnapshot(
1012 req,
1013 ).await
1014 }
1015 }
1016
1017 #[derive(Clone, Debug)]
1019 pub struct RaftexServiceProcessor<P, H, R, RS> {
1020 service: H,
1021 supa: ::fbthrift::NullServiceProcessor<P, R, RS>,
1022 _phantom: ::std::marker::PhantomData<(P, H, R, RS)>,
1023 }
1024
1025 struct Args_RaftexService_askForVote {
1026 req: crate::types::AskForVoteRequest,
1027 }
1028 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_askForVote {
1029 #[inline]
1030 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.askForVote"))]
1031 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1032 static ARGS: &[::fbthrift::Field] = &[
1033 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1034 ];
1035 let mut field_req = ::std::option::Option::None;
1036 let _ = p.read_struct_begin(|_| ())?;
1037 loop {
1038 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1039 match (fty, fid as ::std::primitive::i32) {
1040 (::fbthrift::TType::Stop, _) => break,
1041 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1042 (fty, _) => p.skip(fty)?,
1043 }
1044 p.read_field_end()?;
1045 }
1046 p.read_struct_end()?;
1047 ::std::result::Result::Ok(Self {
1048 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.askForVote", "req"))?,
1049 })
1050 }
1051 }
1052
1053 struct Args_RaftexService_appendLog {
1054 req: crate::types::AppendLogRequest,
1055 }
1056 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_appendLog {
1057 #[inline]
1058 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.appendLog"))]
1059 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1060 static ARGS: &[::fbthrift::Field] = &[
1061 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1062 ];
1063 let mut field_req = ::std::option::Option::None;
1064 let _ = p.read_struct_begin(|_| ())?;
1065 loop {
1066 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1067 match (fty, fid as ::std::primitive::i32) {
1068 (::fbthrift::TType::Stop, _) => break,
1069 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1070 (fty, _) => p.skip(fty)?,
1071 }
1072 p.read_field_end()?;
1073 }
1074 p.read_struct_end()?;
1075 ::std::result::Result::Ok(Self {
1076 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.appendLog", "req"))?,
1077 })
1078 }
1079 }
1080
1081 struct Args_RaftexService_sendSnapshot {
1082 req: crate::types::SendSnapshotRequest,
1083 }
1084 impl<P: ::fbthrift::ProtocolReader> ::fbthrift::Deserialize<P> for self::Args_RaftexService_sendSnapshot {
1085 #[inline]
1086 #[::tracing::instrument(skip_all, level = "trace", name = "deserialize_args", fields(method = "RaftexService.sendSnapshot"))]
1087 fn read(p: &mut P) -> ::anyhow::Result<Self> {
1088 static ARGS: &[::fbthrift::Field] = &[
1089 ::fbthrift::Field::new("req", ::fbthrift::TType::Struct, 1),
1090 ];
1091 let mut field_req = ::std::option::Option::None;
1092 let _ = p.read_struct_begin(|_| ())?;
1093 loop {
1094 let (_, fty, fid) = p.read_field_begin(|_| (), ARGS)?;
1095 match (fty, fid as ::std::primitive::i32) {
1096 (::fbthrift::TType::Stop, _) => break,
1097 (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
1098 (fty, _) => p.skip(fty)?,
1099 }
1100 p.read_field_end()?;
1101 }
1102 p.read_struct_end()?;
1103 ::std::result::Result::Ok(Self {
1104 req: field_req.ok_or_else(|| ::anyhow::anyhow!("`{}` missing arg `{}`", "RaftexService.sendSnapshot", "req"))?,
1105 })
1106 }
1107 }
1108
1109
1110 impl<P, H, R, RS> RaftexServiceProcessor<P, H, R, RS>
1111 where
1112 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1113 P::Frame: ::std::marker::Send + 'static,
1114 P::Deserializer: ::std::marker::Send,
1115 H: RaftexService,
1116 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
1117 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static,
1118 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
1119 + ::std::marker::Send + ::std::marker::Sync,
1120 {
1121 pub fn new(service: H) -> Self {
1122 Self {
1123 service,
1124 supa: ::fbthrift::NullServiceProcessor::new(),
1125 _phantom: ::std::marker::PhantomData,
1126 }
1127 }
1128
1129 pub fn into_inner(self) -> H {
1130 self.service
1131 }
1132
1133 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.askForVote"))]
1134 async fn handle_askForVote<'a>(
1135 &'a self,
1136 p: &'a mut P::Deserializer,
1137 req_ctxt: &R,
1138 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1139 _seqid: ::std::primitive::u32,
1140 ) -> ::anyhow::Result<()> {
1141 use ::const_cstr::const_cstr;
1142 use ::futures::FutureExt as _;
1143
1144 const_cstr! {
1145 SERVICE_NAME = "RaftexService";
1146 METHOD_NAME = "RaftexService.askForVote";
1147 }
1148 let mut ctx_stack = req_ctxt.get_context_stack(
1149 SERVICE_NAME.as_cstr(),
1150 METHOD_NAME.as_cstr(),
1151 )?;
1152 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1153 let _args: self::Args_RaftexService_askForVote = ::fbthrift::Deserialize::read(p)?;
1154 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1155 protocol: P::PROTOCOL_ID,
1156 method_name: METHOD_NAME.as_cstr(),
1157 buffer: ::std::marker::PhantomData, })?;
1159 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1160
1161 let res = ::std::panic::AssertUnwindSafe(
1162 self.service.askForVote(
1163 _args.req,
1164 )
1165 )
1166 .catch_unwind()
1167 .await;
1168
1169 let res = match res {
1171 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1172 ::tracing::info!("success");
1173 crate::services::raftex_service::AskForVoteExn::Success(res)
1174 }
1175 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::Success(_))) => {
1176 panic!(
1177 "{} attempted to return success via error",
1178 "askForVote",
1179 )
1180 }
1181 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1182 ::tracing::error!(exception = ?exn);
1183 exn
1184 }
1185 ::std::result::Result::Err(exn) => {
1186 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.askForVote", exn);
1187 crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn)
1188 }
1189 };
1190
1191 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1192 "askForVote",
1193 METHOD_NAME.as_cstr(),
1194 _seqid,
1195 req_ctxt,
1196 &mut ctx_stack,
1197 res
1198 )?;
1199 reply_state.lock().unwrap().send_reply(env);
1200 Ok(())
1201 }
1202
1203 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.appendLog"))]
1204 async fn handle_appendLog<'a>(
1205 &'a self,
1206 p: &'a mut P::Deserializer,
1207 req_ctxt: &R,
1208 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1209 _seqid: ::std::primitive::u32,
1210 ) -> ::anyhow::Result<()> {
1211 use ::const_cstr::const_cstr;
1212 use ::futures::FutureExt as _;
1213
1214 const_cstr! {
1215 SERVICE_NAME = "RaftexService";
1216 METHOD_NAME = "RaftexService.appendLog";
1217 }
1218 let mut ctx_stack = req_ctxt.get_context_stack(
1219 SERVICE_NAME.as_cstr(),
1220 METHOD_NAME.as_cstr(),
1221 )?;
1222 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1223 let _args: self::Args_RaftexService_appendLog = ::fbthrift::Deserialize::read(p)?;
1224 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1225 protocol: P::PROTOCOL_ID,
1226 method_name: METHOD_NAME.as_cstr(),
1227 buffer: ::std::marker::PhantomData, })?;
1229 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1230
1231 let res = ::std::panic::AssertUnwindSafe(
1232 self.service.appendLog(
1233 _args.req,
1234 )
1235 )
1236 .catch_unwind()
1237 .await;
1238
1239 let res = match res {
1241 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1242 ::tracing::info!("success");
1243 crate::services::raftex_service::AppendLogExn::Success(res)
1244 }
1245 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::Success(_))) => {
1246 panic!(
1247 "{} attempted to return success via error",
1248 "appendLog",
1249 )
1250 }
1251 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1252 ::tracing::error!(exception = ?exn);
1253 exn
1254 }
1255 ::std::result::Result::Err(exn) => {
1256 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.appendLog", exn);
1257 crate::services::raftex_service::AppendLogExn::ApplicationException(aexn)
1258 }
1259 };
1260
1261 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1262 "appendLog",
1263 METHOD_NAME.as_cstr(),
1264 _seqid,
1265 req_ctxt,
1266 &mut ctx_stack,
1267 res
1268 )?;
1269 reply_state.lock().unwrap().send_reply(env);
1270 Ok(())
1271 }
1272
1273 #[::tracing::instrument(skip_all, name = "handler", fields(method = "RaftexService.sendSnapshot"))]
1274 async fn handle_sendSnapshot<'a>(
1275 &'a self,
1276 p: &'a mut P::Deserializer,
1277 req_ctxt: &R,
1278 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1279 _seqid: ::std::primitive::u32,
1280 ) -> ::anyhow::Result<()> {
1281 use ::const_cstr::const_cstr;
1282 use ::futures::FutureExt as _;
1283
1284 const_cstr! {
1285 SERVICE_NAME = "RaftexService";
1286 METHOD_NAME = "RaftexService.sendSnapshot";
1287 }
1288 let mut ctx_stack = req_ctxt.get_context_stack(
1289 SERVICE_NAME.as_cstr(),
1290 METHOD_NAME.as_cstr(),
1291 )?;
1292 ::fbthrift::ContextStack::pre_read(&mut ctx_stack)?;
1293 let _args: self::Args_RaftexService_sendSnapshot = ::fbthrift::Deserialize::read(p)?;
1294 ::fbthrift::ContextStack::on_read_data(&mut ctx_stack, &::fbthrift::SerializedMessage {
1295 protocol: P::PROTOCOL_ID,
1296 method_name: METHOD_NAME.as_cstr(),
1297 buffer: ::std::marker::PhantomData, })?;
1299 ::fbthrift::ContextStack::post_read(&mut ctx_stack, 0)?;
1300
1301 let res = ::std::panic::AssertUnwindSafe(
1302 self.service.sendSnapshot(
1303 _args.req,
1304 )
1305 )
1306 .catch_unwind()
1307 .await;
1308
1309 let res = match res {
1311 ::std::result::Result::Ok(::std::result::Result::Ok(res)) => {
1312 ::tracing::info!("success");
1313 crate::services::raftex_service::SendSnapshotExn::Success(res)
1314 }
1315 ::std::result::Result::Ok(::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::Success(_))) => {
1316 panic!(
1317 "{} attempted to return success via error",
1318 "sendSnapshot",
1319 )
1320 }
1321 ::std::result::Result::Ok(::std::result::Result::Err(exn)) => {
1322 ::tracing::error!(exception = ?exn);
1323 exn
1324 }
1325 ::std::result::Result::Err(exn) => {
1326 let aexn = ::fbthrift::ApplicationException::handler_panic("RaftexService.sendSnapshot", exn);
1327 crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn)
1328 }
1329 };
1330
1331 let env = ::fbthrift::help::serialize_result_envelope::<P, R, _>(
1332 "sendSnapshot",
1333 METHOD_NAME.as_cstr(),
1334 _seqid,
1335 req_ctxt,
1336 &mut ctx_stack,
1337 res
1338 )?;
1339 reply_state.lock().unwrap().send_reply(env);
1340 Ok(())
1341 }
1342 }
1343
1344 #[::async_trait::async_trait]
1345 impl<P, H, R, RS> ::fbthrift::ServiceProcessor<P> for RaftexServiceProcessor<P, H, R, RS>
1346 where
1347 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1348 P::Deserializer: ::std::marker::Send,
1349 H: RaftexService,
1350 P::Frame: ::std::marker::Send + 'static,
1351 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
1352 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
1353 + ::std::marker::Send + ::std::marker::Sync + 'static,
1354 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
1355 {
1356 type RequestContext = R;
1357 type ReplyState = RS;
1358
1359 #[inline]
1360 fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> {
1361 match name {
1362 b"askForVote" => ::std::result::Result::Ok(0usize),
1363 b"appendLog" => ::std::result::Result::Ok(1usize),
1364 b"sendSnapshot" => ::std::result::Result::Ok(2usize),
1365 _ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()),
1366 }
1367 }
1368
1369 #[allow(clippy::match_single_binding)]
1370 async fn handle_method(
1371 &self,
1372 idx: ::std::primitive::usize,
1373 _p: &mut P::Deserializer,
1374 _r: &R,
1375 _reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1376 _seqid: ::std::primitive::u32,
1377 ) -> ::anyhow::Result<()> {
1378 match idx {
1379 0usize => {
1380 self.handle_askForVote(_p, _r, _reply_state, _seqid).await
1381 }
1382 1usize => {
1383 self.handle_appendLog(_p, _r, _reply_state, _seqid).await
1384 }
1385 2usize => {
1386 self.handle_sendSnapshot(_p, _r, _reply_state, _seqid).await
1387 }
1388 bad => panic!(
1389 "{}: unexpected method idx {}",
1390 "RaftexServiceProcessor",
1391 bad
1392 ),
1393 }
1394 }
1395
1396 #[allow(clippy::match_single_binding)]
1397 #[inline]
1398 fn create_interaction_idx(&self, name: &str) -> ::anyhow::Result<::std::primitive::usize> {
1399 match name {
1400 _ => ::anyhow::bail!("Unknown interaction"),
1401 }
1402 }
1403
1404 #[allow(clippy::match_single_binding)]
1405 fn handle_create_interaction(
1406 &self,
1407 idx: ::std::primitive::usize,
1408 ) -> ::anyhow::Result<
1409 ::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = Self::RequestContext, ReplyState = Self::ReplyState> + ::std::marker::Send + 'static>
1410 > {
1411 match idx {
1412 bad => panic!(
1413 "{}: unexpected method idx {}",
1414 "RaftexServiceProcessor",
1415 bad
1416 ),
1417 }
1418 }
1419 }
1420
1421 #[::async_trait::async_trait]
1422 impl<P, H, R, RS> ::fbthrift::ThriftService<P::Frame> for RaftexServiceProcessor<P, H, R, RS>
1423 where
1424 P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
1425 P::Deserializer: ::std::marker::Send,
1426 P::Frame: ::std::marker::Send + 'static,
1427 H: RaftexService,
1428 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
1429 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = ::fbthrift::ProtocolDecoded<P>>
1430 + ::std::marker::Send + ::std::marker::Sync + 'static,
1431 RS: ::fbthrift::ReplyState<P::Frame, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
1432 {
1433 type Handler = H;
1434 type RequestContext = R;
1435 type ReplyState = RS;
1436
1437 #[tracing::instrument(level="trace", skip_all, fields(service = "RaftexService"))]
1438 async fn call(
1439 &self,
1440 req: ::fbthrift::ProtocolDecoded<P>,
1441 req_ctxt: &R,
1442 reply_state: ::std::sync::Arc<::std::sync::Mutex<RS>>,
1443 ) -> ::anyhow::Result<()> {
1444 use ::fbthrift::{BufExt as _, ProtocolReader as _, ServiceProcessor as _};
1445 let mut p = P::deserializer(req);
1446 let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?;
1447 if mty != ::fbthrift::MessageType::Call {
1448 return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new(
1449 ::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType,
1450 format!("message type {:?} not handled", mty)
1451 )));
1452 }
1453 let idx = match idx {
1454 ::std::result::Result::Ok(idx) => idx,
1455 ::std::result::Result::Err(_) => {
1456 let cur = P::into_buffer(p).reset();
1457 return self.supa.call(cur, req_ctxt, reply_state).await;
1458 }
1459 };
1460 self.handle_method(idx, &mut p, req_ctxt, reply_state, seqid).await?;
1461 p.read_message_end()?;
1462
1463 Ok(())
1464 }
1465
1466 fn create_interaction(
1467 &self,
1468 name: &str,
1469 ) -> ::anyhow::Result<
1470 ::std::sync::Arc<dyn ::fbthrift::ThriftService<P::Frame, Handler = (), RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>
1471 > {
1472 use ::fbthrift::{ServiceProcessor as _};
1473 let idx = self.create_interaction_idx(name);
1474 let idx = match idx {
1475 ::anyhow::Result::Ok(idx) => idx,
1476 ::anyhow::Result::Err(_) => {
1477 return self.supa.create_interaction(name);
1478 }
1479 };
1480 self.handle_create_interaction(idx)
1481 }
1482
1483 fn get_method_names(&self) -> &'static [&'static str] {
1484 &[
1485 "askForVote",
1487 "appendLog",
1488 "sendSnapshot",
1489 ]
1490 }
1491 }
1492
1493 #[::tracing::instrument(level="debug", skip_all, fields(proto = ?proto))]
1498 pub fn make_RaftexService_server<F, H, R, RS>(
1499 proto: ::fbthrift::ProtocolID,
1500 handler: H,
1501 ) -> ::std::result::Result<::std::boxed::Box<dyn ::fbthrift::ThriftService<F, Handler = H, RequestContext = R, ReplyState = RS> + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException>
1502 where
1503 F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static,
1504 H: RaftexService,
1505 R: ::fbthrift::RequestContext<Name = ::std::ffi::CStr> + ::std::marker::Send + ::std::marker::Sync + 'static,
1506 <R as ::fbthrift::RequestContext>::ContextStack: ::fbthrift::ContextStack<Name = R::Name, Buffer = F::DecBuf> + ::std::marker::Send + ::std::marker::Sync + 'static,
1507 RS: ::fbthrift::ReplyState<F, RequestContext = R> + ::std::marker::Send + ::std::marker::Sync + 'static
1508 {
1509 match proto {
1510 ::fbthrift::ProtocolID::BinaryProtocol => {
1511 ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::BinaryProtocol<F>, H, R, RS>::new(handler)))
1512 }
1513 ::fbthrift::ProtocolID::CompactProtocol => {
1514 ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::CompactProtocol<F>, H, R, RS>::new(handler)))
1515 }
1516 bad => {
1517 ::tracing::error!(method = "RaftexService.", invalid_protocol = ?bad);
1518 ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad))
1519 }
1520 }
1521 }
1522}
1523
1524pub mod mock {
1618 pub struct RaftexService<'mock> {
1619 pub askForVote: r#impl::raftex_service::askForVote<'mock>,
1620 pub appendLog: r#impl::raftex_service::appendLog<'mock>,
1621 pub sendSnapshot: r#impl::raftex_service::sendSnapshot<'mock>,
1622 _marker: ::std::marker::PhantomData<&'mock ()>,
1623 }
1624
1625 impl dyn super::client::RaftexService {
1626 pub fn mock<'mock>() -> RaftexService<'mock> {
1627 RaftexService {
1628 askForVote: r#impl::raftex_service::askForVote::unimplemented(),
1629 appendLog: r#impl::raftex_service::appendLog::unimplemented(),
1630 sendSnapshot: r#impl::raftex_service::sendSnapshot::unimplemented(),
1631 _marker: ::std::marker::PhantomData,
1632 }
1633 }
1634 }
1635
1636 impl<'mock> super::client::RaftexService for RaftexService<'mock> {
1637 fn askForVote(
1638 &self,
1639 arg_req: &crate::types::AskForVoteRequest,
1640 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> {
1641 let mut closure = self.askForVote.closure.lock().unwrap();
1642 let closure: &mut dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> _ = &mut **closure;
1643 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1644 }
1645 fn appendLog(
1646 &self,
1647 arg_req: &crate::types::AppendLogRequest,
1648 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> {
1649 let mut closure = self.appendLog.closure.lock().unwrap();
1650 let closure: &mut dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> _ = &mut **closure;
1651 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1652 }
1653 fn sendSnapshot(
1654 &self,
1655 arg_req: &crate::types::SendSnapshotRequest,
1656 ) -> ::futures::future::BoxFuture<'static, ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> {
1657 let mut closure = self.sendSnapshot.closure.lock().unwrap();
1658 let closure: &mut dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> _ = &mut **closure;
1659 ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
1660 }
1661 }
1662
1663 mod r#impl {
1664 pub mod raftex_service {
1665
1666 pub struct askForVote<'mock> {
1667 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1668 dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<
1669 crate::types::AskForVoteResponse,
1670 crate::errors::raftex_service::AskForVoteError,
1671 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1672 >>,
1673 }
1674
1675 #[allow(clippy::redundant_closure)]
1676 impl<'mock> askForVote<'mock> {
1677 pub fn unimplemented() -> Self {
1678 Self {
1679 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AskForVoteRequest| panic!(
1680 "{}::{} is not mocked",
1681 "RaftexService",
1682 "askForVote",
1683 ))),
1684 }
1685 }
1686
1687 pub fn ret(&self, value: crate::types::AskForVoteResponse) {
1688 self.mock(move |_: crate::types::AskForVoteRequest| value.clone());
1689 }
1690
1691 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> crate::types::AskForVoteResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1692 let mut closure = self.closure.lock().unwrap();
1693 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1694 }
1695
1696 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) {
1697 let mut closure = self.closure.lock().unwrap();
1698 *closure = ::std::boxed::Box::new(move |req| mock(req));
1699 }
1700
1701 pub fn throw<E>(&self, exception: E)
1702 where
1703 E: ::std::convert::Into<crate::errors::raftex_service::AskForVoteError>,
1704 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
1705 {
1706 let mut closure = self.closure.lock().unwrap();
1707 *closure = ::std::boxed::Box::new(move |_: crate::types::AskForVoteRequest| ::std::result::Result::Err(exception.clone().into()));
1708 }
1709 }
1710
1711 pub struct appendLog<'mock> {
1712 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1713 dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<
1714 crate::types::AppendLogResponse,
1715 crate::errors::raftex_service::AppendLogError,
1716 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1717 >>,
1718 }
1719
1720 #[allow(clippy::redundant_closure)]
1721 impl<'mock> appendLog<'mock> {
1722 pub fn unimplemented() -> Self {
1723 Self {
1724 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AppendLogRequest| panic!(
1725 "{}::{} is not mocked",
1726 "RaftexService",
1727 "appendLog",
1728 ))),
1729 }
1730 }
1731
1732 pub fn ret(&self, value: crate::types::AppendLogResponse) {
1733 self.mock(move |_: crate::types::AppendLogRequest| value.clone());
1734 }
1735
1736 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> crate::types::AppendLogResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1737 let mut closure = self.closure.lock().unwrap();
1738 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1739 }
1740
1741 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) {
1742 let mut closure = self.closure.lock().unwrap();
1743 *closure = ::std::boxed::Box::new(move |req| mock(req));
1744 }
1745
1746 pub fn throw<E>(&self, exception: E)
1747 where
1748 E: ::std::convert::Into<crate::errors::raftex_service::AppendLogError>,
1749 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
1750 {
1751 let mut closure = self.closure.lock().unwrap();
1752 *closure = ::std::boxed::Box::new(move |_: crate::types::AppendLogRequest| ::std::result::Result::Err(exception.clone().into()));
1753 }
1754 }
1755
1756 pub struct sendSnapshot<'mock> {
1757 pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
1758 dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<
1759 crate::types::SendSnapshotResponse,
1760 crate::errors::raftex_service::SendSnapshotError,
1761 > + ::std::marker::Send + ::std::marker::Sync + 'mock,
1762 >>,
1763 }
1764
1765 #[allow(clippy::redundant_closure)]
1766 impl<'mock> sendSnapshot<'mock> {
1767 pub fn unimplemented() -> Self {
1768 Self {
1769 closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::SendSnapshotRequest| panic!(
1770 "{}::{} is not mocked",
1771 "RaftexService",
1772 "sendSnapshot",
1773 ))),
1774 }
1775 }
1776
1777 pub fn ret(&self, value: crate::types::SendSnapshotResponse) {
1778 self.mock(move |_: crate::types::SendSnapshotRequest| value.clone());
1779 }
1780
1781 pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> crate::types::SendSnapshotResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
1782 let mut closure = self.closure.lock().unwrap();
1783 *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
1784 }
1785
1786 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) {
1787 let mut closure = self.closure.lock().unwrap();
1788 *closure = ::std::boxed::Box::new(move |req| mock(req));
1789 }
1790
1791 pub fn throw<E>(&self, exception: E)
1792 where
1793 E: ::std::convert::Into<crate::errors::raftex_service::SendSnapshotError>,
1794 E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
1795 {
1796 let mut closure = self.closure.lock().unwrap();
1797 *closure = ::std::boxed::Box::new(move |_: crate::types::SendSnapshotRequest| ::std::result::Result::Err(exception.clone().into()));
1798 }
1799 }
1800 }
1801 }
1802}
1803
1804pub mod errors {
1806 pub mod raftex_service {
1808
1809 pub type AskForVoteError = ::fbthrift::NonthrowingFunctionError;
1810
1811 impl ::std::convert::From<crate::services::raftex_service::AskForVoteExn> for
1812 ::std::result::Result<crate::types::AskForVoteResponse, AskForVoteError>
1813 {
1814 fn from(e: crate::services::raftex_service::AskForVoteExn) -> Self {
1815 match e {
1816 crate::services::raftex_service::AskForVoteExn::Success(res) => {
1817 ::std::result::Result::Ok(res)
1818 }
1819 crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn) =>
1820 ::std::result::Result::Err(AskForVoteError::ApplicationException(aexn)),
1821 }
1822 }
1823 }
1824
1825 pub type AppendLogError = ::fbthrift::NonthrowingFunctionError;
1826
1827 impl ::std::convert::From<crate::services::raftex_service::AppendLogExn> for
1828 ::std::result::Result<crate::types::AppendLogResponse, AppendLogError>
1829 {
1830 fn from(e: crate::services::raftex_service::AppendLogExn) -> Self {
1831 match e {
1832 crate::services::raftex_service::AppendLogExn::Success(res) => {
1833 ::std::result::Result::Ok(res)
1834 }
1835 crate::services::raftex_service::AppendLogExn::ApplicationException(aexn) =>
1836 ::std::result::Result::Err(AppendLogError::ApplicationException(aexn)),
1837 }
1838 }
1839 }
1840
1841 pub type SendSnapshotError = ::fbthrift::NonthrowingFunctionError;
1842
1843 impl ::std::convert::From<crate::services::raftex_service::SendSnapshotExn> for
1844 ::std::result::Result<crate::types::SendSnapshotResponse, SendSnapshotError>
1845 {
1846 fn from(e: crate::services::raftex_service::SendSnapshotExn) -> Self {
1847 match e {
1848 crate::services::raftex_service::SendSnapshotExn::Success(res) => {
1849 ::std::result::Result::Ok(res)
1850 }
1851 crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn) =>
1852 ::std::result::Result::Err(SendSnapshotError::ApplicationException(aexn)),
1853 }
1854 }
1855 }
1856
1857 }
1858
1859}