Skip to content

Commit

Permalink
tonic: Document Ascii and Binary (#993)
Browse files Browse the repository at this point in the history
This fixes the problem where MetadataValue::from<i16> (and other numeric types) aren't shown in Rustdoc, because they're implemented for Metadata<Ascii>, and Ascii is hidden.

Co-authored-by: Adam Chalmers <adamschalmers@gmail.com>
  • Loading branch information
adamchalmers and Adam Chalmers committed May 3, 2022
1 parent edc5a0d commit 2e19b66
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tonic/src/metadata/encoding.rs
Expand Up @@ -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 =====
Expand Down

0 comments on commit 2e19b66

Please sign in to comment.