nebula-graph-fbthrift-raftex 0.1.1

Nebula Graph raftex interface
Documentation
// @generated by Thrift. This file is probably not the place you want to edit!

#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals, unused_crate_dependencies)]

pub use self::errors::*;
pub use self::types::*;

pub mod types {
    #![allow(clippy::redundant_closure)]


    pub type TermID = ::std::primitive::i64;

    pub type LogID = ::std::primitive::i64;

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct AskForVoteRequest {
        pub space: common::types::GraphSpaceID,
        pub part: common::types::PartitionID,
        pub candidate_ip: common::types::IPv4,
        pub candidate_port: common::types::Port,
        pub term: crate::types::TermID,
        pub last_log_id: crate::types::LogID,
        pub last_log_term: crate::types::TermID,
    }

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct AskForVoteResponse {
        pub error_code: crate::types::ErrorCode,
    }

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct LogEntry {
        pub cluster: common::types::ClusterID,
        pub log_str: ::std::vec::Vec<::std::primitive::u8>,
    }

    #[derive(Clone, Debug, PartialEq)]
    pub struct AppendLogRequest {
        pub space: common::types::GraphSpaceID,
        pub part: common::types::PartitionID,
        pub current_term: crate::types::TermID,
        pub last_log_id: crate::types::LogID,
        pub committed_log_id: crate::types::LogID,
        pub leader_ip: common::types::IPv4,
        pub leader_port: common::types::Port,
        pub last_log_term_sent: crate::types::TermID,
        pub last_log_id_sent: crate::types::LogID,
        pub log_term: crate::types::TermID,
        pub log_str_list: ::std::vec::Vec<crate::types::LogEntry>,
        pub sending_snapshot: ::std::primitive::bool,
    }

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct AppendLogResponse {
        pub error_code: crate::types::ErrorCode,
        pub current_term: crate::types::TermID,
        pub leader_ip: common::types::IPv4,
        pub leader_port: common::types::Port,
        pub committed_log_id: crate::types::LogID,
        pub last_log_id: crate::types::LogID,
        pub last_log_term: crate::types::TermID,
    }

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct SendSnapshotRequest {
        pub space: common::types::GraphSpaceID,
        pub part: common::types::PartitionID,
        pub term: crate::types::TermID,
        pub committed_log_id: crate::types::LogID,
        pub committed_log_term: crate::types::TermID,
        pub leader_ip: common::types::IPv4,
        pub leader_port: common::types::Port,
        pub rows: ::std::vec::Vec<::std::vec::Vec<::std::primitive::u8>>,
        pub total_size: ::std::primitive::i64,
        pub total_count: ::std::primitive::i64,
        pub done: ::std::primitive::bool,
    }

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct SendSnapshotResponse {
        pub error_code: crate::types::ErrorCode,
    }

    #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
    pub struct ErrorCode(pub ::std::primitive::i32);

    impl ErrorCode {
        pub const SUCCEEDED: Self = ErrorCode(0i32);
        pub const E_LOG_GAP: Self = ErrorCode(-1i32);
        pub const E_LOG_STALE: Self = ErrorCode(-2i32);
        pub const E_MISSING_COMMIT: Self = ErrorCode(-3i32);
        pub const E_WAITING_SNAPSHOT: Self = ErrorCode(-4i32);
        pub const E_UNKNOWN_PART: Self = ErrorCode(-5i32);
        pub const E_TERM_OUT_OF_DATE: Self = ErrorCode(-6i32);
        pub const E_LAST_LOG_TERM_TOO_OLD: Self = ErrorCode(-7i32);
        pub const E_BAD_STATE: Self = ErrorCode(-8i32);
        pub const E_WRONG_LEADER: Self = ErrorCode(-9i32);
        pub const E_WAL_FAIL: Self = ErrorCode(-10i32);
        pub const E_NOT_READY: Self = ErrorCode(-11i32);
        pub const E_HOST_STOPPED: Self = ErrorCode(-12i32);
        pub const E_NOT_A_LEADER: Self = ErrorCode(-13i32);
        pub const E_HOST_DISCONNECTED: Self = ErrorCode(-14i32);
        pub const E_TOO_MANY_REQUESTS: Self = ErrorCode(-15i32);
        pub const E_PERSIST_SNAPSHOT_FAILED: Self = ErrorCode(-16i32);
        pub const E_BAD_ROLE: Self = ErrorCode(-17i32);
        pub const E_EXCEPTION: Self = ErrorCode(-20i32);

