Module bencoding

A Bencoding library based on: The BitTorrent specification.

Copyright © (C) 2018-2020, Jan Henry Nystrom <JanHenryNystrom@gmail.com> -------------------------------------------------------------------

Authors: Jan Henry Nystrom (JanHenryNystrom@gmail.com).

Description

A Bencoding library based on: The BitTorrent specification

Bencoding is represented as follows:

Byte string : binary (octets) Integer : integer List : list Dictionary : map

Data Types

bencoding()

bencoding() = binary() | integer() | list() | map()

opt()

opt() = binary | iolist | continue

Function Index

decode/1 Decodes the iodata into a structured Erlang term.
decode/2 Decodes the iodata into a structured Erlang term.
encode/1 Encodes the structured Erlang term as an iolist.
encode/2 Encodes the structured Erlang term as an iolist or binary.

Function Details

decode/1

decode(Binary::binary()) -> bencoding()

Decodes the iodata into a structured Erlang term. Equivalent of decode(JSON, []) -> Term.

decode/2

decode(Binary::binary(), Opts::[opt()]) -> bencoding() | {bencoding(), binary()}

Decodes the iodata into a structured Erlang term. Options are: continue -> return the tuple of the decoded Bencoding and the remaining binary

encode/1

encode(Term::bencoding()) -> iolist()

Encodes the structured Erlang term as an iolist. Equivalent of encode(Term, []) -> Bencoding.

encode/2

encode(Term::bencoding(), Opts::[opt()]) -> iolist() | binary()

Encodes the structured Erlang term as an iolist or binary. Encode will give an exception if the erlang term is not well formed. Options are: binary -> a binary is returned iolist -> an iolist is returned (default)


Generated by EDoc