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

Creates a Stream ID from a VarInt.

This is always a safe conversion, since Stream IDs and VarInts share the same range.

Converts the stream id into a VarInt

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());

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.

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());

Returns whether the client or server initiated the Stream

Returns whether the Stream is unidirectional or bidirectional.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.