1 //! A collection of useful protobuf types that can be used with `tonic`. 2 //! 3 //! This crate also introduces the [`StatusExt`] trait and implements it in 4 //! [`tonic::Status`], allowing the implementation of the 5 //! [gRPC Richer Error Model] with [`tonic`] in a convenient way. 6 //! 7 //! [`tonic::Status`]: https://docs.rs/tonic/latest/tonic/struct.Status.html 8 //! [`tonic`]: https://docs.rs/tonic/latest/tonic/ 9 //! [gRPC Richer Error Model]: https://www.grpc.io/docs/guides/error/ 10 11 #![warn( 12 missing_debug_implementations, 13 missing_docs, 14 rust_2018_idioms, 15 unreachable_pub 16 )] 17 #![doc( 18 html_logo_url = "https://raw.githubusercontent.com/tokio-rs/website/master/public/img/icons/tonic.svg" 19 )] 20 #![deny(rustdoc::broken_intra_doc_links)] 21 #![doc(html_root_url = "https://docs.rs/tonic-types/0.6.1")] 22 #![doc(issue_tracker_base_url = "https://github.com/hyperium/tonic/issues/")] 23 24 /// Useful protobuf types 25 pub mod pb { 26 #![allow(rustdoc::invalid_html_tags)] 27 include!("generated/google.rpc.rs"); 28 29 /// Byte encoded FILE_DESCRIPTOR_SET. 30 pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("generated/types.bin"); 31 32 #[cfg(test)] 33 mod tests { 34 use super::FILE_DESCRIPTOR_SET; 35 use prost::Message as _; 36 37 #[test] 38 fn file_descriptor_set_is_valid() { 39 prost_types::FileDescriptorSet::decode(FILE_DESCRIPTOR_SET).unwrap(); 40 } 41 } 42 } 43 44 pub use pb::Status; 45 46 mod richer_error; 47 48 pub use richer_error::{ 49 BadRequest, DebugInfo, ErrorDetail, ErrorDetails, FieldViolation, QuotaFailure, QuotaViolation, 50 RetryInfo, StatusExt, 51 }; 52 53 mod sealed { 54 #[allow(unreachable_pub)] 55 pub trait Sealed {} 56 } 57