Struct lava_torrent::torrent::v1::TorrentBuilder [] [src]

pub struct TorrentBuilder { /* fields omitted */ }

Builder for creating Torrents from files.

This struct is used for creating Torrents, so that you can encode/serialize them to .torrent files. If you want to read existing .torrent files then use Torrent::read_from_file() or Torrent::read_from_bytes().

Required fields: announce, path, and piece_length. They are set when calling the constructor new().

Optional fields can be set by calling the corresponding methods (e.g. set_announce()). Fields can be updated in the same way.

Notes

*nix hidden files/dirs are ignored.

Reasoning: when handling these special "files", there are many decisions to make:

  • Should they be ignored, included, or selectively ignored/included?
  • Should included/ignored entries be marked specially (e.g. BEP 47)?
  • Should users be allowed to configure the settings?
  • If users can configure the settings, what would be the ideal defaults?
  • ...

Apparently it's not easy to make these decisions. Therefore these files are ignored for now. Clients like Deluge and qBittorrent also ignore hidden entries.

Methods

impl TorrentBuilder
[src]

[src]

Create a new TorrentBuilder with required fields set.

The caller has to ensure that the inputs are valid, as this method does not validate its inputs. If they turn out to be invalid, calling build() later will fail.

Notes

  • path must be absolute.

  • A valid piece_length is larger than 0 AND is a power of 2.

  • Using a path containing hidden components will make build() return Err. This is *nix-specific. Hidden components are those that start with ..

  • Paths with components exactly matching .. are invalid.

[src]

Build a Torrent from this TorrentBuilder.

If name is not set, then the last component of path will be used as the Torrent's name field.

build() does not provide comprehensive validation of any input. Basic cases such as setting announce to an empty string will be detected and Err will be returned. But more complicated cases such as using an invalid url as announce won't be detected. Again, the caller has to ensure that the values given to a TorrentBuilder are valid.

[src]

Set the announce field of the Torrent to be built.

Calling this method multiple times will simply override previous settings.

The caller has to ensure that announce is valid, as this method does not validate its value. If announce turns out to be invalid, calling build() later will fail.

[src]

Set the announce_list field of the Torrent to be built.

Calling this method multiple times will simply override previous settings.

The caller has to ensure that announce_list is valid, as this method does not validate its value. If announce_list turns out to be invalid, calling build() later will fail.

[src]

Set the name field of the Torrent to be built.

Calling this method multiple times will simply override previous settings.

The caller has to ensure that name is valid, as this method does not validate its value. If name turns out to be invalid, calling build() later will fail.

[src]

Set the path to the file(s) from which the Torrent will be built.

Calling this method multiple times will simply override previous settings.

The caller has to ensure that path is valid, as this method does not validate its value. If path turns out to be invalid, calling build() later will fail.

Notes

  • path must be absolute.

  • Using a path containing hidden components will make build() return Err. This is *nix-specific. Hidden components are those that start with ..

  • Paths with components exactly matching .. are invalid.

[src]

Set the piece_length field of the Torrent to be built.

Calling this method multiple times will simply override previous settings.

The caller has to ensure that piece_length is valid, as this method does not validate its value. If piece_length turns out to be invalid, calling build() later will fail.

NOTE: A valid piece_length is larger than 0 AND is a power of 2.

[src]

Add an extra field to Torrent (i.e. to the root dictionary).

Calling this method multiple times with the same key will simply override previous settings.

The caller has to ensure that key and val are valid, as this method does not validate their values. If they turn out to be invalid, calling build() later will fail.

[src]

Add an extra info field to Torrent (i.e. to the info dictionary).

Calling this method multiple times with the same key will simply override previous settings.

The caller has to ensure that key and val are valid, as this method does not validate their values. If they turn out to be invalid, calling build() later will fail.

[src]

Make the Torrent private or public, as defined in BEP 27.

Calling this method multiple times will simply override previous settings.

Trait Implementations

impl Clone for TorrentBuilder
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for TorrentBuilder
[src]

[src]

Formats the value using the given formatter. Read more

impl Default for TorrentBuilder
[src]

[src]

Returns the "default value" for a type. Read more

impl Eq for TorrentBuilder
[src]

impl PartialEq for TorrentBuilder
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

Auto Trait Implementations