Portability | GHC |
---|---|
Stability | experimental |
Maintainer | Florian Hartwig <florian.j.hartwig@gmail.com> |
Safe Haskell | None |
Data.AttoBencode
Description
- data BValue
- type Dict = Map ByteString BValue
- decode :: FromBencode a => ByteString -> Maybe a
- encode :: ToBencode a => a -> ByteString
- class FromBencode a where
- fromBencode :: BValue -> Maybe a
- class ToBencode a where
- (.:) :: FromBencode a => Dict -> ByteString -> Maybe a
- dict :: [(ByteString, BValue)] -> BValue
- (.=) :: ToBencode a => ByteString -> a -> (ByteString, BValue)
BEncode Types
The Haskell data type for Bencode values
type Dict = Map ByteString BValueSource
A Bencode dictionary. Dictionaries have ByteString
keys and BValue
values.
Encoding and Decoding
decode :: FromBencode a => ByteString -> Maybe aSource
Deserialise a bencoded ByteString. If parsing or conversion fails, Nothing is returned.
encode :: ToBencode a => a -> ByteStringSource
Serialise a Bencode value to a (strict) ByteString
class FromBencode a whereSource
A type that can be converted from a BValue
. The conversion can fail.
Methods
fromBencode :: BValue -> Maybe aSource
Instances
A type that can be converted to a BValue
.
Convencience Functions
(.:) :: FromBencode a => Dict -> ByteString -> Maybe aSource
dict :: [(ByteString, BValue)] -> BValueSource
Make a BDict from a list of (key, value) tuples.
(.=) :: ToBencode a => ByteString -> a -> (ByteString, BValue)Source