pub struct RequestGroup {
pub completed_length_atomic: AtomicU64,
pub total_length_atomic: AtomicU64,
pub uploaded_length: AtomicU64,
pub download_speed_cached: AtomicU64,
pub bt_bitfield: RwLock<Option<Vec<u8>>>,
pub bt_num_pieces: AtomicU32,
pub bt_piece_length: AtomicU32,
pub bt_info_hash_hex: RwLock<Option<String>>,
pub rate_limiter: RwLock<Option<RateLimiter>>,
/* private fields */
}Fields§
§completed_length_atomic: AtomicU64§total_length_atomic: AtomicU64§uploaded_length: AtomicU64§download_speed_cached: AtomicU64§bt_bitfield: RwLock<Option<Vec<u8>>>§bt_num_pieces: AtomicU32Number of pieces in the torrent (0 for non-BT downloads)
bt_piece_length: AtomicU32Size of each piece in bytes (0 for non-BT downloads)
bt_info_hash_hex: RwLock<Option<String>>Info hash hex string for torrent identification (None for non-BT downloads) Uses std::sync::RwLock instead of tokio::sync::RwLock for non-async access
rate_limiter: RwLock<Option<RateLimiter>>Handle to the download’s RateLimiter so that runtime option updates
(e.g. via aria2.changeOption) can dynamically adjust the rate.
None until the download engine wires up a ThrottledWriter.
Uses its own RwLock (independent of the RequestGroupMan write lock)
so that set_rate_limiter can take &self.
Implementations§
Source§impl RequestGroup
impl RequestGroup
pub fn new(gid: GroupId, uris: Vec<String>, options: DownloadOptions) -> Self
pub async fn start(&mut self) -> Result<()>
pub async fn pause(&mut self) -> Result<()>
pub async fn remove(&mut self) -> Result<()>
pub async fn complete(&mut self) -> Result<()>
pub async fn error(&mut self, err: impl Into<String>) -> Result<()>
pub async fn status(&self) -> DownloadStatus
pub fn gid(&self) -> GroupId
pub fn uris(&self) -> &[String]
pub fn options(&self) -> &DownloadOptions
Sourcepub async fn set_rate_limiter(&self, limiter: RateLimiter)
pub async fn set_rate_limiter(&self, limiter: RateLimiter)
Store a handle to the download’s RateLimiter so that runtime option
updates (e.g. via aria2.changeOption) can dynamically adjust the rate.
The RateLimiter is Clone and shares Arc<RateLimiterInner>, so both
the ThrottledWriter and RequestGroup see the same token buckets.
Takes &self because rate_limiter has its own RwLock, independent
of the RequestGroupMan outer write lock.
Sourcepub async fn update_option(&mut self, key: &str, value: Value) -> bool
pub async fn update_option(&mut self, key: &str, value: Value) -> bool
Update a single runtime-changeable option by key (using aria2’s
kebab-case option names, e.g. "max-download-limit").
Returns true if the option was recognized and updated, false if the
key is not a runtime-changeable option (see RUNTIME_CHANGEABLE_OPTIONS).
Takes &mut self because options is a plain field — the caller
(RequestGroupMan) holds the outer Arc<RwLock<RequestGroup>> write
lock. For max-download-limit / max-upload-limit, the stored
RateLimiter (if any) is also updated so the change takes effect
immediately on the live download.
pub fn total_length(&self) -> u64
pub async fn set_total_length(&mut self, length: u64)
pub async fn completed_length(&self) -> u64
pub async fn update_completed_length(&self, length: u64)
pub async fn update_progress(&self, completed_length: u64)
pub async fn progress(&self) -> f64
pub async fn download_speed(&self) -> u64
pub async fn upload_speed(&self) -> u64
pub async fn update_speed(&self, dl_speed: u64, ul_speed: u64)
pub async fn add_segment(&mut self, segment: Segment)
pub async fn segments(&self) -> Vec<Segment>
pub async fn elapsed_time(&self) -> Option<Duration>
pub async fn eta(&self) -> Option<Duration>
Sourcepub fn set_completed_length(&self, val: u64)
pub fn set_completed_length(&self, val: u64)
Set completed length using atomic store (lock-free)
Sourcepub fn get_completed_length(&self) -> u64
pub fn get_completed_length(&self) -> u64
Get completed length using atomic load (lock-free)
Sourcepub fn set_total_length_atomic(&self, val: u64)
pub fn set_total_length_atomic(&self, val: u64)
Set total length using atomic store (lock-free)
Sourcepub fn get_total_length_atomic(&self) -> u64
pub fn get_total_length_atomic(&self) -> u64
Get total length using atomic load (lock-free)
Sourcepub fn set_uploaded_length(&self, val: u64)
pub fn set_uploaded_length(&self, val: u64)
Set uploaded length using atomic store (lock-free)
Sourcepub fn get_uploaded_length(&self) -> u64
pub fn get_uploaded_length(&self) -> u64
Get uploaded length using atomic load (lock-free)
Sourcepub fn set_download_speed_cached(&self, val: u64)
pub fn set_download_speed_cached(&self, val: u64)
Set download speed cache using atomic store (lock-free)
Sourcepub fn get_download_speed_cached(&self) -> u64
pub fn get_download_speed_cached(&self) -> u64
Get download speed from cache using atomic load (lock-free)
Sourcepub async fn set_bt_bitfield(&self, bf: Option<Vec<u8>>)
pub async fn set_bt_bitfield(&self, bf: Option<Vec<u8>>)
Set BT bitfield (async, uses RwLock)
Sourcepub async fn get_bt_bitfield(&self) -> Option<Vec<u8>>
pub async fn get_bt_bitfield(&self) -> Option<Vec<u8>>
Get BT bitfield (async, uses RwLock)
Sourcepub fn set_resume_offset(&self, offset: u64)
pub fn set_resume_offset(&self, offset: u64)
Set resume offset for HTTP/FTP range request resumption
Sourcepub fn set_bt_metadata(
&self,
num_pieces: u32,
piece_length: u32,
info_hash_hex: String,
)
pub fn set_bt_metadata( &self, num_pieces: u32, piece_length: u32, info_hash_hex: String, )
Set BT metadata fields (num_pieces, piece_length, info_hash_hex) Called by BtDownloadCommand after parsing TorrentMeta
Sourcepub fn get_bt_num_pieces(&self) -> u32
pub fn get_bt_num_pieces(&self) -> u32
Get number of pieces (lock-free atomic read)
Sourcepub fn get_bt_piece_length(&self) -> u32
pub fn get_bt_piece_length(&self) -> u32
Get piece length (lock-free atomic read)
Sourcepub async fn get_bt_info_hash_hex_async(&self) -> Option<String>
pub async fn get_bt_info_hash_hex_async(&self) -> Option<String>
Get info hash hex string (async-compatible wrapper)
Sourcepub fn get_bt_info_hash_hex(&self) -> Option<String>
pub fn get_bt_info_hash_hex(&self) -> Option<String>
Get info hash hex string (blocking read for non-async contexts)
Auto Trait Implementations§
impl !Freeze for RequestGroup
impl !RefUnwindSafe for RequestGroup
impl !UnwindSafe for RequestGroup
impl Send for RequestGroup
impl Sync for RequestGroup
impl Unpin for RequestGroup
impl UnsafeUnpin for RequestGroup
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