        pub fn variants() -> &'static [&'static str] {
            &[
                "SUCCEEDED",
                "E_LOG_GAP",
                "E_LOG_STALE",
                "E_MISSING_COMMIT",
                "E_WAITING_SNAPSHOT",
                "E_UNKNOWN_PART",
                "E_TERM_OUT_OF_DATE",
                "E_LAST_LOG_TERM_TOO_OLD",
                "E_BAD_STATE",
                "E_WRONG_LEADER",
                "E_WAL_FAIL",
                "E_NOT_READY",
                "E_HOST_STOPPED",
                "E_NOT_A_LEADER",
                "E_HOST_DISCONNECTED",
                "E_TOO_MANY_REQUESTS",
                "E_PERSIST_SNAPSHOT_FAILED",
                "E_BAD_ROLE",
                "E_EXCEPTION",
            ]
        }
    }

    impl ::std::default::Default for ErrorCode {
        fn default() -> Self {
            ErrorCode(::fbthrift::__UNKNOWN_ID)
        }
    }

    impl<'a> ::std::convert::From<&'a ErrorCode> for ::std::primitive::i32 {
        #[inline]
        fn from(x: &'a ErrorCode) -> Self {
            x.0
        }
    }

    impl ::std::convert::From<ErrorCode> for ::std::primitive::i32 {
        #[inline]
        fn from(x: ErrorCode) -> Self {
            x.0
        }
    }

    impl ::std::convert::From<::std::primitive::i32> for ErrorCode {
        #[inline]
        fn from(x: ::std::primitive::i32) -> Self {
            Self(x)
        }
    }

    impl ::std::fmt::Display for ErrorCode {
        fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            let s: &::std::primitive::str = match *self {
                ErrorCode::SUCCEEDED => "SUCCEEDED",
                ErrorCode::E_LOG_GAP => "E_LOG_GAP",
                ErrorCode::E_LOG_STALE => "E_LOG_STALE",
                ErrorCode::E_MISSING_COMMIT => "E_MISSING_COMMIT",
                ErrorCode::E_WAITING_SNAPSHOT => "E_WAITING_SNAPSHOT",
                ErrorCode::E_UNKNOWN_PART => "E_UNKNOWN_PART",
                ErrorCode::E_TERM_OUT_OF_DATE => "E_TERM_OUT_OF_DATE",
                ErrorCode::E_LAST_LOG_TERM_TOO_OLD => "E_LAST_LOG_TERM_TOO_OLD",
                ErrorCode::E_BAD_STATE => "E_BAD_STATE",
                ErrorCode::E_WRONG_LEADER => "E_WRONG_LEADER",
                ErrorCode::E_WAL_FAIL => "E_WAL_FAIL",
                ErrorCode::E_NOT_READY => "E_NOT_READY",
                ErrorCode::E_HOST_STOPPED => "E_HOST_STOPPED",
                ErrorCode::E_NOT_A_LEADER => "E_NOT_A_LEADER",
                ErrorCode::E_HOST_DISCONNECTED => "E_HOST_DISCONNECTED",
                ErrorCode::E_TOO_MANY_REQUESTS => "E_TOO_MANY_REQUESTS",
                ErrorCode::E_PERSIST_SNAPSHOT_FAILED => "E_PERSIST_SNAPSHOT_FAILED",
                ErrorCode::E_BAD_ROLE => "E_BAD_ROLE",
                ErrorCode::E_EXCEPTION => "E_EXCEPTION",
                ErrorCode(x) => return write!(fmt, "{}", x),
            };
            write!(fmt, "{}", s)
        }
    }

    impl ::std::fmt::Debug for ErrorCode {
        fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            write!(fmt, "ErrorCode::{}", self)
        }
    }

    impl ::std::str::FromStr for ErrorCode {
        type Err = ::anyhow::Error;

        fn from_str(string: &::std::primitive::str) -> ::std::result::Result<Self, Self::Err> {
            match string {
                "SUCCEEDED" => ::std::result::Result::Ok(ErrorCode::SUCCEEDED),
                "E_LOG_GAP" => ::std::result::Result::Ok(ErrorCode::E_LOG_GAP),
                "E_LOG_STALE" => ::std::result::Result::Ok(ErrorCode::E_LOG_STALE),
                "E_MISSING_COMMIT" => ::std::result::Result::Ok(ErrorCode::E_MISSING_COMMIT),
                "E_WAITING_SNAPSHOT" => ::std::result::Result::Ok(ErrorCode::E_WAITING_SNAPSHOT),
                "E_UNKNOWN_PART" => ::std::result::Result::Ok(ErrorCode::E_UNKNOWN_PART),
                "E_TERM_OUT_OF_DATE" => ::std::result::Result::Ok(ErrorCode::E_TERM_OUT_OF_DATE),
                "E_LAST_LOG_TERM_TOO_OLD" => ::std::result::Result::Ok(ErrorCode::E_LAST_LOG_TERM_TOO_OLD),
                "E_BAD_STATE" => ::std::result::Result::Ok(ErrorCode::E_BAD_STATE),
                "E_WRONG_LEADER" => ::std::result::Result::Ok(ErrorCode::E_WRONG_LEADER),
                "E_WAL_FAIL" => ::std::result::Result::Ok(ErrorCode::E_WAL_FAIL),
                "E_NOT_READY" => ::std::result::Result::Ok(ErrorCode::E_NOT_READY),
                "E_HOST_STOPPED" => ::std::result::Result::Ok(ErrorCode::E_HOST_STOPPED),
                "E_NOT_A_LEADER" => ::std::result::Result::Ok(ErrorCode::E_NOT_A_LEADER),
                "E_HOST_DISCONNECTED" => ::std::result::Result::Ok(ErrorCode::E_HOST_DISCONNECTED),
                "E_TOO_MANY_REQUESTS" => ::std::result::Result::Ok(ErrorCode::E_TOO_MANY_REQUESTS),
                "E_PERSIST_SNAPSHOT_FAILED" => ::std::result::Result::Ok(ErrorCode::E_PERSIST_SNAPSHOT_FAILED),
                "E_BAD_ROLE" => ::std::result::Result::Ok(ErrorCode::E_BAD_ROLE),
                "E_EXCEPTION" => ::std::result::Result::Ok(ErrorCode::E_EXCEPTION),
                _ => ::anyhow::bail!("Unable to parse {} as ErrorCode", string),
            }
        }
    }

    impl ::fbthrift::GetTType for ErrorCode {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::I32;
    }

    impl<P> ::fbthrift::Serialize<P> for ErrorCode
    where
        P: ::fbthrift::ProtocolWriter,
    {
        #[inline]
        fn write(&self, p: &mut P) {
            p.write_i32(self.into())
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for ErrorCode
    where
        P: ::fbthrift::ProtocolReader,
    {
        #[inline]
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            ::std::result::Result::Ok(ErrorCode::from(p.read_i32()?))
        }
    }



    impl ::std::default::Default for self::AskForVoteRequest {
        fn default() -> Self {
            Self {
                space: ::std::default::Default::default(),
                part: ::std::default::Default::default(),
                candidate_ip: ::std::default::Default::default(),
                candidate_port: ::std::default::Default::default(),
                term: ::std::default::Default::default(),
                last_log_id: ::std::default::Default::default(),
                last_log_term: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::AskForVoteRequest {}
    unsafe impl ::std::marker::Sync for self::AskForVoteRequest {}

    impl ::fbthrift::GetTType for self::AskForVoteRequest {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::AskForVoteRequest
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("AskForVoteRequest");
            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.space, p);
            p.write_field_end();
            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
            ::fbthrift::Serialize::write(&self.part, p);
            p.write_field_end();
            p.write_field_begin("candidate_ip", ::fbthrift::TType::I32, 3);
            ::fbthrift::Serialize::write(&self.candidate_ip, p);
            p.write_field_end();
            p.write_field_begin("candidate_port", ::fbthrift::TType::I32, 4);
            ::fbthrift::Serialize::write(&self.candidate_port, p);
            p.write_field_end();
            p.write_field_begin("term", ::fbthrift::TType::I64, 5);
            ::fbthrift::Serialize::write(&self.term, p);
            p.write_field_end();
            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 6);
            ::fbthrift::Serialize::write(&self.last_log_id, p);
            p.write_field_end();
            p.write_field_begin("last_log_term", ::fbthrift::TType::I64, 7);
            ::fbthrift::Serialize::write(&self.last_log_term, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::AskForVoteRequest
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_space = ::std::option::Option::None;
            let mut field_part = ::std::option::Option::None;
            let mut field_candidate_ip = ::std::option::Option::None;
            let mut field_candidate_port = ::std::option::Option::None;
            let mut field_term = ::std::option::Option::None;
            let mut field_last_log_id = ::std::option::Option::None;
            let mut field_last_log_term = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 3) => field_candidate_ip = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 4) => field_candidate_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 5) => field_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 6) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 7) => field_last_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                space: field_space.unwrap_or_default(),
                part: field_part.unwrap_or_default(),
                candidate_ip: field_candidate_ip.unwrap_or_default(),
                candidate_port: field_candidate_port.unwrap_or_default(),
                term: field_term.unwrap_or_default(),
                last_log_id: field_last_log_id.unwrap_or_default(),
                last_log_term: field_last_log_term.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::AskForVoteResponse {
        fn default() -> Self {
            Self {
                error_code: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::AskForVoteResponse {}
    unsafe impl ::std::marker::Sync for self::AskForVoteResponse {}

    impl ::fbthrift::GetTType for self::AskForVoteResponse {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::AskForVoteResponse
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("AskForVoteResponse");
            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.error_code, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::AskForVoteResponse
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_error_code = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                error_code: field_error_code.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::LogEntry {
        fn default() -> Self {
            Self {
                cluster: ::std::default::Default::default(),
                log_str: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::LogEntry {}
    unsafe impl ::std::marker::Sync for self::LogEntry {}

    impl ::fbthrift::GetTType for self::LogEntry {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::LogEntry
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("LogEntry");
            p.write_field_begin("cluster", ::fbthrift::TType::I64, 1);
            ::fbthrift::Serialize::write(&self.cluster, p);
            p.write_field_end();
            p.write_field_begin("log_str", ::fbthrift::TType::String, 2);
            ::fbthrift::Serialize::write(&self.log_str, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::LogEntry
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_cluster = ::std::option::Option::None;
            let mut field_log_str = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I64, 1) => field_cluster = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::String, 2) => field_log_str = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                cluster: field_cluster.unwrap_or_default(),
                log_str: field_log_str.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::AppendLogRequest {
        fn default() -> Self {
            Self {
                space: ::std::default::Default::default(),
                part: ::std::default::Default::default(),
                current_term: ::std::default::Default::default(),
                last_log_id: ::std::default::Default::default(),
                committed_log_id: ::std::default::Default::default(),
                leader_ip: ::std::default::Default::default(),
                leader_port: ::std::default::Default::default(),
                last_log_term_sent: ::std::default::Default::default(),
                last_log_id_sent: ::std::default::Default::default(),
                log_term: ::std::default::Default::default(),
                log_str_list: ::std::default::Default::default(),
                sending_snapshot: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::AppendLogRequest {}
    unsafe impl ::std::marker::Sync for self::AppendLogRequest {}

    impl ::fbthrift::GetTType for self::AppendLogRequest {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::AppendLogRequest
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("AppendLogRequest");
            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.space, p);
            p.write_field_end();
            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
            ::fbthrift::Serialize::write(&self.part, p);
            p.write_field_end();
            p.write_field_begin("current_term", ::fbthrift::TType::I64, 3);
            ::fbthrift::Serialize::write(&self.current_term, p);
            p.write_field_end();
            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 4);
            ::fbthrift::Serialize::write(&self.last_log_id, p);
            p.write_field_end();
            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 5);
            ::fbthrift::Serialize::write(&self.committed_log_id, p);
            p.write_field_end();
            p.write_field_begin("leader_ip", ::fbthrift::TType::I32, 6);
            ::fbthrift::Serialize::write(&self.leader_ip, p);
            p.write_field_end();
            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 7);
            ::fbthrift::Serialize::write(&self.leader_port, p);
            p.write_field_end();
            p.write_field_begin("last_log_term_sent", ::fbthrift::TType::I64, 8);
            ::fbthrift::Serialize::write(&self.last_log_term_sent, p);
            p.write_field_end();
            p.write_field_begin("last_log_id_sent", ::fbthrift::TType::I64, 9);
            ::fbthrift::Serialize::write(&self.last_log_id_sent, p);
            p.write_field_end();
            p.write_field_begin("log_term", ::fbthrift::TType::I64, 10);
            ::fbthrift::Serialize::write(&self.log_term, p);
            p.write_field_end();
            p.write_field_begin("log_str_list", ::fbthrift::TType::List, 11);
            ::fbthrift::Serialize::write(&self.log_str_list, p);
            p.write_field_end();
            p.write_field_begin("sending_snapshot", ::fbthrift::TType::Bool, 12);
            ::fbthrift::Serialize::write(&self.sending_snapshot, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::AppendLogRequest
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_space = ::std::option::Option::None;
            let mut field_part = ::std::option::Option::None;
            let mut field_current_term = ::std::option::Option::None;
            let mut field_last_log_id = ::std::option::Option::None;
            let mut field_committed_log_id = ::std::option::Option::None;
            let mut field_leader_ip = ::std::option::Option::None;
            let mut field_leader_port = ::std::option::Option::None;
            let mut field_last_log_term_sent = ::std::option::Option::None;
            let mut field_last_log_id_sent = ::std::option::Option::None;
            let mut field_log_term = ::std::option::Option::None;
            let mut field_log_str_list = ::std::option::Option::None;
            let mut field_sending_snapshot = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 3) => field_current_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 4) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 5) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 6) => field_leader_ip = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 7) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 8) => field_last_log_term_sent = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 9) => field_last_log_id_sent = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 10) => field_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::List, 11) => field_log_str_list = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::Bool, 12) => field_sending_snapshot = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                space: field_space.unwrap_or_default(),
                part: field_part.unwrap_or_default(),
                current_term: field_current_term.unwrap_or_default(),
                last_log_id: field_last_log_id.unwrap_or_default(),
                committed_log_id: field_committed_log_id.unwrap_or_default(),
                leader_ip: field_leader_ip.unwrap_or_default(),
                leader_port: field_leader_port.unwrap_or_default(),
                last_log_term_sent: field_last_log_term_sent.unwrap_or_default(),
                last_log_id_sent: field_last_log_id_sent.unwrap_or_default(),
                log_term: field_log_term.unwrap_or_default(),
                log_str_list: field_log_str_list.unwrap_or_default(),
                sending_snapshot: field_sending_snapshot.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::AppendLogResponse {
        fn default() -> Self {
            Self {
                error_code: ::std::default::Default::default(),
                current_term: ::std::default::Default::default(),
                leader_ip: ::std::default::Default::default(),
                leader_port: ::std::default::Default::default(),
                committed_log_id: ::std::default::Default::default(),
                last_log_id: ::std::default::Default::default(),
                last_log_term: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::AppendLogResponse {}
    unsafe impl ::std::marker::Sync for self::AppendLogResponse {}

    impl ::fbthrift::GetTType for self::AppendLogResponse {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::AppendLogResponse
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("AppendLogResponse");
            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.error_code, p);
            p.write_field_end();
            p.write_field_begin("current_term", ::fbthrift::TType::I64, 2);
            ::fbthrift::Serialize::write(&self.current_term, p);
            p.write_field_end();
            p.write_field_begin("leader_ip", ::fbthrift::TType::I32, 3);
            ::fbthrift::Serialize::write(&self.leader_ip, p);
            p.write_field_end();
            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 4);
            ::fbthrift::Serialize::write(&self.leader_port, p);
            p.write_field_end();
            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 5);
            ::fbthrift::Serialize::write(&self.committed_log_id, p);
            p.write_field_end();
            p.write_field_begin("last_log_id", ::fbthrift::TType::I64, 6);
            ::fbthrift::Serialize::write(&self.last_log_id, p);
            p.write_field_end();
            p.write_field_begin("last_log_term", ::fbthrift::TType::I64, 7);
            ::fbthrift::Serialize::write(&self.last_log_term, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::AppendLogResponse
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_error_code = ::std::option::Option::None;
            let mut field_current_term = ::std::option::Option::None;
            let mut field_leader_ip = ::std::option::Option::None;
            let mut field_leader_port = ::std::option::Option::None;
            let mut field_committed_log_id = ::std::option::Option::None;
            let mut field_last_log_id = ::std::option::Option::None;
            let mut field_last_log_term = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 2) => field_current_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 3) => field_leader_ip = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 4) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 5) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 6) => field_last_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 7) => field_last_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                error_code: field_error_code.unwrap_or_default(),
                current_term: field_current_term.unwrap_or_default(),
                leader_ip: field_leader_ip.unwrap_or_default(),
                leader_port: field_leader_port.unwrap_or_default(),
                committed_log_id: field_committed_log_id.unwrap_or_default(),
                last_log_id: field_last_log_id.unwrap_or_default(),
                last_log_term: field_last_log_term.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::SendSnapshotRequest {
        fn default() -> Self {
            Self {
                space: ::std::default::Default::default(),
                part: ::std::default::Default::default(),
                term: ::std::default::Default::default(),
                committed_log_id: ::std::default::Default::default(),
                committed_log_term: ::std::default::Default::default(),
                leader_ip: ::std::default::Default::default(),
                leader_port: ::std::default::Default::default(),
                rows: ::std::default::Default::default(),
                total_size: ::std::default::Default::default(),
                total_count: ::std::default::Default::default(),
                done: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::SendSnapshotRequest {}
    unsafe impl ::std::marker::Sync for self::SendSnapshotRequest {}

    impl ::fbthrift::GetTType for self::SendSnapshotRequest {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::SendSnapshotRequest
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("SendSnapshotRequest");
            p.write_field_begin("space", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.space, p);
            p.write_field_end();
            p.write_field_begin("part", ::fbthrift::TType::I32, 2);
            ::fbthrift::Serialize::write(&self.part, p);
            p.write_field_end();
            p.write_field_begin("term", ::fbthrift::TType::I64, 3);
            ::fbthrift::Serialize::write(&self.term, p);
            p.write_field_end();
            p.write_field_begin("committed_log_id", ::fbthrift::TType::I64, 4);
            ::fbthrift::Serialize::write(&self.committed_log_id, p);
            p.write_field_end();
            p.write_field_begin("committed_log_term", ::fbthrift::TType::I64, 5);
            ::fbthrift::Serialize::write(&self.committed_log_term, p);
            p.write_field_end();
            p.write_field_begin("leader_ip", ::fbthrift::TType::I32, 6);
            ::fbthrift::Serialize::write(&self.leader_ip, p);
            p.write_field_end();
            p.write_field_begin("leader_port", ::fbthrift::TType::I32, 7);
            ::fbthrift::Serialize::write(&self.leader_port, p);
            p.write_field_end();
            p.write_field_begin("rows", ::fbthrift::TType::List, 8);
            ::fbthrift::Serialize::write(&self.rows, p);
            p.write_field_end();
            p.write_field_begin("total_size", ::fbthrift::TType::I64, 9);
            ::fbthrift::Serialize::write(&self.total_size, p);
            p.write_field_end();
            p.write_field_begin("total_count", ::fbthrift::TType::I64, 10);
            ::fbthrift::Serialize::write(&self.total_count, p);
            p.write_field_end();
            p.write_field_begin("done", ::fbthrift::TType::Bool, 11);
            ::fbthrift::Serialize::write(&self.done, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::SendSnapshotRequest
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_space = ::std::option::Option::None;
            let mut field_part = ::std::option::Option::None;
            let mut field_term = ::std::option::Option::None;
            let mut field_committed_log_id = ::std::option::Option::None;
            let mut field_committed_log_term = ::std::option::Option::None;
            let mut field_leader_ip = ::std::option::Option::None;
            let mut field_leader_port = ::std::option::Option::None;
            let mut field_rows = ::std::option::Option::None;
            let mut field_total_size = ::std::option::Option::None;
            let mut field_total_count = ::std::option::Option::None;
            let mut field_done = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_space = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 2) => field_part = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 3) => field_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 4) => field_committed_log_id = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 5) => field_committed_log_term = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 6) => field_leader_ip = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I32, 7) => field_leader_port = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::List, 8) => field_rows = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 9) => field_total_size = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::I64, 10) => field_total_count = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (::fbthrift::TType::Bool, 11) => field_done = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                space: field_space.unwrap_or_default(),
                part: field_part.unwrap_or_default(),
                term: field_term.unwrap_or_default(),
                committed_log_id: field_committed_log_id.unwrap_or_default(),
                committed_log_term: field_committed_log_term.unwrap_or_default(),
                leader_ip: field_leader_ip.unwrap_or_default(),
                leader_port: field_leader_port.unwrap_or_default(),
                rows: field_rows.unwrap_or_default(),
                total_size: field_total_size.unwrap_or_default(),
                total_count: field_total_count.unwrap_or_default(),
                done: field_done.unwrap_or_default(),
            })
        }
    }


    impl ::std::default::Default for self::SendSnapshotResponse {
        fn default() -> Self {
            Self {
                error_code: ::std::default::Default::default(),
            }
        }
    }

    unsafe impl ::std::marker::Send for self::SendSnapshotResponse {}
    unsafe impl ::std::marker::Sync for self::SendSnapshotResponse {}

    impl ::fbthrift::GetTType for self::SendSnapshotResponse {
        const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
    }

    impl<P> ::fbthrift::Serialize<P> for self::SendSnapshotResponse
    where
        P: ::fbthrift::ProtocolWriter,
    {
        fn write(&self, p: &mut P) {
            p.write_struct_begin("SendSnapshotResponse");
            p.write_field_begin("error_code", ::fbthrift::TType::I32, 1);
            ::fbthrift::Serialize::write(&self.error_code, p);
            p.write_field_end();
            p.write_field_stop();
            p.write_struct_end();
        }
    }

    impl<P> ::fbthrift::Deserialize<P> for self::SendSnapshotResponse
    where
        P: ::fbthrift::ProtocolReader,
    {
        fn read(p: &mut P) -> ::anyhow::Result<Self> {
            let mut field_error_code = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::I32, 1) => field_error_code = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            ::std::result::Result::Ok(Self {
                error_code: field_error_code.unwrap_or_default(),
            })
        }
    }

}

