bencoding

A library for encoding and decoding of BEncode data. https://github.com/cobit/bencoding

Latest on Hackage:0.4.3.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Sam Truzjan
Maintained by Sam Truzjan

Synopsis

BEncode is JSON-like format used in bittorrent protocol but might be used anywhere else.

Description

This package implements fast seamless encoding/decoding to/from bencode format for many native datatypes. To achive more performance we use bytestring builders and hand optimized attoparsec parser so this library is considered as replacement for BEncode and AttoBencode packages.

Format

Bencode is pretty similar to JSON: it has dictionaries(JSON objects), lists(JSON arrays), strings and integers. However bencode has a few advantages:

  • Compactness: no spaces in between any values — nor lists nor dicts nor anywhere else.
  • Dictionaries always sorted lexicographically by the keys. This allow us to test data on equality without decoding from raw bytestring. Moreover this allow to hash encoded data (this property is heavily used by core bittorrent protocol).
  • All strings prefixed with its length. This simplifies and speed up string parsing.

Hovewer there are some disadvantages comparing with JSON:

  • Bencode is certainly less human readable.
  • Bencode is rarely used, except bittorrent protocol of course.

Documentation

For documentation see package hackage page.

Build Status

Build Status

Maintainer

Feel free to report bugs and suggestions via issue tracker or the mail.

Changes

2013-12-19 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.3.0: Add lookAhead and match functions.

2013-12-16 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.2.1: Override default Monad(fail) method so it is possible
to catch Get monad failures from pure code.

2013-12-14 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.2.0: Override default fixity for operators: previously it
has been impossible to mix bencode Get operators ((<$>!), (<$>?),
(<*>!), (<*>?)) with applicative operators ((<$>), (<*>)).

2013-12-08 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.1.0: Expose parser and builder so it is possible to use
parser incrementally.

2013-10-01 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.0.2: Minor fixes.

2013-10-01 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.0.1: Nothing changed.

2013-10-01 Sam Truzjan <pxqr.sta@gmail.com>

* 0.4.0.0: Faster dictionary conversion.

2013-09-28 Sam Truzjan <pxqr.sta@gmail.com>

* 0.3.0.0: Rename BEncode to BValue and BEncodable to BEncode.

2013-09-28 Sam Truzjan <pxqr.sta@gmail.com>

* 0.2.2.0: Arbitrary length integers. (by specification)

2013-08-26 Sam Truzjan <pxqr.sta@gmail.com>

* 0.2.0.0: Added default decoders/encoders using GHC Generics.

2013-06-09 Sam Truzjan <pxqr.sta@gmail.com>

* 0.1.0.0: Initial version.
comments powered byDisqus