pub struct StreamPool<F: StreamFactory> { /* private fields */ }Expand description
Represents a pool of streams, managing a collection of streams created by a factory.
Implementations§
Source§impl<F: StreamFactory> StreamPool<F>
impl<F: StreamFactory> StreamPool<F>
Sourcepub fn new(backend: F, max_streams: u8, num_special: u8) -> Self
pub fn new(backend: F, max_streams: u8, num_special: u8) -> Self
Creates a new stream pool with the given backend factory and capacity constraints.
Sourcepub fn streams(&self) -> impl Iterator<Item = &F::Stream>
pub fn streams(&self) -> impl Iterator<Item = &F::Stream>
Read-only iterator over initialized streams (unlike Self::get_mut, never creates one).
Sourcepub fn stream_ids(&self) -> impl Iterator<Item = StreamId> + '_
pub fn stream_ids(&self) -> impl Iterator<Item = StreamId> + '_
Synthetic StreamIds, one per initialized regular pool slot.
Each id round-trips through Self::get_mut to the same slot it
came from (slot i is reachable via StreamId { value: i } since
indexing is value % max_streams), so it’s safe to feed these
ids back into per-stream APIs.
Sourcepub fn get_mut(&mut self, stream_id: &StreamId) -> &mut F::Stream
pub fn get_mut(&mut self, stream_id: &StreamId) -> &mut F::Stream
Retrieves a mutable reference to a stream for a given stream ID.
Sourcepub unsafe fn get_mut_index(&mut self, index: usize) -> &mut F::Stream
pub unsafe fn get_mut_index(&mut self, index: usize) -> &mut F::Stream
Retrieves a mutable reference to a stream at the specified index, initializing it if needed.
§Safety
- Caller must ensure the index is valid (less than
max_streams + num_special). - Lifetimes still follow the Rust rules.
Sourcepub unsafe fn get_special(&mut self, index: u8) -> &mut F::Stream
pub unsafe fn get_special(&mut self, index: u8) -> &mut F::Stream
Retrieves a mutable reference to a special stream at the given index.
§Safety
- Caller must ensure the index corresponds to a valid special stream.
- Lifetimes still follow the Rust rules.
Sourcepub fn stream_index(&mut self, id: &StreamId) -> usize
pub fn stream_index(&mut self, id: &StreamId) -> usize
Calculates the index for a given stream ID, mapping it to the pool’s capacity.
Sourcepub fn factory_mut(&mut self) -> &mut F
pub fn factory_mut(&mut self) -> &mut F
Mutable access to the factory, e.g. to change the configuration new streams are created with. Already-created streams are unaffected.
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for StreamPool<F>where
F: Freeze,
impl<F> RefUnwindSafe for StreamPool<F>
impl<F> Send for StreamPool<F>
impl<F> Sync for StreamPool<F>
impl<F> Unpin for StreamPool<F>
impl<F> UnsafeUnpin for StreamPool<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for StreamPool<F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more