diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ce9c448 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# 0.1.0-alpha.1 (October 1, 2019) + +- Initial release diff --git a/tonic-build/Cargo.toml b/tonic-build/Cargo.toml index 805f295..a5a85a5 100644 --- a/tonic-build/Cargo.toml +++ b/tonic-build/Cargo.toml @@ -1,8 +1,18 @@ [package] name = "tonic-build" -version = "0.1.0" +version = "0.1.0-alpha.1" authors = ["Lucio Franco "] edition = "2018" +documentation = "https://docs.rs/tonic/0.1.0-alpha.1/tonic/" +repository = "https://github.com/hyperium/tonic" +homepage = "https://github.com/hyperium/tonic" +description = """ +Codegen module of `tonic` gRPC implementation. +""" +readme = "README.md" +categories = ["network-programming", "asynchronous"] +keywords = ["rpc", "grpc", "async", "codegen", "protobuf"] + [dependencies] prost-build = "0.5" diff --git a/tonic-build/README.md b/tonic-build/README.md new file mode 100644 index 0000000..9920c71 --- /dev/null +++ b/tonic-build/README.md @@ -0,0 +1,44 @@ +# tonic-build + +Compiles proto files via prost and generates service stubs and proto definitiones for use with tonic. + +## Features + +- rustfmt: This feature enables the use of rustfmt to format the output code this makes the code readable and the error messages nice. This requires that rustfmt is installed. This is enabled by default. + +Required dependencies + +```toml +[dependencies] +bytes = +tonic = +prost = + +[build-dependencies] +tonic-build = +``` + +## Examples + +### Simple + +```rust +fn main() -> Result<(), Box> { + tonic_build::compile_protos("proto/service.proto")?; + Ok(()) +} +``` + +### Configuration + +```rust +fn main() -> Result<(), Box> { + tonic_build::configure() + .build_server(false) + .compile( + &["proto/helloworld/helloworld.proto"], + &["proto/helloworld"], + )?; + Ok(()) +} +``` diff --git a/tonic-build/src/lib.rs b/tonic-build/src/lib.rs index 9d04a2a..696c933 100644 --- a/tonic-build/src/lib.rs +++ b/tonic-build/src/lib.rs @@ -3,8 +3,9 @@ //! //! # Features //! -//! `tonic-build` only comes with one `rustfmt` feature which enables the usage of -//! the `rustfmt` binary to format the generated code. This is enabled by default. +//! - `rustfmt`: This feature enables the use of `rustfmt` to format the output code +//! this makes the code readable and the error messages nice. This requires that `rustfmt` +//! is installed. This is enabled by default. //! //! # Required dependencies //! @@ -42,6 +43,20 @@ //! } //! ``` +#![recursion_limit = "256"] +#![warn( + missing_debug_implementations, + missing_docs, + rust_2018_idioms, + unreachable_pub +)] +#![doc( + html_logo_url = "https://github.com/hyperium/tonic/raw/master/.github/assets/tonic-docs.png" +)] +#![doc(html_root_url = "https://docs.rs/tonic/0.1.0-alpha.1")] +#![doc(issue_tracker_base_url = "https://github.com/hyperium/tonic/issues/")] +#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))] + use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream}; use prost_build::Config; use quote::TokenStreamExt; @@ -56,7 +71,8 @@ use std::{ mod client; mod service; -#[derive(Clone)] +/// Service generator builder. +#[derive(Debug, Clone)] pub struct Builder { build_client: bool, build_server: bool, @@ -152,7 +168,7 @@ fn fmt(out_dir: &str) { } } -pub struct ServiceGenerator { +struct ServiceGenerator { builder: Builder, clients: TokenStream, servers: TokenStream, diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 9ac49a6..65c3a2c 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -14,7 +14,7 @@ edition = "2018" license = "MIT" documentation = "https://docs.rs/tonic/0.1.0-alpha.1/tonic/" repository = "https://github.com/hyperium/tonic" -homepage = "https://tokio.rs" +homepage = "https://github.com/hyperium/tonic" description = """ A gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility. """ diff --git a/tonic/src/lib.rs b/tonic/src/lib.rs index 939d562..6084a38 100644 --- a/tonic/src/lib.rs +++ b/tonic/src/lib.rs @@ -48,15 +48,18 @@ //! [gRPC]: https://grpc.io //! [`tonic`]: https://github.com/hyperium/tonic //! [`tokio`]: https://docs.rs/tokio +//! [`prost`]: https://docs.rs/prost //! [`hyper`]: https://docs.rs/hyper //! [`tower`]: https://docs.rs/tower //! [`tonic-build`]: https://docs.rs/tonic-build -//! [`tonic-examples`]: https://github.com/hyperium/tonic/tree/master/tonic-examples/src +//! [`tonic-examples`]: https://github.com/hyperium/tonic/tree/master/tonic-examples //! [`Codec`]: codec/trait.Codec.html //! [`Channel`]: transport/struct.Channel.html //! [`Server`]: transport/struct.Server.html //! [`rustls`]: https://docs.rs/rustls //! [`openssl`]: https://www.openssl.org +//! [`client`]: client/index.html +//! [`transport`]: transport/index.html #![recursion_limit = "256"] #![warn( diff --git a/tonic/src/macros.rs b/tonic/src/macros.rs index ca90cd1..72e6dac 100644 --- a/tonic/src/macros.rs +++ b/tonic/src/macros.rs @@ -1,6 +1,12 @@ /// Include generated proto server and client items. /// /// You must specify the gRPC package name. +/// +/// ```rust,ignore +/// mod pb { +/// tonic::include_proto("hellworld"); +/// } +/// ``` #[macro_export] macro_rules! include_proto { ($package: tt) => {