Struct s2n_quic_transport::stream::StreamId
source · [−]pub struct StreamId(_);
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
sourceimpl StreamId
impl StreamId
sourcepub const fn from_varint(id: VarInt) -> StreamId
pub const fn from_varint(id: VarInt) -> StreamId
sourcepub fn initial(initator: Type, stream_type: StreamType) -> StreamId
pub fn initial(initator: 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
sourceimpl Ord for StreamId
impl Ord for StreamId
sourceimpl PartialOrd<StreamId> for StreamId
impl PartialOrd<StreamId> for StreamId
sourcefn partial_cmp(&self, other: &StreamId) -> Option<Ordering>
fn partial_cmp(&self, other: &StreamId) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for StreamId
impl Eq for StreamId
impl StructuralEq for StreamId
impl StructuralPartialEq for StreamId
Auto Trait Implementations
impl RefUnwindSafe for StreamId
impl Send for StreamId
impl Sync for StreamId
impl Unpin for StreamId
impl UnwindSafe for StreamId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more