pub struct WebSeedManager { /* private fields */ }Expand description
Manages multiple web-seed endpoints with automatic fallback.
When downloading a piece, tries each configured web-seed URL in order until one succeeds. If all fail, returns an aggregated error.
Implementations§
Source§impl WebSeedManager
impl WebSeedManager
Sourcepub fn new(urls: Vec<String>, piece_length: u32, total_length: u64) -> Self
pub fn new(urls: Vec<String>, piece_length: u32, total_length: u64) -> Self
Create a new WebSeedManager from a list of web-seed URLs.
§Arguments
urls- List of HTTP(S) URLs serving the torrent contentpiece_length- Length of each piece in the torrenttotal_length- Total file length
§Example
use aria2_core::engine::bt_web_seed::WebSeedManager;
let manager = WebSeedManager::new(
vec![
"http://mirror1.example.com/file.bin".to_string(),
"http://mirror2.example.com/file.bin".to_string(),
],
16384, // piece_length
1048576 // total_length
);Sourcepub fn stats(&self) -> &WebSeedStats
pub fn stats(&self) -> &WebSeedStats
Get the shared statistics.
Sourcepub async fn try_download_piece(
&self,
piece_index: u32,
piece_length: u64,
piece_offset: u64,
length: u64,
) -> Result<Vec<u8>, String>
pub async fn try_download_piece( &self, piece_index: u32, piece_length: u64, piece_offset: u64, length: u64, ) -> Result<Vec<u8>, String>
Attempt to download a piece from any available web-seed.
Tries each web-seed in order; returns data from the first successful response. Collects errors from all failed attempts if all fail.
§Arguments
piece_index- Logical index of the piecepiece_length- Total length of this piecepiece_offset- Byte offset within the filelength- Number of bytes to download
§Returns
Ok(Vec<u8>)- Piece data from first successful web-seedErr(String)- All web-seeds failed (contains error details)
Sourcepub fn clients(&self) -> &[WebSeedClient]
pub fn clients(&self) -> &[WebSeedClient]
Get reference to the underlying web-seed clients.
Auto Trait Implementations§
impl !RefUnwindSafe for WebSeedManager
impl !UnwindSafe for WebSeedManager
impl Freeze for WebSeedManager
impl Send for WebSeedManager
impl Sync for WebSeedManager
impl Unpin for WebSeedManager
impl UnsafeUnpin for WebSeedManager
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
Mutably borrows from an owned value. Read more