pub struct PeerHandle { /* private fields */ }Expand description
Per-peer handle for submitting fetch commands and awaiting responses.
Cheap to Clone (one Arc bump). When the last clone is dropped,
the peer-level cancel token fires, aborting all in-flight fetches
for this peer.
Implementations§
Source§impl PeerHandle
impl PeerHandle
Sourcepub async fn batch(
&self,
cmds: Vec<FetchCmd>,
) -> Vec<Result<FetchResponse, NetError>>
pub async fn batch( &self, cmds: Vec<FetchCmd>, ) -> Vec<Result<FetchResponse, NetError>>
Submit a batch of fetch commands and await all responses.
Commands execute in parallel. Results are returned in array order, not completion order.
§Errors
Individual commands may fail independently. Each slot in the
returned Vec contains its own Result.
Sourcepub fn cancel(&self) -> CancellationToken
pub fn cancel(&self) -> CancellationToken
Peer-level cancellation token.
Cancelling this token aborts all in-flight fetches for this peer. The cancel also fires automatically when the last clone of this handle is dropped.
Sourcepub async fn execute(&self, cmd: FetchCmd) -> Result<FetchResponse, NetError>
pub async fn execute(&self, cmd: FetchCmd) -> Result<FetchResponse, NetError>
Submit a single fetch command and await the response.
Always runs at High priority — imperative requests are
latency-sensitive.
§Errors
Returns NetError::Cancelled when the peer cancel fires,
the downloader shuts down, or the HTTP request itself fails.
Sourcepub fn with_bus(self, bus: EventBus) -> Self
pub fn with_bus(self, bus: EventBus) -> Self
Attach an event bus so the Downloader can publish per-peer
DownloaderEvents and the ABR
controller can publish AbrEvents to
it. Returns self so the call chains naturally after
Downloader::register.
Trait Implementations§
Source§impl Clone for PeerHandle
impl Clone for PeerHandle
Source§fn clone(&self) -> PeerHandle
fn clone(&self) -> PeerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more