pub struct BtProgressManager { /* private fields */ }Expand description
BT progress file manager
Manages BT download progress save, load, delete, and list operations. Supports atomic writes to ensure existing progress files are not corrupted in abnormal situations.
Implementations§
Source§impl BtProgressManager
impl BtProgressManager
Sourcepub fn get_progress_file_path(&self, info_hash: &[u8; 20]) -> PathBuf
pub fn get_progress_file_path(&self, info_hash: &[u8; 20]) -> PathBuf
Generate progress file path
Sourcepub fn save_progress(
&self,
info_hash: &[u8; 20],
progress: &BtProgress,
) -> Result<()>
pub fn save_progress( &self, info_hash: &[u8; 20], progress: &BtProgress, ) -> Result<()>
Save BT download progress to file
Uses atomic write strategy: writes to temporary file first, then replaces original file via rename operation, ensuring existing progress files are not corrupted if exceptions occur during write process.
§Arguments
info_hash- Torrent info_hash (20 bytes)progress- Progress data to save
§Errors
Returns error when file write fails
Sourcepub fn load_progress(&self, info_hash: &[u8; 20]) -> Result<BtProgress>
pub fn load_progress(&self, info_hash: &[u8; 20]) -> Result<BtProgress>
Load BT download progress file
Automatically detects C++ binary format and text format, and parses correctly. Validates whether info_hash in file matches provided parameter.
§Arguments
info_hash- Expected info_hash (20 bytes) for validation
§Returns
Returns loaded progress data
§Errors
- File doesn’t exist or read failure
- File format invalid or corrupted
- info_hash mismatch
Auto Trait Implementations§
impl Freeze for BtProgressManager
impl RefUnwindSafe for BtProgressManager
impl Send for BtProgressManager
impl Sync for BtProgressManager
impl Unpin for BtProgressManager
impl UnsafeUnpin for BtProgressManager
impl UnwindSafe for BtProgressManager
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