pub struct StreamId(/* private fields */);Expand description
The ID of a stream.
A stream ID is a 62-bit integer (0 to 2^62-1) that is unique for all streams on a connection.
Implementations§
Source§impl StreamId
impl StreamId
Sourcepub const fn from_varint(id: VarInt) -> StreamId
pub const fn from_varint(id: VarInt) -> StreamId
Sourcepub fn initial(initiator: Type, stream_type: StreamType) -> StreamId
pub fn initial(initiator: Type, stream_type: StreamType) -> StreamId
Returns the initial Stream ID for a given stream type.
E.g. the initial Stream ID for a server initiated unidirectional Stream
is Stream ID 3.
Example:
let stream_id = StreamId::initial(endpoint::Type::Server, StreamType::Unidirectional);
// Initial server initiated unidirectional Stream ID is 3
assert_eq!(3u64, stream_id.as_varint().as_u64());Sourcepub fn nth(initiator: Type, stream_type: StreamType, n: u64) -> Option<StreamId>
pub fn nth(initiator: Type, stream_type: StreamType, n: u64) -> Option<StreamId>
Returns the n-th StreamId for a certain type of Stream.
The 0th StreamId thereby represents the StreamId which is returned
by the Self::initial method. All further StreamIds of a certain type
will be spaced apart by 4.
nth() will return None if the resulting StreamId would not be valid.
Sourcepub fn next_of_type(self) -> Option<StreamId>
pub fn next_of_type(self) -> Option<StreamId>
Returns the next StreamId which is of the same type the one referred
to. E.g. if the method is called on a Stream ID for an unidirectional
client initiated stream, the Stream ID of the next unidirectional client
initiated stream will be returned.
Returns None if the next Stream ID would not be valid, due to being out
of bounds.
Example:
let stream_id = StreamId::initial(endpoint::Type::Client, StreamType::Unidirectional);
// Initial client initiated unidirectional Stream ID is 2
assert_eq!(2u64, stream_id.as_varint().as_u64());
// Get the next client initiated Stream ID
let next_stream_id = stream_id.next_of_type();
assert_eq!(6u64, next_stream_id.expect("Next Stream ID is valid").as_varint().as_u64());Sourcepub fn stream_type(self) -> StreamType
pub fn stream_type(self) -> StreamType
Returns whether the Stream is unidirectional or bidirectional.