summaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-07-21 00:48:19 +0400
committerSam T <pxqr.sta@gmail.com>2013-07-21 00:48:19 +0400
commit9101056298bbbd891b6134c45b63146c2b2125e2 (patch)
tree8bace6ba2831f6e1448bae50dba8bf0b0dccf12a /src/Data
parent8fe68502f23cd737cfd198ce63ae8522c8e11a7f (diff)
+ Add JSON instances for Tracker info.
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Torrent.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs
index a1df0034..1dab1541 100644
--- a/src/Data/Torrent.hs
+++ b/src/Data/Torrent.hs
@@ -16,13 +16,14 @@
16-- <http://www.bittorrent.org/beps/bep_0003.html#metainfo-files>, 16-- <http://www.bittorrent.org/beps/bep_0003.html#metainfo-files>,
17-- <https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure> 17-- <https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure>
18-- 18--
19{-# OPTIONS -fno-warn-orphans #-} 19{-# LANGUAGE OverloadedStrings #-}
20{-# LANGUAGE CPP #-} 20{-# LANGUAGE RecordWildCards #-}
21{-# LANGUAGE FlexibleInstances #-} 21{-# LANGUAGE CPP #-}
22{-# LANGUAGE OverloadedStrings #-} 22{-# LANGUAGE FlexibleInstances #-}
23{-# LANGUAGE RecordWildCards #-} 23{-# LANGUAGE BangPatterns #-}
24{-# LANGUAGE BangPatterns #-} 24{-# LANGUAGE GeneralizedNewtypeDeriving #-}
25{-# LANGUAGE TemplateHaskell #-} 25{-# LANGUAGE TemplateHaskell #-}
26{-# OPTIONS -fno-warn-orphans #-}
26-- TODO refine interface 27-- TODO refine interface
27module Data.Torrent 28module Data.Torrent
28 ( -- * Torrent 29 ( -- * Torrent
@@ -69,6 +70,7 @@ import Control.Monad
69 70
70import qualified Crypto.Hash.SHA1 as C 71import qualified Crypto.Hash.SHA1 as C
71 72
73import Data.Aeson
72import Data.Aeson.TH 74import Data.Aeson.TH
73import Data.BEncode as BE 75import Data.BEncode as BE
74import Data.Char 76import Data.Char
@@ -98,7 +100,7 @@ import Numeric
98 100
99-- | Exactly 20 bytes long SHA1 hash of the info part of torrent file. 101-- | Exactly 20 bytes long SHA1 hash of the info part of torrent file.
100newtype InfoHash = InfoHash { getInfoHash :: ByteString } 102newtype InfoHash = InfoHash { getInfoHash :: ByteString }
101 deriving (Eq, Ord) 103 deriving (Eq, Ord, ToJSON, FromJSON)
102 104
103instance Show InfoHash where 105instance Show InfoHash where
104 show = render . ppInfoHash 106 show = render . ppInfoHash