pub struct HandleStore { /* private fields */ }Expand description
Per-endpoint handle registry. Owns all body readers, writers, trailers,
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 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_trailer_sender(
&self,
tx: Sender<Vec<(String, String)>>,
) -> Result<u64, CoreError>
pub fn insert_trailer_sender( &self, tx: Sender<Vec<(String, String)>>, ) -> Result<u64, CoreError>
Insert a trailer oneshot sender and return a handle.
Sourcepub fn insert_trailer_receiver(
&self,
rx: Receiver<Vec<(String, String)>>,
) -> Result<u64, CoreError>
pub fn insert_trailer_receiver( &self, rx: Receiver<Vec<(String, String)>>, ) -> Result<u64, CoreError>
Insert a trailer oneshot receiver and return a handle.
Sourcepub fn remove_trailer_sender(&self, handle: u64)
pub fn remove_trailer_sender(&self, handle: u64)
Remove (drop) a trailer sender without sending.
Sourcepub fn alloc_trailer_sender(&self) -> Result<u64, CoreError>
pub fn alloc_trailer_sender(&self) -> Result<u64, CoreError>
Allocate a (tx, rx) trailer oneshot pair for sending request trailers
from JavaScript to the Rust body encoder.
Returns the sender handle — JS holds this and calls send_trailers when
it is done writing the request body. The matching rx is stored in
pending_trailer_rxs and claimed by fetch() via
claim_pending_trailer_rx.
Sourcepub fn claim_pending_trailer_rx(
&self,
sender_handle: u64,
) -> Option<Receiver<Vec<(String, String)>>>
pub fn claim_pending_trailer_rx( &self, sender_handle: u64, ) -> Option<Receiver<Vec<(String, String)>>>
Claim the trailer receiver that was paired with the given sender handle.
Returns None if the handle was never allocated via
alloc_trailer_sender or has already been claimed.
Sourcepub fn send_trailers(
&self,
handle: u64,
trailers: Vec<(String, String)>,
) -> Result<(), CoreError>
pub fn send_trailers( &self, handle: u64, trailers: Vec<(String, String)>, ) -> Result<(), CoreError>
Deliver trailers from the JS side to the waiting Rust pump task.
Sourcepub async fn next_trailer(
&self,
handle: u64,
) -> Result<Option<Vec<(String, String)>>, CoreError>
pub async fn next_trailer( &self, handle: u64, ) -> Result<Option<Vec<(String, String)>>, CoreError>
Await and retrieve trailers produced by the Rust pump task.
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.