Skip to main content

AddTorrentParams

Struct AddTorrentParams 

Source
pub struct AddTorrentParams {
    pub source: AddSource,
    pub category: Option<String>,
    pub tags: Vec<String>,
    pub download_dir: Option<PathBuf>,
    pub paused: Option<bool>,
    pub skip_checking: bool,
}
Expand description

Unified parameters for SessionHandle::add_torrent (M170).

Replaces the ad-hoc set of add_magnet, add_magnet_uri, add_torrent_bytes call shapes with a single params struct. Callers build the struct via the static constructors (magnet or bytes) and chain .with_category() / .with_tags() / .with_download_dir() / .paused().

Download-dir resolution (see add_torrent):

  1. download_dir: Some(p) wins, if set.
  2. Else, if category: Some(name) and the registry contains name, the registry’s save_path is used.
  3. Else, if category: Some(name) and the registry does NOT contain name, the call fails with [Error::CategoryNotFound].
  4. Else, falls back to Settings.download_dir.

skip_checking is reserved for M171+ (qBt skip_hash_check=true).

Fields§

§source: AddSource

The torrent source (magnet URI or raw .torrent bytes).

§category: Option<String>

Optional qBt-compat category label resolved via the session’s CategoryRegistry at add-time.

§tags: Vec<String>

M171: Per-torrent tags baked in at add time (qBt-compat). Multi- valued. An empty vec means “no tags” and is the default.

§download_dir: Option<PathBuf>

Explicit download directory, overrides both category lookup and Settings.download_dir when Some.

§paused: Option<bool>

Whether the torrent should be added in a paused state. None (the constructor default) means “use Settings::default_add_paused”; Some(v) is an explicit per-call override. The resolution happens in dispatch_add_torrent_m170 before the M170 post-add hooks run, so the actor sees a concrete bool either way.

§skip_checking: bool

Reserved for M171+ — skip the initial re-hash on add.

Implementations§

Source§

impl AddTorrentParams

Source

pub fn magnet(uri: impl Into<String>) -> Self

Build a magnet-source add with default knobs.

Source

pub fn bytes(data: impl Into<Vec<u8>>) -> Self

Build a bytes-source add with default knobs.

Source

pub fn with_category(self, name: impl Into<String>) -> Self

Assign a category label to the torrent. The session resolves the name against its registry at add-time; unknown names error out.

Source

pub fn with_tags(self, tags: Vec<String>) -> Self

M171: Attach tags at add time. Tags are baked into the torrent’s config before TorrentActor::new, so the first stats() call returns them — no post-add spawn race.

Source

pub fn with_download_dir(self, dir: impl Into<PathBuf>) -> Self

Override the download directory for this torrent.

Source

pub fn paused(self, paused: bool) -> Self

Toggle the paused-at-add flag. Wraps the explicit choice in Some(_) so the actor can distinguish “caller explicitly set this” from “caller did not touch it” (the latter falls back to Settings::default_add_paused).

Source

pub fn skip_checking(self, skip: bool) -> Self

Toggle the skip-initial-check flag (M171+).

Trait Implementations§

Source§

impl Clone for AddTorrentParams

Source§

fn clone(&self) -> AddTorrentParams

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AddTorrentParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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: 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: 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<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