From 2e19b660e547b8f405376116e974a962b651cc27 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Tue, 3 May 2022 11:09:15 -0500 Subject: [PATCH] tonic: Document Ascii and Binary (#993) This fixes the problem where MetadataValue::from (and other numeric types) aren't shown in Rustdoc, because they're implemented for Metadata, and Ascii is hidden. Co-authored-by: Adam Chalmers --- tonic/src/metadata/encoding.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tonic/src/metadata/encoding.rs b/tonic/src/metadata/encoding.rs index 106be4eab..657b2bf65 100644 --- a/tonic/src/metadata/encoding.rs +++ b/tonic/src/metadata/encoding.rs @@ -51,11 +51,27 @@ pub trait ValueEncoding: Clone + Eq + PartialEq + Hash + self::value_encoding::S fn is_valid_key(key: &str) -> bool; } +/// gRPC metadata values can be either ASCII strings or binary. Note that only +/// visible ASCII characters (32-127) are permitted. +/// This type should never be instantiated -- in fact, it's impossible +/// to, because there's no variants to instantiate. Instead, it's just used as +/// a type parameter for [`MetadataKey`] and [`MetadataValue`]. +/// +/// [`MetadataKey`]: struct.MetadataKey.html +/// [`MetadataValue`]: struct.MetadataValue.html #[derive(Clone, Debug, Eq, PartialEq, Hash)] -#[doc(hidden)] +#[non_exhaustive] pub enum Ascii {} + +/// gRPC metadata values can be either ASCII strings or binary. +/// This type should never be instantiated -- in fact, it's impossible +/// to, because there's no variants to instantiate. Instead, it's just used as +/// a type parameter for [`MetadataKey`] and [`MetadataValue`]. +/// +/// [`MetadataKey`]: struct.MetadataKey.html +/// [`MetadataValue`]: struct.MetadataValue.html #[derive(Clone, Debug, Eq, PartialEq, Hash)] -#[doc(hidden)] +#[non_exhaustive] pub enum Binary {} // ===== impl ValueEncoding =====