Skip to content

Commit

Permalink
tonic: Document Ascii and Binary
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.
  • Loading branch information
Adam Chalmers committed May 2, 2022
1 parent 2112ecc commit ca99f71
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tonic/src/metadata/encoding.rs
Expand Up @@ -51,11 +51,25 @@ 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)]
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)]
pub enum Binary {}

// ===== impl ValueEncoding =====
Expand Down

0 comments on commit ca99f71

Please sign in to comment.