Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioFranco committed Oct 1, 2019
1 parent ca69b41 commit 08d8795
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 13 deletions.
Binary file added .github/assets/tonic-docs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tonic-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ proc-macro2 = "1.0"
default = ["transport", "rustfmt"]
rustfmt = []
transport = []

[package.metadata.docs.rs]
all-features = true
4 changes: 4 additions & 0 deletions tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ openssl1 = { package = "openssl", version = "0.10", optional = true }

# rustls
tokio-rustls = { version = "=0.12.0-alpha.4", optional = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
34 changes: 21 additions & 13 deletions tonic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
#![recursion_limit = "256"]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
#![doc(
html_logo_url = "https://github.com/LucioFranco/tonic/raw/master/.github/assets/tonic-docs.svg?sanitize=true"
)]
#![doc(html_root_url = "https://docs.rs/tonic/0.1.0-alpha.1")]
#![doc(test(no_crate_inject, attr(deny(rust_2018_idioms))))]

//! A Rust implementation of [gRPC], a high performance, open source, general
//! RPC framework that puts mobile and HTTP/2 first.
//!
Expand Down Expand Up @@ -60,6 +47,9 @@
//!
//! [gRPC]: https://grpc.io
//! [`tonic`]: https://github.com/hyperium/tonic
//! [`tokio`]: https://docs.rs/tokio
//! [`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
//! [`Codec`]: codec/trait.Codec.html
Expand All @@ -68,13 +58,29 @@
//! [`rustls`]: https://docs.rs/rustls
//! [`openssl`]: https://www.openssl.org
#![recursion_limit = "256"]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unreachable_pub
)]
#![doc(
html_logo_url = "https://github.com/LucioFranco/tonic/raw/master/.github/assets/tonic-docs.svg?sanitize=true"
)]
#![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))))]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod body;
pub mod client;
pub mod codec;
pub mod metadata;
pub mod server;

#[cfg(feature = "transport")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport")))]
pub mod transport;

mod macros;
Expand All @@ -84,6 +90,7 @@ mod status;

/// A re-export of [`async-trait`](https://docs.rs/async-trait) for use with codegen.
#[cfg(feature = "codegen")]
#[cfg_attr(docsrs, doc(cfg(feature = "codegen")))]
pub use async_trait::async_trait;

#[doc(inline)]
Expand All @@ -96,4 +103,5 @@ pub(crate) type Error = Box<dyn std::error::Error + Send + Sync>;

#[doc(hidden)]
#[cfg(feature = "codegen")]
#[cfg_attr(docsrs, doc(cfg(feature = "codegen")))]
pub mod codegen;
14 changes: 14 additions & 0 deletions tonic/src/transport/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ impl Endpoint {
self
}

/// Enable TLS and apply the CA as the root certificate.
///
/// Providing an optional domain to override. If `None` is passed to this
/// the TLS implementation will use the `Uri` that was used to create the
/// `Endpoint` builder.
///
/// ```no_run
/// # use tonic::transport::{Certificate, Endpoint};
/// # fn dothing() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -114,6 +120,7 @@ impl Endpoint {
/// # }
/// ```
#[cfg(feature = "openssl")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl_tls(&mut self, ca: Certificate, domain: impl Into<Option<String>>) -> &mut Self {
let domain = domain
.into()
Expand All @@ -123,6 +130,12 @@ impl Endpoint {
self
}

/// Enable TLS and apply the CA as the root certificate.
///
/// Providing an optional domain to override. If `None` is passed to this
/// the TLS implementation will use the `Uri` that was used to create the
/// `Endpoint` builder.
///
/// ```no_run
/// # use tonic::transport::{Certificate, Endpoint};
/// # fn dothing() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -136,6 +149,7 @@ impl Endpoint {
/// # }
/// ```
#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls_tls(&mut self, ca: Certificate, domain: impl Into<Option<String>>) -> &mut Self {
let domain = domain
.into()
Expand Down
2 changes: 2 additions & 0 deletions tonic/src/transport/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl Server {
/// # }
/// ```
#[cfg(feature = "openssl")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl")))]
pub fn openssl_tls(&mut self, identity: Identity) -> &mut Self {
let acceptor = TlsAcceptor::new_with_openssl(identity).unwrap();
self.tls = Some(acceptor);
Expand All @@ -95,6 +96,7 @@ impl Server {
/// # }
/// ```
#[cfg(feature = "rustls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls")))]
pub fn rustls_tls(&mut self, identity: Identity) -> &mut Self {
let acceptor = TlsAcceptor::new_with_rustls(identity).unwrap();
self.tls = Some(acceptor);
Expand Down

0 comments on commit 08d8795

Please sign in to comment.