Skip to content

Commit

Permalink
add accessor for StreamId u32 (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehaydenr committed Oct 21, 2022
1 parent 756e252 commit 79dff0c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/share.rs
Expand Up @@ -108,9 +108,15 @@ pub struct SendStream<B> {
/// new stream.
///
/// [Section 5.1.1]: https://tools.ietf.org/html/rfc7540#section-5.1.1
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct StreamId(u32);

impl From<StreamId> for u32 {
fn from(src: StreamId) -> Self {
src.0
}
}

/// Receives the body stream and trailers from the remote peer.
///
/// A `RecvStream` is provided by [`client::ResponseFuture`] and
Expand Down Expand Up @@ -382,6 +388,18 @@ impl StreamId {
pub(crate) fn from_internal(id: crate::frame::StreamId) -> Self {
StreamId(id.into())
}

/// Returns the `u32` corresponding to this `StreamId`
///
/// # Note
///
/// This is the same as the `From<StreamId>` implementation, but
/// included as an inherent method because that implementation doesn't
/// appear in rustdocs, as well as a way to force the type instead of
/// relying on inference.
pub fn as_u32(&self) -> u32 {
(*self).into()
}
}
// ===== impl RecvStream =====

Expand Down

0 comments on commit 79dff0c

Please sign in to comment.