Skip to content

Introduce typed TorrentSource for adding torrents #224

Description

@artrixdotdev

Problem

Engine::add_torrent currently accepts impl ToString and guesses source type with string prefixes like http and magnet:. A frontend should pass typed intent instead of relying on string heuristics.

Relevant code:

  • crates/libtortillas/src/engine/mod.rs:254

Dependency

Blocked by #222 because TorrentSource should be part of the stable facade.

Proposal

Add a typed source enum, for example:

pub enum TorrentSource {
    Magnet(String),
    TorrentFilePath(PathBuf),
    TorrentFileBytes(Bytes),
    RemoteTorrentUrl(String),
}

Exact variants can differ, but source type should be explicit.

Acceptance criteria

  • Adding a torrent no longer requires source detection from arbitrary strings.
  • Invalid source/type combinations return typed errors.
  • Existing path, magnet, and remote torrent behavior remains covered by tests.
  • API docs show how a TUI should add torrents from user input.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthigh prioGET DONE ASAP!!libtortillasChanges in the libtortillas craterustPull requests that update rust codetui-foundationWork needed before building the Tortillas TUI

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions