pub struct DHTServer { /* private fields */ }Expand description
Cloneable BEP-5 server handle and primary crate entry point.
Implementations§
Source§impl DHTServer
impl DHTServer
Sourcepub async fn new(options: DHTOptions) -> Result<Self>
pub async fn new(options: DHTOptions) -> Result<Self>
Validates options, binds configured UDP sockets and constructs bounded pipelines.
Background Metadata scheduling begins during construction. Active crawling and UDP receive
loops begin when Self::start is awaited.
Sourcepub fn on_metadata_fetch<F, Fut>(&self, callback: F)
pub fn on_metadata_fetch<F, Fut>(&self, callback: F)
Registers the asynchronous admission gate invoked before the first real Peer attempt.
Returning false rejects the job without downloading Metadata and without emitting a
MetadataFetchCompletion. If no gate is registered, jobs are admitted.
Sourcepub fn on_torrent<F>(&self, callback: F)
pub fn on_torrent<F>(&self, callback: F)
Registers a torrent callback whose return is implicitly treated as accepted delivery.
Registering a new torrent callback replaces the previous one.
Sourcepub fn on_torrent_with_ack<F>(&self, callback: F)
pub fn on_torrent_with_ack<F>(&self, callback: F)
Registers a torrent callback that acknowledges application delivery.
Returning true produces crate::MetadataFetchCompletionStatus::Accepted. Returning
false produces crate::MetadataFetchCompletionStatus::DeliveryRejected: the Metadata
download was
valid, but the application did not accept it. A callback panic is caught and treated as
rejected delivery. Registering this callback replaces any previous torrent callback.
Sourcepub fn on_metadata_fetch_complete<F>(&self, callback: F)
pub fn on_metadata_fetch_complete<F>(&self, callback: F)
Registers a callback invoked exactly once when an admitted Metadata job terminates.
Gate rejection does not emit a completion. attempts counts real Peer network attempts;
failure-cache skips are excluded. Registering a new callback replaces the previous one.
Sourcepub fn filter<F>(&self, filter: F)
pub fn filter<F>(&self, filter: F)
Registers an early synchronous InfoHash filter for valid announce_peer queries.
Returning false prevents the Hash from entering the bounded ingress queue. Registering a
new filter replaces the previous one.
Sourcepub fn set_filter<F>(&self, filter: F)
pub fn set_filter<F>(&self, filter: F)
Alias for Self::filter.
Sourcepub fn on_error<F>(&self, callback: F)
pub fn on_error<F>(&self, callback: F)
Registers a runtime error callback, replacing any previous callback.
Initialization and start errors are still returned through Result.
Sourcepub fn get_node_pool_size(&self) -> usize
pub fn get_node_pool_size(&self) -> usize
Returns the current strict FIFO crawl-pool size.
Sourcepub fn runtime_stats(&self) -> DhtRuntimeStats
pub fn runtime_stats(&self) -> DhtRuntimeStats
Returns a cheap cloneable handle to transport-neutral atomic runtime statistics.