pub mod dependencies {
    pub use common as common;
}

pub mod services {
    pub mod raftex_service {

        #[derive(Clone, Debug)]
        pub enum AskForVoteExn {
            Success(crate::types::AskForVoteResponse),
            ApplicationException(::fbthrift::ApplicationException),
        }

        impl ::std::convert::From<::fbthrift::ApplicationException> for AskForVoteExn {
            fn from(exn: ::fbthrift::ApplicationException) -> Self {
                AskForVoteExn::ApplicationException(exn)
            }
        }

        impl ::fbthrift::GetTType for AskForVoteExn {
            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
        }

        impl<P> ::fbthrift::Serialize<P> for AskForVoteExn
        where
            P: ::fbthrift::ProtocolWriter,
        {
            fn write(&self, p: &mut P) {
                p.write_struct_begin("AskForVote");
                match self {
                    AskForVoteExn::Success(inner) => {
                        p.write_field_begin(
                            "Success",
                            ::fbthrift::TType::Struct,
                            0i16,
                        );
                        inner.write(p);
                        p.write_field_end();
                    }
                    AskForVoteExn::ApplicationException(_) => panic!(
                        "Bad union Alt field {} id {}",
                        "ApplicationException",
                        -2147483648i32,
                    ),
                }
                p.write_field_stop();
                p.write_struct_end();
            }
        }

