Skip to main content

LpdManager

Struct LpdManager 

Source
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

Source

pub fn new() -> Self

Create a new LpdManager

Initializes the UDP socket, joins multicast group, and sets up internal state tracking.

Source

pub fn with_interval(announce_interval_secs: u64) -> Result<Self, String>

Create LpdManager with custom configuration

Source

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.

Source

pub async fn unregister_torrent(&self, info_hash: &str)

Unregister a torrent from LPD announcements

Source

pub async fn announce_torrent( &self, info_hash: &str, port: u16, ) -> Result<(), String>

Manual announce for a specific torrent

Source

pub async fn discover_peers( &self, _info_hash: &str, timeout_ms: Option<u64>, ) -> Vec<LpdPeer>

Discover peers for a specific info_hash via LPD

Source

pub async fn get_peers_for(&self, info_hash: &str) -> Vec<LpdPeer>

Get all known peers for a given info_hash

Source

pub fn start_background_announce(&mut self, port: u16) -> Option<JoinHandle<()>>

Start periodic background announce task

Spawns a Tokio task that announces all registered torrents every N seconds (default 5 min).

§Arguments
  • port - Our BT client listen port
§Returns

JoinHandle that can be used to cancel the task

Source

pub fn stop_background_announce(&mut self)

Stop background announce task

Source

pub async fn update_peers(&self, info_hash: &str, new_peers: Vec<LpdPeer>)

Update peer registry with newly discovered peers

Source

pub async fn cleanup_expired_peers(&self, max_age: Duration) -> usize

Clean up expired peers from all registries

Source

pub fn is_available(&self) -> bool

Check if LPD is available and working

Trait Implementations§

Source§

impl Default for LpdManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more