Package-level declarations

Types

Link copied to clipboard
object Bdecode

Bencode decoder, the port of libtorrent's bdecode() (src/bdecode.cpp). Parses a bencoded buffer into a BdecodeNode tree whose nodes reference back into the original ByteArray (no copies of the payload are made until you ask for them).

Link copied to clipboard

Bdecode error codes. This is a direct port of libtorrent's bdecode_errors::error_code_enum (bdecode.hpp). BdecodeException carries one of these plus the byte offset where parsing failed, mirroring libtorrent's error_code + error_pos.

Link copied to clipboard
class BdecodeException(val error: BdecodeError, val position: Int) : Exception

Thrown by Bdecode.decode when the input is not valid bencoding.

Link copied to clipboard

A node in the tree produced by Bdecode.decode. The port of libtorrent's bdecode_node (bdecode.hpp). Every node keeps a reference to the original parsed buffer plus the byte span it occupies, so dataSection can hand back the exact bytes a node was parsed from. That is what makes correct info-hashing possible: the v1 info-hash is SHA-1(info-dict's dataSection).

Link copied to clipboard
object Bencode

Bencode encoder, the port of libtorrent's bencode() and bencode_recursive (bencode.hpp). Turns an Entry tree into canonical bencoded bytes.

Link copied to clipboard
sealed class Entry

One node in a bencoded hierarchy: the owning variant type, the port of libtorrent's entry (entry.hpp). Use this to build structures (a torrent file, a DHT message, resume data) and hand them to Bencode.encode.