diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 8e0321c..a170d1e 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -11,7 +11,7 @@ tracing = "0.1" http = "0.1.14" base64 = "0.10" bytes = "0.4.7" -prost = "0.5" + percent-encoding = "1.0.1" tower-service = "=0.3.0-alpha.1" tokio-codec = "=0.2.0-alpha.4" @@ -19,6 +19,9 @@ async-stream = "0.1.1" http-body = "0.2.0-alpha.1" pin-project = "=0.4.0-alpha.11" +# prost +prost = { version = "0.5", optional = true } + # codegen async-trait = { version = "0.1.13", optional = true } @@ -39,7 +42,7 @@ openssl1 = { package = "openssl", version = "0.10", optional = true } tokio-rustls = { version = "0.12.0-alpha.2", optional = true } [features] -default = ["transport", "codegen"] +default = ["transport", "codegen", "prost"] codegen = ["async-trait"] transport = [ "hyper", diff --git a/tonic/src/client/mod.rs b/tonic/src/client/mod.rs index 091608e..3534058 100644 --- a/tonic/src/client/mod.rs +++ b/tonic/src/client/mod.rs @@ -1,4 +1,4 @@ -//! gRPC client implementation. +//! Generic client implementation. //! //! This module contains the low level components to build a gRPC client. It //! provides a codec agnostic gRPC client dispatcher and a decorated tower diff --git a/tonic/src/codec/mod.rs b/tonic/src/codec/mod.rs index 241afae..b75fea5 100644 --- a/tonic/src/codec/mod.rs +++ b/tonic/src/codec/mod.rs @@ -1,20 +1,22 @@ -//! gRPC encoding and decoding. +//! Generic encoding and decoding. //! //! This module contains the generic `Codec` trait and a protobuf codec //! based on prost. mod decode; mod encode; +#[cfg(feature = "prost")] mod prost; pub use self::decode::Streaming; pub(crate) use self::encode::{encode_client, encode_server}; +#[cfg(feature = "prost")] pub use self::prost::ProstCodec; pub use tokio_codec::{Decoder, Encoder}; use crate::Status; -/// Triat that knows how to encode and decode gRPC messages. +/// Trait that knows how to encode and decode gRPC messages. pub trait Codec { /// The encodable message. type Encode: Send + 'static; diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs index 639057a..a91b9dd 100644 --- a/tonic/src/lib.rs +++ b/tonic/src/lib.rs @@ -30,13 +30,14 @@ //! enabled by default. //! - `rustls`: Enables the `ruslts` based tls options for the `transport` feature`. Not //! enabled by default. +//! - `prost`: Enables the [`prost`] based gRPC [`Codec`] implementation. //! //! # Structure //! //! ## Generic implementation //! //! The main goal of [`tonic`] is to provide a generic gRPC implementation over http2.0 -//! framing. This means at the lowest level this library provides the ability to +//! framing. This means at the lowest level this library provides the ability to //! //! TODO: write generic implementation docs //! diff --git a/tonic/src/metadata/mod.rs b/tonic/src/metadata/mod.rs index 12c9c53..8389681 100644 --- a/tonic/src/metadata/mod.rs +++ b/tonic/src/metadata/mod.rs @@ -1,5 +1,4 @@ -//! The metadata module contains data structures and utilities for handling -//! gRPC custom metadata. +//! Contains data structures and utilities for handling gRPC custom metadata. mod encoding; mod key; diff --git a/tonic/src/server/mod.rs b/tonic/src/server/mod.rs index 7f6deb5..c1be1c2 100644 --- a/tonic/src/server/mod.rs +++ b/tonic/src/server/mod.rs @@ -1,9 +1,9 @@ -//! gRPC server implementation. +//! Generic server implementation. //! //! This module contains the low level components to build a gRPC server. It //! provides a codec agnostic gRPC server handler. //! -//! The items in this module are generally desgined to be used by some codegen +//! The items in this module are generally designed to be used by some codegen //! tool that will provide the user some custom way to implement the server that //! will implement the proper gRPC service. Thusly, they are a bit hard to use //! by hand.