1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#![recursion_limit = "1024"]
#![deny(warnings)]

macro_rules! bail_err {
    ($e:expr) => {
        return Err(From::from($e))
    };
}

macro_rules! ensure_err {
    ($cond:expr, $e:expr) => {
        if !$cond {
            bail_err!($e);
        }
    };
}

use anyhow::Result;

#[macro_use]
pub mod protocol;

pub mod adapter;
pub mod application_exception;
pub mod binary_protocol;
pub mod binary_type;
pub mod builtin_types;
pub mod compact_protocol;
pub mod context_stack;
pub mod deserialize;
pub mod export;
pub mod framing;
pub mod metadata;
pub mod processor;
pub mod request_context;
pub mod serialize;
pub mod simplejson_protocol;
pub mod thrift_protocol;
pub mod ttype;
pub mod uri;

mod bufext;
mod client;
mod errors;
mod exceptions;
mod varint;

#[cfg(test)]
mod tests;

#[doc(hidden)]
pub mod help;

pub mod types {
    // Define ApplicationException as if it were a normal generated type to make things simpler
    // for codegen.
    pub use crate::application_exception::ApplicationException;
}

pub use crate::application_exception::ApplicationException;
pub use crate::application_exception::ApplicationExceptionErrorCode;
pub use crate::binary_protocol::BinaryProtocol;
pub use crate::bufext::BufExt;
pub use crate::bufext::BufMutExt;
pub use crate::bufext::DeserializeSource;
pub use crate::client::ClientFactory;
pub use crate::client::ClientStreamElement;
pub use crate::client::Transport;
pub use crate::compact_protocol::CompactProtocol;
pub use crate::context_stack::ContextStack;
pub use crate::context_stack::DummyContextStack;
pub use crate::context_stack::SerializedMessage;
pub use crate::deserialize::Deserialize;
pub use crate::errors::NonthrowingFunctionError;
pub use crate::errors::ProtocolError;
pub use crate::exceptions::ExceptionInfo;
pub use crate::exceptions::ResultInfo;
pub use crate::exceptions::ResultType;
pub use crate::framing::Framing;
pub use crate::framing::FramingDecoded;
pub use crate::framing::FramingEncoded;
pub use crate::framing::FramingEncodedFinal;
pub use crate::help::NoopSpawner;
pub use crate::processor::NullServiceProcessor;
pub use crate::processor::ReplyState;
pub use crate::processor::SerializedStreamElement;
pub use crate::processor::ServiceProcessor;
pub use crate::processor::ThriftService;
pub use crate::protocol::Field;
pub use crate::protocol::Protocol;
pub use crate::protocol::ProtocolDecoded;
pub use crate::protocol::ProtocolEncoded;
pub use crate::protocol::ProtocolEncodedFinal;
pub use crate::protocol::ProtocolReader;
pub use crate::protocol::ProtocolWriter;
pub use crate::request_context::DummyRequestContext;
pub use crate::request_context::RequestContext;
pub use crate::serialize::Serialize;
pub use crate::simplejson_protocol::SimpleJsonProtocol;
pub use crate::thrift_protocol::MessageType;
pub use crate::thrift_protocol::ProtocolID;
pub use crate::ttype::GetTType;
pub use crate::ttype::TType;
pub use crate::uri::GetUri;

pub trait ThriftEnum: Sized {
    fn enumerate() -> &'static [(Self, &'static str)];

    fn variants() -> &'static [&'static str];

    fn variant_values() -> &'static [Self];
}