• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
2 
3 /*!
4 
5 [grpcio] is a Rust implementation of [gRPC], which is a high performance, open source universal RPC
6 framework that puts mobile and HTTP/2 first. grpcio is built on [gRPC Core] and [futures-rs].
7 
8 [grpcio]: https://github.com/tikv/grpc-rs/
9 [gRPC]: https://grpc.io/
10 [gRPC Core]: https://github.com/grpc/grpc
11 [futures-rs]: https://github.com/rust-lang/futures-rs
12 
13 ## Optional features
14 
15 - **`secure`** *(enabled by default)* - Enables support for TLS encryption and some authentication
16   mechanisms.
17 
18 */
19 
20 #![allow(clippy::new_without_default)]
21 #![allow(clippy::new_without_default)]
22 #![allow(clippy::cast_lossless)]
23 #![allow(clippy::option_map_unit_fn)]
24 
25 use grpcio_sys as grpc_sys;
26 #[macro_use]
27 extern crate log;
28 
29 mod auth_context;
30 mod buf;
31 mod call;
32 mod channel;
33 mod client;
34 mod codec;
35 mod cq;
36 mod env;
37 mod error;
38 mod log_util;
39 mod metadata;
40 mod quota;
41 #[cfg(feature = "secure")]
42 mod security;
43 mod server;
44 mod task;
45 
46 pub use crate::buf::GrpcSlice;
47 pub use crate::call::client::{
48     CallOption, ClientCStreamReceiver, ClientCStreamSender, ClientDuplexReceiver,
49     ClientDuplexSender, ClientSStreamReceiver, ClientUnaryReceiver, StreamingCallSink,
50 };
51 pub use crate::call::server::{
52     ClientStreamingSink, ClientStreamingSinkResult, Deadline, DuplexSink, DuplexSinkFailure,
53     RequestStream, RpcContext, ServerStreamingSink, ServerStreamingSinkFailure, UnarySink,
54     UnarySinkResult,
55 };
56 pub use crate::call::{MessageReader, Method, MethodType, RpcStatus, RpcStatusCode, WriteFlags};
57 pub use crate::channel::{
58     Channel, ChannelBuilder, CompressionAlgorithms, CompressionLevel, ConnectivityState, LbPolicy,
59     OptTarget,
60 };
61 pub use crate::client::Client;
62 
63 #[cfg(feature = "protobuf-codec")]
64 pub use crate::codec::pb_codec::{de as pb_de, ser as pb_ser};
65 #[cfg(feature = "prost-codec")]
66 pub use crate::codec::pr_codec::{de as pr_de, ser as pr_ser};
67 
68 pub use crate::auth_context::{AuthContext, AuthProperty, AuthPropertyIter};
69 pub use crate::codec::{Marshaller, MAX_MESSAGE_SIZE};
70 pub use crate::env::{EnvBuilder, Environment};
71 pub use crate::error::{Error, Result};
72 pub use crate::log_util::redirect_log;
73 pub use crate::metadata::{Metadata, MetadataBuilder, MetadataIter};
74 pub use crate::quota::ResourceQuota;
75 #[cfg(feature = "secure")]
76 pub use crate::security::{
77     CertificateRequestType, ChannelCredentials, ChannelCredentialsBuilder, ServerCredentials,
78     ServerCredentialsBuilder, ServerCredentialsFetcher,
79 };
80 pub use crate::server::{
81     CheckResult, Server, ServerBuilder, ServerChecker, Service, ServiceBuilder, ShutdownFuture,
82 };
83 
84 /// A shortcut for implementing a service method by returning `UNIMPLEMENTED` status code.
85 ///
86 /// Compiler will provide a default implementations for all methods to invoke this macro, so
87 /// you usually won't call it directly. If you really need to, just call it like:
88 /// ```ignored
89 /// fn method(&self, ctx: grpcio::RpcContext, req: Request, resp: UnarySink<Response>) {
90 ///     unimplemented_call!(ctx, resp);
91 /// }
92 /// ```
93 #[macro_export]
94 macro_rules! unimplemented_call {
95     ($ctx:ident, $sink:ident) => {{
96         let f = async move {
97             let _ = $sink
98                 .fail($crate::RpcStatus::new($crate::RpcStatusCode::UNIMPLEMENTED))
99                 .await;
100         };
101         $ctx.spawn(f)
102     }};
103 }
104