From 1f94c0f5035004237fa97aca2766b9b50829bed5 Mon Sep 17 00:00:00 2001 From: Eric Rosenberg Date: Thu, 29 Sep 2022 15:53:06 +0000 Subject: [PATCH 1/2] add accessor for StreamId u32 --- src/share.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/share.rs b/src/share.rs index ef520be3..f366da40 100644 --- a/src/share.rs +++ b/src/share.rs @@ -111,6 +111,12 @@ pub struct SendStream { #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct StreamId(u32); +impl From 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 From 599d063521f23e19d6af7aea287195ddbbd4ef22 Mon Sep 17 00:00:00 2001 From: Eric Rosenberg Date: Fri, 21 Oct 2022 18:26:41 +0000 Subject: [PATCH 2/2] add as_u32 method --- src/share.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/share.rs b/src/share.rs index f366da40..f4e3cdeb 100644 --- a/src/share.rs +++ b/src/share.rs @@ -108,7 +108,7 @@ pub struct SendStream { /// 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 for u32 { @@ -388,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` 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 =====