        impl<P> ::fbthrift::Deserialize<P> for AskForVoteExn
        where
            P: ::fbthrift::ProtocolReader,
        {
            fn read(p: &mut P) -> ::anyhow::Result<Self> {
                let _ = p.read_struct_begin(|_| ())?;
                let mut once = false;
                let mut alt = ::std::option::Option::None;
                loop {
                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
                    match ((fty, fid as ::std::primitive::i32), once) {
                        ((::fbthrift::TType::Stop, _), _) => {
                            p.read_field_end()?;
                            break;
                        }
                        ((::fbthrift::TType::Struct, 0i32), false) => {
                            once = true;
                            alt = ::std::option::Option::Some(AskForVoteExn::Success(::fbthrift::Deserialize::read(p)?));
                        }
                        ((ty, _id), false) => p.skip(ty)?,
                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
                            ::fbthrift::ApplicationException::new(
                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
                                format!(
                                    "unwanted extra union {} field ty {:?} id {}",
                                    "AskForVoteExn",
                                    badty,
                                    badid,
                                ),
                            )
                        )),
                    }
                    p.read_field_end()?;
                }
                p.read_struct_end()?;
                alt.ok_or_else(||
                    ::fbthrift::ApplicationException::new(
                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
                        format!("Empty union {}", "AskForVoteExn"),
                    )
                    .into(),
                )
            }
        }

        #[derive(Clone, Debug)]
        pub enum AppendLogExn {
            Success(crate::types::AppendLogResponse),
            ApplicationException(::fbthrift::ApplicationException),
        }

        impl ::std::convert::From<::fbthrift::ApplicationException> for AppendLogExn {
            fn from(exn: ::fbthrift::ApplicationException) -> Self {
                AppendLogExn::ApplicationException(exn)
            }
        }

        impl ::fbthrift::GetTType for AppendLogExn {
            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
        }

        impl<P> ::fbthrift::Serialize<P> for AppendLogExn
        where
            P: ::fbthrift::ProtocolWriter,
        {
            fn write(&self, p: &mut P) {
                p.write_struct_begin("AppendLog");
                match self {
                    AppendLogExn::Success(inner) => {
                        p.write_field_begin(
                            "Success",
                            ::fbthrift::TType::Struct,
                            0i16,
                        );
                        inner.write(p);
                        p.write_field_end();
                    }
                    AppendLogExn::ApplicationException(_) => panic!(
                        "Bad union Alt field {} id {}",
                        "ApplicationException",
                        -2147483648i32,
                    ),
                }
                p.write_field_stop();
                p.write_struct_end();
            }
        }

        impl<P> ::fbthrift::Deserialize<P> for AppendLogExn
        where
            P: ::fbthrift::ProtocolReader,
        {
            fn read(p: &mut P) -> ::anyhow::Result<Self> {
                let _ = p.read_struct_begin(|_| ())?;
                let mut once = false;
                let mut alt = ::std::option::Option::None;
                loop {
                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
                    match ((fty, fid as ::std::primitive::i32), once) {
                        ((::fbthrift::TType::Stop, _), _) => {
                            p.read_field_end()?;
                            break;
                        }
                        ((::fbthrift::TType::Struct, 0i32), false) => {
                            once = true;
                            alt = ::std::option::Option::Some(AppendLogExn::Success(::fbthrift::Deserialize::read(p)?));
                        }
                        ((ty, _id), false) => p.skip(ty)?,
                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
                            ::fbthrift::ApplicationException::new(
                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
                                format!(
                                    "unwanted extra union {} field ty {:?} id {}",
                                    "AppendLogExn",
                                    badty,
                                    badid,
                                ),
                            )
                        )),
                    }
                    p.read_field_end()?;
                }
                p.read_struct_end()?;
                alt.ok_or_else(||
                    ::fbthrift::ApplicationException::new(
                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
                        format!("Empty union {}", "AppendLogExn"),
                    )
                    .into(),
                )
            }
        }

        #[derive(Clone, Debug)]
        pub enum SendSnapshotExn {
            Success(crate::types::SendSnapshotResponse),
            ApplicationException(::fbthrift::ApplicationException),
        }

        impl ::std::convert::From<::fbthrift::ApplicationException> for SendSnapshotExn {
            fn from(exn: ::fbthrift::ApplicationException) -> Self {
                SendSnapshotExn::ApplicationException(exn)
            }
        }

        impl ::fbthrift::GetTType for SendSnapshotExn {
            const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
        }

        impl<P> ::fbthrift::Serialize<P> for SendSnapshotExn
        where
            P: ::fbthrift::ProtocolWriter,
        {
            fn write(&self, p: &mut P) {
                p.write_struct_begin("SendSnapshot");
                match self {
                    SendSnapshotExn::Success(inner) => {
                        p.write_field_begin(
                            "Success",
                            ::fbthrift::TType::Struct,
                            0i16,
                        );
                        inner.write(p);
                        p.write_field_end();
                    }
                    SendSnapshotExn::ApplicationException(_) => panic!(
                        "Bad union Alt field {} id {}",
                        "ApplicationException",
                        -2147483648i32,
                    ),
                }
                p.write_field_stop();
                p.write_struct_end();
            }
        }

        impl<P> ::fbthrift::Deserialize<P> for SendSnapshotExn
        where
            P: ::fbthrift::ProtocolReader,
        {
            fn read(p: &mut P) -> ::anyhow::Result<Self> {
                let _ = p.read_struct_begin(|_| ())?;
                let mut once = false;
                let mut alt = ::std::option::Option::None;
                loop {
                    let (_, fty, fid) = p.read_field_begin(|_| ())?;
                    match ((fty, fid as ::std::primitive::i32), once) {
                        ((::fbthrift::TType::Stop, _), _) => {
                            p.read_field_end()?;
                            break;
                        }
                        ((::fbthrift::TType::Struct, 0i32), false) => {
                            once = true;
                            alt = ::std::option::Option::Some(SendSnapshotExn::Success(::fbthrift::Deserialize::read(p)?));
                        }
                        ((ty, _id), false) => p.skip(ty)?,
                        ((badty, badid), true) => return ::std::result::Result::Err(::std::convert::From::from(
                            ::fbthrift::ApplicationException::new(
                                ::fbthrift::ApplicationExceptionErrorCode::ProtocolError,
                                format!(
                                    "unwanted extra union {} field ty {:?} id {}",
                                    "SendSnapshotExn",
                                    badty,
                                    badid,
                                ),
                            )
                        )),
                    }
                    p.read_field_end()?;
                }
                p.read_struct_end()?;
                alt.ok_or_else(||
                    ::fbthrift::ApplicationException::new(
                        ::fbthrift::ApplicationExceptionErrorCode::MissingResult,
                        format!("Empty union {}", "SendSnapshotExn"),
                    )
                    .into(),
                )
            }
        }
    }
}

