{"action":"created","comment":{"url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/comments/234318885","pull_request_review_id":175942025,"id":234318885,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNDMxODg4NQ==","diff_hunk":"@@ -0,0 +1,1716 @@\n+use http;\n+use metadata_key::InvalidMetadataKey;\n+use metadata_key::MetadataKey;\n+use metadata_value::MetadataValue;\n+\n+pub use self::as_metadata_key::AsMetadataKey;\n+pub use self::into_metadata_key::IntoMetadataKey;\n+\n+/// A set of gRPC custom metadata entries.\n+///\n+/// # Examples\n+///\n+/// Basic usage\n+///\n+/// ```\n+/// # use tower_grpc::metadata::*;\n+/// let mut map = MetadataMap::new();\n+///\n+/// map.insert(\"x-host\", \"example.com\".parse().unwrap());\n+/// map.insert(\"x-number\", \"123\".parse().unwrap());\n+///\n+/// assert!(map.contains_key(\"x-host\"));\n+/// assert!(!map.contains_key(\"x-location\"));\n+///\n+/// assert_eq!(map.get(\"x-host\").unwrap(), \"example.com\");\n+///\n+/// map.remove(\"x-host\");\n+///\n+/// assert!(!map.contains_key(\"x-host\"));\n+/// ```\n+#[derive(Clone, Debug, Default)]\n+pub struct MetadataMap {\n+    headers: http::HeaderMap<MetadataValue>,\n+}\n+\n+/// `HeaderMap` entry iterator.\n+///\n+/// Yields `(&HeaderName, &value)` tuples. The same header name may be yielded\n+/// more than once if it has more than one associated value.\n+#[derive(Debug)]\n+pub struct Iter<'a, T: 'a> {\n+    inner: http::header::Iter<'a, T>,\n+}\n+\n+/// A drain iterator of all values associated with a single metadata key.\n+#[derive(Debug)]\n+pub struct ValueDrain<'a, T: 'a> {\n+    inner: http::header::ValueDrain<'a, T>,\n+}\n+\n+/// A drain iterator for `MetadataMap`.\n+#[derive(Debug)]\n+pub struct Drain<'a, T: 'a> {\n+    inner: http::header::Drain<'a, T>,\n+}\n+\n+/// An iterator over `MetadataMap` keys.\n+///\n+/// Each header name is yielded only once, even if it has more than one\n+/// associated value.\n+#[derive(Debug)]\n+pub struct Keys<'a, T: 'a> {\n+    inner: http::header::Keys<'a, T>,\n+}\n+\n+/// `MetadataMap` value iterator.\n+///\n+/// Each value contained in the `MetadataMap` will be yielded.\n+#[derive(Debug)]\n+pub struct Values<'a, T: 'a> {\n+    inner: http::header::Values<'a, T>,\n+}\n+\n+/// An iterator of all values associated with a single metadata key.\n+#[derive(Debug)]\n+pub struct ValueIter<'a, T: 'a> {\n+    inner: http::header::ValueIter<'a, T>,\n+}\n+\n+/// An iterator of all values associated with a single metadata key.\n+#[derive(Debug)]\n+pub struct ValueIterMut<'a, T: 'a> {\n+    inner: http::header::ValueIterMut<'a, T>,\n+}\n+\n+/// A view to all values stored in a single entry.\n+///\n+/// This struct is returned by `MetadataMap::get_all`.\n+#[derive(Debug)]\n+pub struct GetAll<'a> {\n+    inner: http::header::GetAll<'a, MetadataValue>\n+}\n+\n+/// A view into a single location in a `MetadataMap`, which may be vacant or occupied.\n+#[derive(Debug)]\n+pub enum Entry<'a, T: 'a> {\n+    /// An occupied entry\n+    Occupied(OccupiedEntry<'a, T>),\n+\n+    /// A vacant entry\n+    Vacant(VacantEntry<'a, T>),\n+}\n+\n+/// A view into a single empty location in a `MetadataMap`.\n+///\n+/// This struct is returned as part of the `Entry` enum.\n+#[derive(Debug)]\n+pub struct VacantEntry<'a, T: 'a> {\n+    inner: http::header::VacantEntry<'a, T>,\n+}\n+\n+/// A view into a single occupied location in a `MetadataMap`.\n+///\n+/// This struct is returned as part of the `Entry` enum.\n+#[derive(Debug)]\n+pub struct OccupiedEntry<'a, T: 'a> {\n+    inner: http::header::OccupiedEntry<'a, T>,\n+}\n+\n+// ===== impl MetadataMap =====\n+\n+impl MetadataMap {\n+    /// Create an empty `MetadataMap`.\n+    ///\n+    /// The map will be created without any capacity. This function will not\n+    /// allocate.\n+    ///\n+    /// # Examples\n+    ///\n+    /// ```\n+    /// # use tower_grpc::metadata::*;\n+    /// let map = MetadataMap::new();\n+    ///\n+    /// assert!(map.is_empty());\n+    /// assert_eq!(0, map.capacity());\n+    /// ```\n+    pub fn new() -> Self {\n+        MetadataMap::with_capacity(0)\n+    }\n+\n+    /// Convert an HTTP HeaderMap to a MetadataMap\n+    pub fn from_headers(mut headers: http::HeaderMap) -> Self {","path":"src/metadata_map.rs","position":142,"original_position":142,"commit_id":"480d4f11cb5a614e12770cae82211a6189468f91","original_commit_id":"a282359a9f32eb37fa60c49be98c02d2bbc105c3","user":{"login":"carllerche","id":6180,"node_id":"MDQ6VXNlcjYxODA=","avatar_url":"https://avatars3.githubusercontent.com/u/6180?v=4","gravatar_id":"","url":"https://api.github.com/users/carllerche","html_url":"https://github.com/carllerche","followers_url":"https://api.github.com/users/carllerche/followers","following_url":"https://api.github.com/users/carllerche/following{/other_user}","gists_url":"https://api.github.com/users/carllerche/gists{/gist_id}","starred_url":"https://api.github.com/users/carllerche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carllerche/subscriptions","organizations_url":"https://api.github.com/users/carllerche/orgs","repos_url":"https://api.github.com/users/carllerche/repos","events_url":"https://api.github.com/users/carllerche/events{/privacy}","received_events_url":"https://api.github.com/users/carllerche/received_events","type":"User","site_admin":false},"body":"I mean... it doesn't seem terrible to have conversions. Being able to easily convert between the two does not violate \"hiding\".","created_at":"2018-11-16T19:17:17Z","updated_at":"2018-11-16T19:42:35Z","html_url":"https://github.com/tower-rs/tower-grpc/pull/92#discussion_r234318885","pull_request_url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/comments/234318885"},"html":{"href":"https://github.com/tower-rs/tower-grpc/pull/92#discussion_r234318885"},"pull_request":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92"}},"in_reply_to_id":232048328},"pull_request":{"url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92","id":229443849,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NDQzODQ5","html_url":"https://github.com/tower-rs/tower-grpc/pull/92","diff_url":"https://github.com/tower-rs/tower-grpc/pull/92.diff","patch_url":"https://github.com/tower-rs/tower-grpc/pull/92.patch","issue_url":"https://api.github.com/repos/tower-rs/tower-grpc/issues/92","number":92,"state":"open","locked":false,"title":"Introduce tower_grpc::metadata::MetadataMap type","user":{"login":"per-gron","id":87926,"node_id":"MDQ6VXNlcjg3OTI2","avatar_url":"https://avatars3.githubusercontent.com/u/87926?v=4","gravatar_id":"","url":"https://api.github.com/users/per-gron","html_url":"https://github.com/per-gron","followers_url":"https://api.github.com/users/per-gron/followers","following_url":"https://api.github.com/users/per-gron/following{/other_user}","gists_url":"https://api.github.com/users/per-gron/gists{/gist_id}","starred_url":"https://api.github.com/users/per-gron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-gron/subscriptions","organizations_url":"https://api.github.com/users/per-gron/orgs","repos_url":"https://api.github.com/users/per-gron/repos","events_url":"https://api.github.com/users/per-gron/events{/privacy}","received_events_url":"https://api.github.com/users/per-gron/received_events","type":"User","site_admin":false},"body":"As per the discussion in #90, it wraps http::HeaderMap to abstract away the fact that tower-grpc is HTTP based. At this time this class is a pure wrapper that does not actually implement any of the gRPC metadata specific stuff (such as binary fields), that will come later.\r\n\r\nMy goal with this PR is to make `MetadataMap` (largely) equivalent to `HeaderMap` while not exposing http types.\r\n","created_at":"2018-11-08T17:11:39Z","updated_at":"2018-11-16T19:42:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"01ef4de423c9537865a0e8e3b7def56c16cda70f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92/commits","review_comments_url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92/comments","review_comment_url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tower-rs/tower-grpc/issues/92/comments","statuses_url":"https://api.github.com/repos/tower-rs/tower-grpc/statuses/480d4f11cb5a614e12770cae82211a6189468f91","head":{"label":"per-gron:request-metadata","ref":"request-metadata","sha":"480d4f11cb5a614e12770cae82211a6189468f91","user":{"login":"per-gron","id":87926,"node_id":"MDQ6VXNlcjg3OTI2","avatar_url":"https://avatars3.githubusercontent.com/u/87926?v=4","gravatar_id":"","url":"https://api.github.com/users/per-gron","html_url":"https://github.com/per-gron","followers_url":"https://api.github.com/users/per-gron/followers","following_url":"https://api.github.com/users/per-gron/following{/other_user}","gists_url":"https://api.github.com/users/per-gron/gists{/gist_id}","starred_url":"https://api.github.com/users/per-gron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-gron/subscriptions","organizations_url":"https://api.github.com/users/per-gron/orgs","repos_url":"https://api.github.com/users/per-gron/repos","events_url":"https://api.github.com/users/per-gron/events{/privacy}","received_events_url":"https://api.github.com/users/per-gron/received_events","type":"User","site_admin":false},"repo":{"id":141156476,"node_id":"MDEwOlJlcG9zaXRvcnkxNDExNTY0NzY=","name":"tower-grpc","full_name":"per-gron/tower-grpc","private":false,"owner":{"login":"per-gron","id":87926,"node_id":"MDQ6VXNlcjg3OTI2","avatar_url":"https://avatars3.githubusercontent.com/u/87926?v=4","gravatar_id":"","url":"https://api.github.com/users/per-gron","html_url":"https://github.com/per-gron","followers_url":"https://api.github.com/users/per-gron/followers","following_url":"https://api.github.com/users/per-gron/following{/other_user}","gists_url":"https://api.github.com/users/per-gron/gists{/gist_id}","starred_url":"https://api.github.com/users/per-gron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/per-gron/subscriptions","organizations_url":"https://api.github.com/users/per-gron/orgs","repos_url":"https://api.github.com/users/per-gron/repos","events_url":"https://api.github.com/users/per-gron/events{/privacy}","received_events_url":"https://api.github.com/users/per-gron/received_events","type":"User","site_admin":false},"html_url":"https://github.com/per-gron/tower-grpc","description":"A gRPC client & server implementation.","fork":true,"url":"https://api.github.com/repos/per-gron/tower-grpc","forks_url":"https://api.github.com/repos/per-gron/tower-grpc/forks","keys_url":"https://api.github.com/repos/per-gron/tower-grpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/per-gron/tower-grpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/per-gron/tower-grpc/teams","hooks_url":"https://api.github.com/repos/per-gron/tower-grpc/hooks","issue_events_url":"https://api.github.com/repos/per-gron/tower-grpc/issues/events{/number}","events_url":"https://api.github.com/repos/per-gron/tower-grpc/events","assignees_url":"https://api.github.com/repos/per-gron/tower-grpc/assignees{/user}","branches_url":"https://api.github.com/repos/per-gron/tower-grpc/branches{/branch}","tags_url":"https://api.github.com/repos/per-gron/tower-grpc/tags","blobs_url":"https://api.github.com/repos/per-gron/tower-grpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/per-gron/tower-grpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/per-gron/tower-grpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/per-gron/tower-grpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/per-gron/tower-grpc/statuses/{sha}","languages_url":"https://api.github.com/repos/per-gron/tower-grpc/languages","stargazers_url":"https://api.github.com/repos/per-gron/tower-grpc/stargazers","contributors_url":"https://api.github.com/repos/per-gron/tower-grpc/contributors","subscribers_url":"https://api.github.com/repos/per-gron/tower-grpc/subscribers","subscription_url":"https://api.github.com/repos/per-gron/tower-grpc/subscription","commits_url":"https://api.github.com/repos/per-gron/tower-grpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/per-gron/tower-grpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/per-gron/tower-grpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/per-gron/tower-grpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/per-gron/tower-grpc/contents/{+path}","compare_url":"https://api.github.com/repos/per-gron/tower-grpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/per-gron/tower-grpc/merges","archive_url":"https://api.github.com/repos/per-gron/tower-grpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/per-gron/tower-grpc/downloads","issues_url":"https://api.github.com/repos/per-gron/tower-grpc/issues{/number}","pulls_url":"https://api.github.com/repos/per-gron/tower-grpc/pulls{/number}","milestones_url":"https://api.github.com/repos/per-gron/tower-grpc/milestones{/number}","notifications_url":"https://api.github.com/repos/per-gron/tower-grpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/per-gron/tower-grpc/labels{/name}","releases_url":"https://api.github.com/repos/per-gron/tower-grpc/releases{/id}","deployments_url":"https://api.github.com/repos/per-gron/tower-grpc/deployments","created_at":"2018-07-16T15:18:19Z","updated_at":"2018-07-16T15:18:22Z","pushed_at":"2018-11-16T18:21:38Z","git_url":"git://github.com/per-gron/tower-grpc.git","ssh_url":"git@github.com:per-gron/tower-grpc.git","clone_url":"https://github.com/per-gron/tower-grpc.git","svn_url":"https://github.com/per-gron/tower-grpc","homepage":null,"size":1265,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tower-rs:master","ref":"master","sha":"40b059abac9ca07edac252f4d0b69c55f6ecf88d","user":{"login":"tower-rs","id":26263939,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYzOTM5","avatar_url":"https://avatars0.githubusercontent.com/u/26263939?v=4","gravatar_id":"","url":"https://api.github.com/users/tower-rs","html_url":"https://github.com/tower-rs","followers_url":"https://api.github.com/users/tower-rs/followers","following_url":"https://api.github.com/users/tower-rs/following{/other_user}","gists_url":"https://api.github.com/users/tower-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tower-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tower-rs/subscriptions","organizations_url":"https://api.github.com/users/tower-rs/orgs","repos_url":"https://api.github.com/users/tower-rs/repos","events_url":"https://api.github.com/users/tower-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tower-rs/received_events","type":"Organization","site_admin":false},"repo":{"id":113232134,"node_id":"MDEwOlJlcG9zaXRvcnkxMTMyMzIxMzQ=","name":"tower-grpc","full_name":"tower-rs/tower-grpc","private":false,"owner":{"login":"tower-rs","id":26263939,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI2MjYzOTM5","avatar_url":"https://avatars0.githubusercontent.com/u/26263939?v=4","gravatar_id":"","url":"https://api.github.com/users/tower-rs","html_url":"https://github.com/tower-rs","followers_url":"https://api.github.com/users/tower-rs/followers","following_url":"https://api.github.com/users/tower-rs/following{/other_user}","gists_url":"https://api.github.com/users/tower-rs/gists{/gist_id}","starred_url":"https://api.github.com/users/tower-rs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tower-rs/subscriptions","organizations_url":"https://api.github.com/users/tower-rs/orgs","repos_url":"https://api.github.com/users/tower-rs/repos","events_url":"https://api.github.com/users/tower-rs/events{/privacy}","received_events_url":"https://api.github.com/users/tower-rs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/tower-rs/tower-grpc","description":"A gRPC client & server implementation.","fork":false,"url":"https://api.github.com/repos/tower-rs/tower-grpc","forks_url":"https://api.github.com/repos/tower-rs/tower-grpc/forks","keys_url":"https://api.github.com/repos/tower-rs/tower-grpc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tower-rs/tower-grpc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tower-rs/tower-grpc/teams","hooks_url":"https://api.github.com/repos/tower-rs/tower-grpc/hooks","issue_events_url":"https://api.github.com/repos/tower-rs/tower-grpc/issues/events{/number}","events_url":"https://api.github.com/repos/tower-rs/tower-grpc/events","assignees_url":"https://api.github.com/repos/tower-rs/tower-grpc/assignees{/user}","branches_url":"https://api.github.com/repos/tower-rs/tower-grpc/branches{/branch}","tags_url":"https://api.github.com/repos/tower-rs/tower-grpc/tags","blobs_url":"https://api.github.com/repos/tower-rs/tower-grpc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tower-rs/tower-grpc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tower-rs/tower-grpc/git/refs{/sha}","trees_url":"https://api.github.com/repos/tower-rs/tower-grpc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tower-rs/tower-grpc/statuses/{sha}","languages_url":"https://api.github.com/repos/tower-rs/tower-grpc/languages","stargazers_url":"https://api.github.com/repos/tower-rs/tower-grpc/stargazers","contributors_url":"https://api.github.com/repos/tower-rs/tower-grpc/contributors","subscribers_url":"https://api.github.com/repos/tower-rs/tower-grpc/subscribers","subscription_url":"https://api.github.com/repos/tower-rs/tower-grpc/subscription","commits_url":"https://api.github.com/repos/tower-rs/tower-grpc/commits{/sha}","git_commits_url":"https://api.github.com/repos/tower-rs/tower-grpc/git/commits{/sha}","comments_url":"https://api.github.com/repos/tower-rs/tower-grpc/comments{/number}","issue_comment_url":"https://api.github.com/repos/tower-rs/tower-grpc/issues/comments{/number}","contents_url":"https://api.github.com/repos/tower-rs/tower-grpc/contents/{+path}","compare_url":"https://api.github.com/repos/tower-rs/tower-grpc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tower-rs/tower-grpc/merges","archive_url":"https://api.github.com/repos/tower-rs/tower-grpc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tower-rs/tower-grpc/downloads","issues_url":"https://api.github.com/repos/tower-rs/tower-grpc/issues{/number}","pulls_url":"https://api.github.com/repos/tower-rs/tower-grpc/pulls{/number}","milestones_url":"https://api.github.com/repos/tower-rs/tower-grpc/milestones{/number}","notifications_url":"https://api.github.com/repos/tower-rs/tower-grpc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tower-rs/tower-grpc/labels{/name}","releases_url":"https://api.github.com/repos/tower-rs/tower-grpc/releases{/id}","deployments_url":"https://api.github.com/repos/tower-rs/tower-grpc/deployments","created_at":"2017-12-05T20:56:56Z","updated_at":"2018-11-16T07:03:07Z","pushed_at":"2018-11-16T18:21:40Z","git_url":"git://github.com/tower-rs/tower-grpc.git","ssh_url":"git@github.com:tower-rs/tower-grpc.git","clone_url":"https://github.com/tower-rs/tower-grpc.git","svn_url":"https://github.com/tower-rs/tower-grpc","homepage":null,"size":1333,"stargazers_count":231,"watchers_count":231,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":26,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":26,"open_issues":32,"watchers":231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92"},"html":{"href":"https://github.com/tower-rs/tower-grpc/pull/92"},"issue":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/issues/92"},"comments":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/tower-rs/tower-grpc/statuses/480d4f11cb5a614e12770cae82211a6189468f91"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"carllerche"}}