package bencode

  1. Overview
  2. Docs
On This Page
  1. Helpers
Bencode (`.torrent` file format) reader/writer in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

2.0.tar.gz
md5=80a4d59a246c31df45a42779c777bb28
sha512=687544db98ca47ecd55c8235e751b04df58fd5aba1270dcc93e19629f483f33232ac3779c0e07d0fdb67ea958156113143b0bd3b8640478928b591092d327d12

doc/bencode/Bencode/index.html

Module BencodeSource

Read and write bencode files in OCaml

Sourcetype t =
  1. | Integer of int64
  2. | String of string
  3. | List of t list
  4. | Dict of (string * t) list
Sourcetype src = [
  1. | `Channel of in_channel
  2. | `File_path of string
  3. | `String of string
]
Sourcetype dst = [
  1. | `Channel of out_channel
  2. | `File_path of string
  3. | `Buffer of Buffer.t
]
Sourceval eq : t -> t -> bool
Sourceval hash : t -> int
Sourceval dict_of_list : (string * t) list -> t

sort list and wrap it in Dict. The list should not contain the same key twice.

pretty_print is not tail recursive (or pretty)

Sourceval pp_hum : Format.formatter -> t -> unit

pp_hum fmt tree is the bencode tree pretty-printed in a human-readable format on fmt.

  • since 2.0
Sourceval pretty_print : t -> string

Simple pretty printer to strings

Sourceval decode : [< src ] -> t

encode is not tail recursive

Sourceval encode : [< dst ] -> t -> unit

encode_to_string is not tail recursive

Sourceval encode_to_string : t -> string
Sourcetype 'a sequence = ('a -> unit) -> unit
Sourceval decode_seq : [< src ] -> t sequence
Sourceval encode_seq : [< dst ] -> t sequence -> unit

Helpers

Sourceval as_string : t -> string option
Sourceval as_int : t -> int64 option
Sourceval as_list : t -> t list option
Sourceval as_dict : t -> (string * t) list option
Sourceval dict_get : t -> string -> t option