pub mod client {

    pub struct RaftexServiceImpl<P, T> {
        transport: T,
        _phantom: ::std::marker::PhantomData<fn() -> P>,
    }

    impl<P, T> RaftexServiceImpl<P, T> {
        pub fn new(
            transport: T,
        ) -> Self {
            Self {
                transport,
                _phantom: ::std::marker::PhantomData,
            }
        }

        pub fn transport(&self) -> &T {
            &self.transport
        }
    }

    pub trait RaftexService: ::std::marker::Send {
        fn askForVote(
            &self,
            arg_req: &crate::types::AskForVoteRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>>;
        fn appendLog(
            &self,
            arg_req: &crate::types::AppendLogRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>>;
        fn sendSnapshot(
            &self,
            arg_req: &crate::types::SendSnapshotRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>>;
    }

    impl<P, T> RaftexService for RaftexServiceImpl<P, T>
    where
        P: ::fbthrift::Protocol,
        T: ::fbthrift::Transport,
        P::Frame: ::fbthrift::Framing<DecBuf = ::fbthrift::FramingDecoded<T>>,
        ::fbthrift::ProtocolEncoded<P>: ::fbthrift::BufMutExt<Final = ::fbthrift::FramingEncodedFinal<T>>,
    {        fn askForVote(
            &self,
            arg_req: &crate::types::AskForVoteRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
            use ::futures::future::{FutureExt as _, TryFutureExt as _};
            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "askForVote",
                ::fbthrift::MessageType::Call,
                // Note: we send a 0 message sequence ID from clients because
                // this field should not be used by the server (except for some
                // language implementations).
                0,
                |p| {
                    p.write_struct_begin("args");
                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
                    ::fbthrift::Serialize::write(&arg_req, p);
                    p.write_field_end();
                    p.write_field_stop();
                    p.write_struct_end();
                },
            ));
            self.transport()
                .call(request)
                .map_err(::std::convert::From::from)
                .and_then(|reply| ::futures::future::ready({
                    let de = P::deserializer(reply);
                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError> {
                        let p = &mut p;
                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
                        let result = match message_type {
                            ::fbthrift::MessageType::Reply => {
                                let exn: crate::services::raftex_service::AskForVoteExn = ::fbthrift::Deserialize::read(p)?;
                                match exn {
                                    crate::services::raftex_service::AskForVoteExn::Success(x) => ::std::result::Result::Ok(x),
                                    crate::services::raftex_service::AskForVoteExn::ApplicationException(ae) => {
                                        ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(ae))
                                    }
                                }
                            }
                            ::fbthrift::MessageType::Exception => {
                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
                                ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ApplicationException(ae))
                            }
                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
                                ::std::result::Result::Err(crate::errors::raftex_service::AskForVoteError::ThriftError(err))
                            }
                        };
                        p.read_message_end()?;
                        result
                    }(de)
                }))
                .boxed()
        }
        fn appendLog(
            &self,
            arg_req: &crate::types::AppendLogRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
            use ::futures::future::{FutureExt as _, TryFutureExt as _};
            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "appendLog",
                ::fbthrift::MessageType::Call,
                // Note: we send a 0 message sequence ID from clients because
                // this field should not be used by the server (except for some
                // language implementations).
                0,
                |p| {
                    p.write_struct_begin("args");
                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
                    ::fbthrift::Serialize::write(&arg_req, p);
                    p.write_field_end();
                    p.write_field_stop();
                    p.write_struct_end();
                },
            ));
            self.transport()
                .call(request)
                .map_err(::std::convert::From::from)
                .and_then(|reply| ::futures::future::ready({
                    let de = P::deserializer(reply);
                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError> {
                        let p = &mut p;
                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
                        let result = match message_type {
                            ::fbthrift::MessageType::Reply => {
                                let exn: crate::services::raftex_service::AppendLogExn = ::fbthrift::Deserialize::read(p)?;
                                match exn {
                                    crate::services::raftex_service::AppendLogExn::Success(x) => ::std::result::Result::Ok(x),
                                    crate::services::raftex_service::AppendLogExn::ApplicationException(ae) => {
                                        ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(ae))
                                    }
                                }
                            }
                            ::fbthrift::MessageType::Exception => {
                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
                                ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ApplicationException(ae))
                            }
                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
                                ::std::result::Result::Err(crate::errors::raftex_service::AppendLogError::ThriftError(err))
                            }
                        };
                        p.read_message_end()?;
                        result
                    }(de)
                }))
                .boxed()
        }
        fn sendSnapshot(
            &self,
            arg_req: &crate::types::SendSnapshotRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
            use ::fbthrift::{ProtocolReader as _, ProtocolWriter as _};
            use ::futures::future::{FutureExt as _, TryFutureExt as _};
            let request = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "sendSnapshot",
                ::fbthrift::MessageType::Call,
                // Note: we send a 0 message sequence ID from clients because
                // this field should not be used by the server (except for some
                // language implementations).
                0,
                |p| {
                    p.write_struct_begin("args");
                    p.write_field_begin("arg_req", ::fbthrift::TType::Struct, 1i16);
                    ::fbthrift::Serialize::write(&arg_req, p);
                    p.write_field_end();
                    p.write_field_stop();
                    p.write_struct_end();
                },
            ));
            self.transport()
                .call(request)
                .map_err(::std::convert::From::from)
                .and_then(|reply| ::futures::future::ready({
                    let de = P::deserializer(reply);
                    move |mut p: P::Deserializer| -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError> {
                        let p = &mut p;
                        let (_, message_type, _) = p.read_message_begin(|_| ())?;
                        let result = match message_type {
                            ::fbthrift::MessageType::Reply => {
                                let exn: crate::services::raftex_service::SendSnapshotExn = ::fbthrift::Deserialize::read(p)?;
                                match exn {
                                    crate::services::raftex_service::SendSnapshotExn::Success(x) => ::std::result::Result::Ok(x),
                                    crate::services::raftex_service::SendSnapshotExn::ApplicationException(ae) => {
                                        ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(ae))
                                    }
                                }
                            }
                            ::fbthrift::MessageType::Exception => {
                                let ae: ::fbthrift::ApplicationException = ::fbthrift::Deserialize::read(p)?;
                                ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ApplicationException(ae))
                            }
                            ::fbthrift::MessageType::Call | ::fbthrift::MessageType::Oneway | ::fbthrift::MessageType::InvalidMessageType => {
                                let err = ::anyhow::anyhow!("Unexpected message type {:?}", message_type);
                                ::std::result::Result::Err(crate::errors::raftex_service::SendSnapshotError::ThriftError(err))
                            }
                        };
                        p.read_message_end()?;
                        result
                    }(de)
                }))
                .boxed()
        }
    }

    impl<'a, T> RaftexService for T
    where
        T: ::std::convert::AsRef<dyn RaftexService + 'a>,
        T: ::std::marker::Send,
    {
        fn askForVote(
            &self,
            arg_req: &crate::types::AskForVoteRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
            self.as_ref().askForVote(
                arg_req,
            )
        }
        fn appendLog(
            &self,
            arg_req: &crate::types::AppendLogRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
            self.as_ref().appendLog(
                arg_req,
            )
        }
        fn sendSnapshot(
            &self,
            arg_req: &crate::types::SendSnapshotRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
            self.as_ref().sendSnapshot(
                arg_req,
            )
        }
    }

    pub struct make_RaftexService;

    /// To be called by user directly setting up a client. Avoids
    /// needing ClientFactory trait in scope, avoids unidiomatic
    /// make_Trait name.
    ///
    /// ```
    /// use bgs::client::BuckGraphService;
    ///
    /// let protocol = BinaryProtocol::new();
    /// let transport = HttpClient::new();
    /// let client = BuckGraphService::new(protocol, transport);
    /// ```
    impl dyn RaftexService {
        pub fn new<P, T>(
            protocol: P,
            transport: T,
        ) -> ::std::sync::Arc<impl RaftexService + ::std::marker::Send + 'static>
        where
            P: ::fbthrift::Protocol<Frame = T>,
            T: ::fbthrift::Transport,
        {
            let _ = protocol;
            ::std::sync::Arc::new(RaftexServiceImpl::<P, T>::new(transport))
        }
    }

    /// The same thing, but to be called from generic contexts where we are
    /// working with a type parameter `C: ClientFactory` to produce clients.
    impl ::fbthrift::ClientFactory for make_RaftexService {
        type Api = dyn RaftexService + ::std::marker::Send + ::std::marker::Sync + 'static;

        fn new<P, T>(protocol: P, transport: T) -> ::std::sync::Arc<Self::Api>
        where
            P: ::fbthrift::Protocol<Frame = T>,
            T: ::fbthrift::Transport + ::std::marker::Sync,
        {
            RaftexService::new(protocol, transport)
        }
    }
}

