Add stream_id accessors to public API types (#292)

Problem:

Applications may want to access the underlying h2 stream ID for
diagnostics, etc. Stream IDs were not previously exposed in public APIs.

Solution:

Added a new public `share::StreamId` type, which has a more restricted 
API than the internal `frame::StreamId` type. The public API types 
`SendStream`, `RecvStream`, `ReleaseCapacity`, 
`client::ResponseFuture`, and `server::SendResponse` now all have 
`stream_id` methods which return the stream ID of the corresponding 
stream.

Closes #289.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
Eliza Weisman
2018-07-12 21:01:57 -07:00
committed by GitHub
parent 41aae14c64
commit f3806d5144
6 changed files with 101 additions and 1 deletions

View File

@@ -946,6 +946,10 @@ impl<B> StreamRef<B> {
{
self.opaque.clone()
}
pub fn stream_id(&self) -> StreamId {
self.opaque.stream_id()
}
}
impl<B> Clone for StreamRef<B> {
@@ -1018,6 +1022,13 @@ impl OpaqueStreamRef {
.recv
.release_capacity(capacity, &mut stream, &mut me.actions.task)
}
pub fn stream_id(&self) -> StreamId {
self.inner.lock()
.unwrap()
.store[self.key]
.id
}
}
impl fmt::Debug for OpaqueStreamRef {