Skip to main content

RequestGroup

Struct RequestGroup 

Source
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: AtomicU32

Number of pieces in the torrent (0 for non-BT downloads)

§bt_piece_length: AtomicU32

Size 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

Source

pub fn new(gid: GroupId, uris: Vec<String>, options: DownloadOptions) -> Self

Source

pub async fn start(&mut self) -> Result<()>

Source

pub async fn pause(&mut self) -> Result<()>

Source

pub async fn remove(&mut self) -> Result<()>

Source

pub async fn complete(&mut self) -> Result<()>

Source

pub async fn error(&mut self, err: impl Into<String>) -> Result<()>

Source

pub async fn status(&self) -> DownloadStatus

Source

pub fn gid(&self) -> GroupId

Source

pub fn uris(&self) -> &[String]

Source

pub fn options(&self) -> &DownloadOptions

Source

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.

Source

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.

Source

pub fn total_length(&self) -> u64

Source

pub async fn set_total_length(&mut self, length: u64)

Source

pub async fn completed_length(&self) -> u64

Source

pub async fn update_completed_length(&self, length: u64)

Source

pub async fn update_progress(&self, completed_length: u64)

Source

pub async fn progress(&self) -> f64

Source

pub async fn download_speed(&self) -> u64

Source

pub async fn upload_speed(&self) -> u64

Source

pub async fn update_speed(&self, dl_speed: u64, ul_speed: u64)

Source

pub async fn add_segment(&mut self, segment: Segment)

Source

pub async fn segments(&self) -> Vec<Segment>

Source

pub async fn elapsed_time(&self) -> Option<Duration>

Source

pub async fn eta(&self) -> Option<Duration>

Source

pub fn set_completed_length(&self, val: u64)

Set completed length using atomic store (lock-free)

Source

pub fn get_completed_length(&self) -> u64

Get completed length using atomic load (lock-free)

Source

pub fn set_total_length_atomic(&self, val: u64)

Set total length using atomic store (lock-free)

Source

pub fn get_total_length_atomic(&self) -> u64

Get total length using atomic load (lock-free)

Source

pub fn set_uploaded_length(&self, val: u64)

Set uploaded length using atomic store (lock-free)

Source

pub fn get_uploaded_length(&self) -> u64

Get uploaded length using atomic load (lock-free)

Source

pub fn set_download_speed_cached(&self, val: u64)

Set download speed cache using atomic store (lock-free)

Source

pub fn get_download_speed_cached(&self) -> u64

Get download speed from cache using atomic load (lock-free)

Source

pub async fn set_bt_bitfield(&self, bf: Option<Vec<u8>>)

Set BT bitfield (async, uses RwLock)

Source

pub async fn get_bt_bitfield(&self) -> Option<Vec<u8>>

Get BT bitfield (async, uses RwLock)

Source

pub fn set_resume_offset(&self, offset: u64)

Set resume offset for HTTP/FTP range request resumption

Source

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

Source

pub fn get_bt_num_pieces(&self) -> u32

Get number of pieces (lock-free atomic read)

Source

pub fn get_bt_piece_length(&self) -> u32

Get piece length (lock-free atomic read)

Source

pub async fn get_bt_info_hash_hex_async(&self) -> Option<String>

Get info hash hex string (async-compatible wrapper)

Source

pub fn get_bt_info_hash_hex(&self) -> Option<String>

Get info hash hex string (blocking read for non-async contexts)

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