pub mod server {
    #[::async_trait::async_trait]
    pub trait RaftexService: ::std::marker::Send + ::std::marker::Sync + 'static {
        async fn askForVote(
            &self,
            _req: crate::types::AskForVoteRequest,
        ) -> ::std::result::Result<crate::types::AskForVoteResponse, crate::services::raftex_service::AskForVoteExn> {
            ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(
                ::fbthrift::ApplicationException::unimplemented_method(
                    "RaftexService",
                    "askForVote",
                ),
            ))
        }
        async fn appendLog(
            &self,
            _req: crate::types::AppendLogRequest,
        ) -> ::std::result::Result<crate::types::AppendLogResponse, crate::services::raftex_service::AppendLogExn> {
            ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(
                ::fbthrift::ApplicationException::unimplemented_method(
                    "RaftexService",
                    "appendLog",
                ),
            ))
        }
        async fn sendSnapshot(
            &self,
            _req: crate::types::SendSnapshotRequest,
        ) -> ::std::result::Result<crate::types::SendSnapshotResponse, crate::services::raftex_service::SendSnapshotExn> {
            ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(
                ::fbthrift::ApplicationException::unimplemented_method(
                    "RaftexService",
                    "sendSnapshot",
                ),
            ))
        }
    }

    #[derive(Clone, Debug)]
    pub struct RaftexServiceProcessor<P, H, R> {
        service: H,
        supa: ::fbthrift::NullServiceProcessor<P, R>,
        _phantom: ::std::marker::PhantomData<(P, H, R)>,
    }

    impl<P, H, R> RaftexServiceProcessor<P, H, R>
    where
        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
        P::Deserializer: ::std::marker::Send,
        H: RaftexService,
    {
        pub fn new(service: H) -> Self {
            Self {
                service,
                supa: ::fbthrift::NullServiceProcessor::new(),
                _phantom: ::std::marker::PhantomData,
            }
        }

        pub fn into_inner(self) -> H {
            self.service
        }

        async fn handle_askForVote<'a>(
            &'a self,
            p: &'a mut P::Deserializer,
            _req_ctxt: &R,
            seqid: ::std::primitive::u32,
        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
            use ::fbthrift::ProtocolReader as _;
            let mut field_req = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            let res = self.service.askForVote(
                field_req.ok_or_else(|| {
                    ::fbthrift::ApplicationException::missing_arg(
                        "askForVote",
                        "req",
                    )
                })?,
            ).await;
            let res = match res {
                ::std::result::Result::Ok(res) => {
                    crate::services::raftex_service::AskForVoteExn::Success(res)
                }
                ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::ApplicationException(aexn)) => {
                    return ::std::result::Result::Err(aexn.into())
                }
                ::std::result::Result::Err(crate::services::raftex_service::AskForVoteExn::Success(_)) => {
                    panic!(
                        "{} attempted to return success via error",
                        "askForVote",
                    )
                }
            };
            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "askForVote",
                ::fbthrift::MessageType::Reply,
                seqid,
                |p| ::fbthrift::Serialize::write(&res, p),
            ));
            ::std::result::Result::Ok(res)
        }

        async fn handle_appendLog<'a>(
            &'a self,
            p: &'a mut P::Deserializer,
            _req_ctxt: &R,
            seqid: ::std::primitive::u32,
        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
            use ::fbthrift::ProtocolReader as _;
            let mut field_req = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            let res = self.service.appendLog(
                field_req.ok_or_else(|| {
                    ::fbthrift::ApplicationException::missing_arg(
                        "appendLog",
                        "req",
                    )
                })?,
            ).await;
            let res = match res {
                ::std::result::Result::Ok(res) => {
                    crate::services::raftex_service::AppendLogExn::Success(res)
                }
                ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::ApplicationException(aexn)) => {
                    return ::std::result::Result::Err(aexn.into())
                }
                ::std::result::Result::Err(crate::services::raftex_service::AppendLogExn::Success(_)) => {
                    panic!(
                        "{} attempted to return success via error",
                        "appendLog",
                    )
                }
            };
            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "appendLog",
                ::fbthrift::MessageType::Reply,
                seqid,
                |p| ::fbthrift::Serialize::write(&res, p),
            ));
            ::std::result::Result::Ok(res)
        }

        async fn handle_sendSnapshot<'a>(
            &'a self,
            p: &'a mut P::Deserializer,
            _req_ctxt: &R,
            seqid: ::std::primitive::u32,
        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
            use ::fbthrift::ProtocolReader as _;
            let mut field_req = ::std::option::Option::None;
            let _ = p.read_struct_begin(|_| ())?;
            loop {
                let (_, fty, fid) = p.read_field_begin(|_| ())?;
                match (fty, fid as ::std::primitive::i32) {
                    (::fbthrift::TType::Stop, _) => break,
                    (::fbthrift::TType::Struct, 1) => field_req = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
                    (fty, _) => p.skip(fty)?,
                }
                p.read_field_end()?;
            }
            p.read_struct_end()?;
            let res = self.service.sendSnapshot(
                field_req.ok_or_else(|| {
                    ::fbthrift::ApplicationException::missing_arg(
                        "sendSnapshot",
                        "req",
                    )
                })?,
            ).await;
            let res = match res {
                ::std::result::Result::Ok(res) => {
                    crate::services::raftex_service::SendSnapshotExn::Success(res)
                }
                ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::ApplicationException(aexn)) => {
                    return ::std::result::Result::Err(aexn.into())
                }
                ::std::result::Result::Err(crate::services::raftex_service::SendSnapshotExn::Success(_)) => {
                    panic!(
                        "{} attempted to return success via error",
                        "sendSnapshot",
                    )
                }
            };
            let res = ::fbthrift::serialize!(P, |p| ::fbthrift::protocol::write_message(
                p,
                "sendSnapshot",
                ::fbthrift::MessageType::Reply,
                seqid,
                |p| ::fbthrift::Serialize::write(&res, p),
            ));
            ::std::result::Result::Ok(res)
        }
    }

    #[::async_trait::async_trait]
    impl<P, H, R> ::fbthrift::ServiceProcessor<P> for RaftexServiceProcessor<P, H, R>
    where
        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
        P::Deserializer: ::std::marker::Send,
        H: RaftexService,
        R: ::std::marker::Send + ::std::marker::Sync + 'static,
    {
        type RequestContext = R;

        #[inline]
        fn method_idx(&self, name: &[::std::primitive::u8]) -> ::std::result::Result<::std::primitive::usize, ::fbthrift::ApplicationException> {
            match name {
                b"askForVote" => ::std::result::Result::Ok(0usize),
                b"appendLog" => ::std::result::Result::Ok(1usize),
                b"sendSnapshot" => ::std::result::Result::Ok(2usize),
                _ => ::std::result::Result::Err(::fbthrift::ApplicationException::unknown_method()),
            }
        }

        async fn handle_method(
            &self,
            idx: ::std::primitive::usize,
            _p: &mut P::Deserializer,
            _r: &R,
            _seqid: ::std::primitive::u32,
        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
            match idx {
                0usize => self.handle_askForVote(_p, _r, _seqid).await,
                1usize => self.handle_appendLog(_p, _r, _seqid).await,
                2usize => self.handle_sendSnapshot(_p, _r, _seqid).await,
                bad => panic!(
                    "{}: unexpected method idx {}",
                    "RaftexServiceProcessor",
                    bad
                ),
            }
        }
    }

    #[::async_trait::async_trait]
    impl<P, H, R> ::fbthrift::ThriftService<P::Frame> for RaftexServiceProcessor<P, H, R>
    where
        P: ::fbthrift::Protocol + ::std::marker::Send + ::std::marker::Sync + 'static,
        P::Deserializer: ::std::marker::Send,
        P::Frame: ::std::marker::Send + 'static,
        H: RaftexService,
        R: ::std::marker::Send + ::std::marker::Sync + 'static,
    {
        type Handler = H;
        type RequestContext = R;

        async fn call(
            &self,
            req: ::fbthrift::ProtocolDecoded<P>,
            req_ctxt: &R,
        ) -> ::anyhow::Result<::fbthrift::ProtocolEncodedFinal<P>> {
            use ::fbthrift::{BufExt as _, ProtocolReader as _, ServiceProcessor as _};
            let mut p = P::deserializer(req);
            let (idx, mty, seqid) = p.read_message_begin(|name| self.method_idx(name))?;
            if mty != ::fbthrift::MessageType::Call {
                return ::std::result::Result::Err(::std::convert::From::from(::fbthrift::ApplicationException::new(
                    ::fbthrift::ApplicationExceptionErrorCode::InvalidMessageType,
                    format!("message type {:?} not handled", mty)
                )));
            }
            let idx = match idx {
                ::std::result::Result::Ok(idx) => idx,
                ::std::result::Result::Err(_) => {
                    let cur = P::into_buffer(p).reset();
                    return self.supa.call(cur, req_ctxt).await;
                }
            };
            let res = self.handle_method(idx, &mut p, req_ctxt, seqid).await;
            p.read_message_end()?;
            match res {
                ::std::result::Result::Ok(bytes) => ::std::result::Result::Ok(bytes),
                ::std::result::Result::Err(err) => match err.downcast_ref::<::fbthrift::ProtocolError>() {
                    ::std::option::Option::Some(::fbthrift::ProtocolError::ApplicationException(ae)) => {
                        let res = ::fbthrift::serialize!(P, |p| {
                            ::fbthrift::protocol::write_message(
                                p,
                                "RaftexServiceProcessor",
                                ::fbthrift::MessageType::Exception,
                                seqid,
                                |p| ::fbthrift::Serialize::write(&ae, p),
                            )
                        });
                        ::std::result::Result::Ok(res)
                    }
                    _ => ::std::result::Result::Err(err),
                },
            }
        }
    }

    pub fn make_RaftexService_server<F, H, R>(
        proto: ::fbthrift::ProtocolID,
        handler: H,
    ) -> ::std::result::Result<::std::boxed::Box<dyn ::fbthrift::ThriftService<F, Handler = H, RequestContext = R> + ::std::marker::Send + 'static>, ::fbthrift::ApplicationException>
    where
        F: ::fbthrift::Framing + ::std::marker::Send + ::std::marker::Sync + 'static,
        H: RaftexService,
        R: ::std::marker::Send + ::std::marker::Sync + 'static,
    {
        match proto {
            ::fbthrift::ProtocolID::BinaryProtocol => {
                ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::BinaryProtocol<F>, H, R>::new(handler)))
            }
            ::fbthrift::ProtocolID::CompactProtocol => {
                ::std::result::Result::Ok(::std::boxed::Box::new(RaftexServiceProcessor::<::fbthrift::CompactProtocol<F>, H, R>::new(handler)))
            }
            bad => ::std::result::Result::Err(::fbthrift::ApplicationException::invalid_protocol(bad)),
        }
    }
}

