Struct s2n_quic_core::stream::StreamId
source · 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 StreamId
s 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.
Trait Implementations§
source§impl Ord for StreamId
impl Ord for StreamId
source§impl PartialEq for StreamId
impl PartialEq for StreamId
source§impl PartialOrd for StreamId
impl PartialOrd for StreamId
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more