pub struct LpdManager {
pub active_hashes: Arc<RwLock<HashSet<String>>>,
/* private fields */
}Expand description
Manages LPD operations for all active torrents.
Maintains a registry of known peers discovered via LPD, handles periodic announcements for active downloads, and coordinates with the download engine.
Fields§
§active_hashes: Arc<RwLock<HashSet<String>>>Track which info hashes we’re currently announcing
Implementations§
Source§impl LpdManager
impl LpdManager
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LpdManager
Initializes the UDP socket, joins multicast group, and sets up internal state tracking.
Sourcepub fn with_interval(announce_interval_secs: u64) -> Result<Self, String>
pub fn with_interval(announce_interval_secs: u64) -> Result<Self, String>
Create LpdManager with custom configuration
Sourcepub async fn register_torrent(&self, info_hash: &str) -> Result<(), String>
pub async fn register_torrent(&self, info_hash: &str) -> Result<(), String>
Register a torrent for LPD announcements
Adds the info_hash to the active set so it gets periodically announced.
Sourcepub async fn unregister_torrent(&self, info_hash: &str)
pub async fn unregister_torrent(&self, info_hash: &str)
Unregister a torrent from LPD announcements
Sourcepub async fn announce_torrent(
&self,
info_hash: &str,
port: u16,
) -> Result<(), String>
pub async fn announce_torrent( &self, info_hash: &str, port: u16, ) -> Result<(), String>
Manual announce for a specific torrent
Sourcepub async fn discover_peers(
&self,
_info_hash: &str,
timeout_ms: Option<u64>,
) -> Vec<LpdPeer>
pub async fn discover_peers( &self, _info_hash: &str, timeout_ms: Option<u64>, ) -> Vec<LpdPeer>
Discover peers for a specific info_hash via LPD
Sourcepub async fn get_peers_for(&self, info_hash: &str) -> Vec<LpdPeer>
pub async fn get_peers_for(&self, info_hash: &str) -> Vec<LpdPeer>
Get all known peers for a given info_hash
Sourcepub fn start_background_announce(&mut self, port: u16) -> Option<JoinHandle<()>>
pub fn start_background_announce(&mut self, port: u16) -> Option<JoinHandle<()>>
Sourcepub fn stop_background_announce(&mut self)
pub fn stop_background_announce(&mut self)
Stop background announce task
Sourcepub async fn update_peers(&self, info_hash: &str, new_peers: Vec<LpdPeer>)
pub async fn update_peers(&self, info_hash: &str, new_peers: Vec<LpdPeer>)
Update peer registry with newly discovered peers
Sourcepub async fn cleanup_expired_peers(&self, max_age: Duration) -> usize
pub async fn cleanup_expired_peers(&self, max_age: Duration) -> usize
Clean up expired peers from all registries
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check if LPD is available and working
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LpdManager
impl !UnwindSafe for LpdManager
impl Freeze for LpdManager
impl Send for LpdManager
impl Sync for LpdManager
impl Unpin for LpdManager
impl UnsafeUnpin for LpdManager
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