/// Client mocks. For every service, a struct mock::TheService that implements
/// client::TheService.
///
/// As an example of the generated API, for the following thrift service:
///
///     service MyService {
///         FunctionResponse myFunction(
///             1: FunctionRequest request,
///         ) throws {
///             1: StorageException s,
///             2: NotFoundException n,
///         ),
///
///         // other functions
///     }
///
///
/// we would end up with this mock object under crate::mock::MyService:
///
///     impl crate::client::MyService for MyService<'mock> {...}
///
///     pub struct MyService<'mock> {
///         pub myFunction: myFunction<'mock>,
///         // ...
///     }
///
///     impl dyn crate::client::MyService {
///         pub fn mock<'mock>() -> MyService<'mock>;
///     }
///
///     impl myFunction<'mock> {
///         // directly return the given success response
///         pub fn ret(&self, value: FunctionResponse);
///
///         // invoke closure to compute success response
///         pub fn mock(
///             &self,
///             mock: impl FnMut(FunctionRequest) -> FunctionResponse + Send + Sync + 'mock,
///         );
///
///         // return one of the function's declared exceptions
///         pub fn throw<E>(&self, exception: E)
///         where
///             E: Clone + Into<crate::services::MyService::MyFunctionExn> + Send + Sync + 'mock;
///     }
///
///     impl From<StorageException> for MyFunctionExn {...}
///     impl From<NotFoundException> for MyFunctionExn {...}
///
///
/// The intended usage from a test would be:
///
///     use std::sync::Arc;
///     use thrift_if::client::MyService;
///
///     #[test]
///     fn test_my_client() {
///         let mock = Arc::new(MyService::mock());
///
///         // directly return a success response
///         let resp = FunctionResponse {...};
///         mock.myFunction.ret(resp);
///
///         // or give a closure to compute the success response
///         mock.myFunction.mock(|request| FunctionResponse {...});
///
///         // or throw one of the function's exceptions
///         mock.myFunction.throw(StorageException::ItFailed);
///
///         let out = do_the_thing(mock).wait().unwrap();
///         assert!(out.what_i_expected());
///     }
///
///     fn do_the_thing(
///         client: Arc<dyn MyService + Send + Sync + 'static>,
///     ) -> impl Future<Item = Out> {...}
pub mod mock {
    pub struct RaftexService<'mock> {
        pub askForVote: r#impl::raftex_service::askForVote<'mock>,
        pub appendLog: r#impl::raftex_service::appendLog<'mock>,
        pub sendSnapshot: r#impl::raftex_service::sendSnapshot<'mock>,
        _marker: ::std::marker::PhantomData<&'mock ()>,
    }

    impl dyn super::client::RaftexService {
        pub fn mock<'mock>() -> RaftexService<'mock> {
            RaftexService {
                askForVote: r#impl::raftex_service::askForVote::unimplemented(),
                appendLog: r#impl::raftex_service::appendLog::unimplemented(),
                sendSnapshot: r#impl::raftex_service::sendSnapshot::unimplemented(),
                _marker: ::std::marker::PhantomData,
            }
        }
    }

    #[::async_trait::async_trait]
    impl<'mock> super::client::RaftexService for RaftexService<'mock> {
        fn askForVote(
            &self,
            arg_req: &crate::types::AskForVoteRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AskForVoteResponse, crate::errors::raftex_service::AskForVoteError>> + ::std::marker::Send + 'static>> {
            let mut closure = self.askForVote.closure.lock().unwrap();
            let closure: &mut dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> _ = &mut **closure;
            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
        }
        fn appendLog(
            &self,
            arg_req: &crate::types::AppendLogRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::AppendLogResponse, crate::errors::raftex_service::AppendLogError>> + ::std::marker::Send + 'static>> {
            let mut closure = self.appendLog.closure.lock().unwrap();
            let closure: &mut dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> _ = &mut **closure;
            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
        }
        fn sendSnapshot(
            &self,
            arg_req: &crate::types::SendSnapshotRequest,
        ) -> ::std::pin::Pin<::std::boxed::Box<dyn ::std::future::Future<Output = ::std::result::Result<crate::types::SendSnapshotResponse, crate::errors::raftex_service::SendSnapshotError>> + ::std::marker::Send + 'static>> {
            let mut closure = self.sendSnapshot.closure.lock().unwrap();
            let closure: &mut dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> _ = &mut **closure;
            ::std::boxed::Box::pin(::futures::future::ready(closure(arg_req.clone())))
        }
    }

    mod r#impl {
        pub mod raftex_service {

            pub struct askForVote<'mock> {
                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
                    dyn ::std::ops::FnMut(crate::types::AskForVoteRequest) -> ::std::result::Result<
                        crate::types::AskForVoteResponse,
                        crate::errors::raftex_service::AskForVoteError,
                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
                >>,
            }

            impl<'mock> askForVote<'mock> {
                pub fn unimplemented() -> Self {
                    askForVote {
                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AskForVoteRequest| panic!(
                            "{}::{} is not mocked",
                            "RaftexService",
                            "askForVote",
                        ))),
                    }
                }

                pub fn ret(&self, value: crate::types::AskForVoteResponse) {
                    self.mock(move |_: crate::types::AskForVoteRequest| value.clone());
                }

                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AskForVoteRequest) -> crate::types::AskForVoteResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
                }

                pub fn throw<E>(&self, exception: E)
                where
                    E: ::std::convert::Into<crate::errors::raftex_service::AskForVoteError>,
                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
                {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |_: crate::types::AskForVoteRequest| ::std::result::Result::Err(exception.clone().into()));
                }
            }

            pub struct appendLog<'mock> {
                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
                    dyn ::std::ops::FnMut(crate::types::AppendLogRequest) -> ::std::result::Result<
                        crate::types::AppendLogResponse,
                        crate::errors::raftex_service::AppendLogError,
                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
                >>,
            }

            impl<'mock> appendLog<'mock> {
                pub fn unimplemented() -> Self {
                    appendLog {
                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::AppendLogRequest| panic!(
                            "{}::{} is not mocked",
                            "RaftexService",
                            "appendLog",
                        ))),
                    }
                }

                pub fn ret(&self, value: crate::types::AppendLogResponse) {
                    self.mock(move |_: crate::types::AppendLogRequest| value.clone());
                }

                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::AppendLogRequest) -> crate::types::AppendLogResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
                }

                pub fn throw<E>(&self, exception: E)
                where
                    E: ::std::convert::Into<crate::errors::raftex_service::AppendLogError>,
                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
                {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |_: crate::types::AppendLogRequest| ::std::result::Result::Err(exception.clone().into()));
                }
            }

            pub struct sendSnapshot<'mock> {
                pub(crate) closure: ::std::sync::Mutex<::std::boxed::Box<
                    dyn ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> ::std::result::Result<
                        crate::types::SendSnapshotResponse,
                        crate::errors::raftex_service::SendSnapshotError,
                    > + ::std::marker::Send + ::std::marker::Sync + 'mock,
                >>,
            }

            impl<'mock> sendSnapshot<'mock> {
                pub fn unimplemented() -> Self {
                    sendSnapshot {
                        closure: ::std::sync::Mutex::new(::std::boxed::Box::new(|_: crate::types::SendSnapshotRequest| panic!(
                            "{}::{} is not mocked",
                            "RaftexService",
                            "sendSnapshot",
                        ))),
                    }
                }

                pub fn ret(&self, value: crate::types::SendSnapshotResponse) {
                    self.mock(move |_: crate::types::SendSnapshotRequest| value.clone());
                }

                pub fn mock(&self, mut mock: impl ::std::ops::FnMut(crate::types::SendSnapshotRequest) -> crate::types::SendSnapshotResponse + ::std::marker::Send + ::std::marker::Sync + 'mock) {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |req| ::std::result::Result::Ok(mock(req)));
                }

                pub fn throw<E>(&self, exception: E)
                where
                    E: ::std::convert::Into<crate::errors::raftex_service::SendSnapshotError>,
                    E: ::std::clone::Clone + ::std::marker::Send + ::std::marker::Sync + 'mock,
                {
                    let mut closure = self.closure.lock().unwrap();
                    *closure = ::std::boxed::Box::new(move |_: crate::types::SendSnapshotRequest| ::std::result::Result::Err(exception.clone().into()));
                }
            }
        }
    }
}

pub mod errors {
    pub mod raftex_service {

        pub type AskForVoteError = ::fbthrift::NonthrowingFunctionError;

        pub type AppendLogError = ::fbthrift::NonthrowingFunctionError;

        pub type SendSnapshotError = ::fbthrift::NonthrowingFunctionError;

    }

}