pub struct HandleStore { /* private fields */ }Expand description
Per-endpoint handle registry. Owns all body readers, writers,
sessions, request-head rendezvous channels, and fetch-cancel tokens for
a single IrohEndpoint.
When the endpoint is dropped, this store is dropped with it — all slot-maps are freed and any remaining handles become invalid.
Implementations§
Source§impl HandleStore
impl HandleStore
Sourcepub fn new(config: StoreConfig) -> Self
pub fn new(config: StoreConfig) -> Self
Create a new handle store with the given configuration.
Sourcepub fn drain_timeout(&self) -> Duration
pub fn drain_timeout(&self) -> Duration
The configured drain timeout.
Sourcepub fn max_chunk_size(&self) -> usize
pub fn max_chunk_size(&self) -> usize
The configured maximum chunk size.
Sourcepub fn count_handles(&self) -> (usize, usize, usize, usize)
pub fn count_handles(&self) -> (usize, usize, usize, usize)
Snapshot of handle counts for observability.
Returns (active_readers, active_writers, active_sessions, total_handles).
Sourcepub fn make_body_channel(&self) -> (BodyWriter, BodyReader)
pub fn make_body_channel(&self) -> (BodyWriter, BodyReader)
Create a matched (writer, reader) pair using this store’s config.
Sourcepub fn insert_reader(&self, reader: BodyReader) -> Result<u64, CoreError>
pub fn insert_reader(&self, reader: BodyReader) -> Result<u64, CoreError>
Insert a BodyReader and return a handle.
Sourcepub fn insert_writer(&self, writer: BodyWriter) -> Result<u64, CoreError>
pub fn insert_writer(&self, writer: BodyWriter) -> Result<u64, CoreError>
Insert a BodyWriter and return a handle.
Sourcepub fn alloc_body_writer(&self) -> Result<(u64, BodyReader), CoreError>
pub fn alloc_body_writer(&self) -> Result<(u64, BodyReader), CoreError>
Allocate a (writer_handle, reader) pair for streaming request bodies.
The writer handle is returned to JS. The reader must be stashed via
store_pending_reader so the fetch path
can claim it.
Sourcepub fn store_pending_reader(&self, writer_handle: u64, reader: BodyReader)
pub fn store_pending_reader(&self, writer_handle: u64, reader: BodyReader)
Store the reader side of a newly allocated writer channel so that the
fetch path can claim it with claim_pending_reader.
Sourcepub fn claim_pending_reader(&self, writer_handle: u64) -> Option<BodyReader>
pub fn claim_pending_reader(&self, writer_handle: u64) -> Option<BodyReader>
Claim the reader that was paired with writer_handle.
Returns None if already claimed or never stored.
Sourcepub async fn next_chunk(&self, handle: u64) -> Result<Option<Bytes>, CoreError>
pub async fn next_chunk(&self, handle: u64) -> Result<Option<Bytes>, CoreError>
Pull the next chunk from a reader handle.
Returns Ok(None) at EOF. After returning None the handle is
cleaned up from the registry automatically.
Sourcepub fn try_next_chunk(&self, handle: u64) -> Result<Option<Bytes>, CoreError>
pub fn try_next_chunk(&self, handle: u64) -> Result<Option<Bytes>, CoreError>
Non-blocking variant of next_chunk.
Returns:
Ok(Some(bytes))— a chunk was immediately available.Ok(None)— EOF; the reader is cleaned up.Err(_)— no data available yet (channel empty or lock contended), or invalid handle. Caller should retry after yielding.
#126: Used by the Deno adapter to avoid spawn_blocking overhead on
the body-read hot path. When data is already buffered in the channel,
this returns it synchronously on the JS thread.
Sourcepub async fn send_chunk(
&self,
handle: u64,
chunk: Bytes,
) -> Result<(), CoreError>
pub async fn send_chunk( &self, handle: u64, chunk: Bytes, ) -> Result<(), CoreError>
Push a chunk into a writer handle.
Chunks larger than the configured max_chunk_size are split
automatically so individual messages stay within the backpressure budget.
Sourcepub fn finish_body(&self, handle: u64) -> Result<(), CoreError>
pub fn finish_body(&self, handle: u64) -> Result<(), CoreError>
Signal end-of-body by dropping the writer from the registry.
Sourcepub fn cancel_reader(&self, handle: u64)
pub fn cancel_reader(&self, handle: u64)
Drop a body reader, signalling cancellation of any in-flight read.
Sourcepub fn insert_session(&self, entry: SessionEntry) -> Result<u64, CoreError>
pub fn insert_session(&self, entry: SessionEntry) -> Result<u64, CoreError>
Insert a SessionEntry and return a handle.
Sourcepub fn lookup_session(&self, handle: u64) -> Option<Arc<SessionEntry>>
pub fn lookup_session(&self, handle: u64) -> Option<Arc<SessionEntry>>
Look up a session by handle without consuming it.
Sourcepub fn remove_session(&self, handle: u64) -> Option<Arc<SessionEntry>>
pub fn remove_session(&self, handle: u64) -> Option<Arc<SessionEntry>>
Remove a session entry by handle and return it.
Sourcepub fn allocate_req_handle(
&self,
sender: Sender<ResponseHeadEntry>,
) -> Result<u64, CoreError>
pub fn allocate_req_handle( &self, sender: Sender<ResponseHeadEntry>, ) -> Result<u64, CoreError>
Insert a response-head oneshot sender and return a handle.
Sourcepub fn take_req_sender(&self, handle: u64) -> Option<Sender<ResponseHeadEntry>>
pub fn take_req_sender(&self, handle: u64) -> Option<Sender<ResponseHeadEntry>>
Remove and return the response-head sender for the given handle.
Sourcepub fn alloc_fetch_token(&self) -> Result<u64, CoreError>
pub fn alloc_fetch_token(&self) -> Result<u64, CoreError>
Allocate a cancellation token for an upcoming fetch call.
Sourcepub fn cancel_in_flight(&self, token: u64)
pub fn cancel_in_flight(&self, token: u64)
Signal an in-flight fetch to abort.
Sourcepub fn get_fetch_cancel_notify(&self, token: u64) -> Option<Arc<Notify>>
pub fn get_fetch_cancel_notify(&self, token: u64) -> Option<Arc<Notify>>
Retrieve the Notify for a fetch token (clones the Arc for use in select!).
Sourcepub fn remove_fetch_token(&self, token: u64)
pub fn remove_fetch_token(&self, token: u64)
Remove a fetch cancel token after the fetch completes.
Auto Trait Implementations§
impl !Freeze for HandleStore
impl RefUnwindSafe for HandleStore
impl Send for HandleStore
impl Sync for HandleStore
impl Unpin for HandleStore
impl UnsafeUnpin for HandleStore
impl UnwindSafe for HandleStore
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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