torrent-10000.1.3: BitTorrent file parser and generater

Safe Haskell | None
Language | Haskell2010

Data.Torrent

Description

BitTorrent metainfo files

http://www.bittorrent.org/beps/bep_0003.html

Synopsis

- data Torrent = Torrent {
  - tAnnounce :: Maybe ByteString
  - tAnnounceList :: [ByteString]
  - tComment :: ByteString
  - tCreatedBy :: Maybe ByteString
  - tInfo :: TorrentInfo
  }
- data TorrentInfo
  - = SingleFile {
    - tLength :: Integer
    - tName :: ByteString
    - tPieceLength :: Integer
    - tPieces :: ByteString
    }
  - | MultiFile {
    - tFiles :: [TorrentFile]
    - tName :: ByteString
    - tPieceLength :: Integer
    - tPieces :: ByteString
    }
- data TorrentFile = TorrentFile {
  - fileLength :: Integer
  - filePath :: [ByteString]
  }
- readTorrent :: ByteString -> Either String Torrent
- serializeTorrent :: Torrent -> BEncode
- torrentSize :: Torrent -> Integer
- showTorrent :: Torrent -> ByteString

# Documentation

data Torrent Source #

Constructors

Torrent |

Fields

- tAnnounce :: Maybe ByteString
- tAnnounceList :: [ByteString]
- tComment :: ByteString
- tCreatedBy :: Maybe ByteString
- tInfo :: TorrentInfo

#### Instances

Instances details

Binary Torrent Source # |
Instance details Defined in Data.Torrent Methods put :: Torrent -> Put Source # get :: Get Torrent Source # putList :: [Torrent] -> Put Source #
Data Torrent Source # |

Instance details

Defined in Data.Torrent

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Torrent -> c Torrent Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Torrent Source #

toConstr :: Torrent -> Constr Source #

dataTypeOf :: Torrent -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Torrent) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Torrent) Source #

gmapT :: (forall b. Data b => b -> b) -> Torrent -> Torrent Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Torrent -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Torrent -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Torrent -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Torrent -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Torrent -> m Torrent Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Torrent -> m Torrent Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Torrent -> m Torrent Source #

Read Torrent Source # |
Instance details Defined in Data.Torrent Methods readsPrec :: Int -> ReadS Torrent Source # readList :: ReadS [Torrent] Source # readPrec :: ReadPrec Torrent Source # readListPrec :: ReadPrec [Torrent] Source #
Show Torrent Source # |
Instance details Defined in Data.Torrent Methods showsPrec :: Int -> Torrent -> ShowS Source # show :: Torrent -> String Source # showList :: [Torrent] -> ShowS Source #

data TorrentInfo Source #

Constructors

SingleFile |

Fields

- tLength :: Integer
- tName :: ByteString
- tPieceLength :: Integer
- tPieces :: ByteString

MultiFile |

Fields

- tFiles :: [TorrentFile]
- tName :: ByteString
- tPieceLength :: Integer
- tPieces :: ByteString

#### Instances

Instances details

Data TorrentInfo Source # |

Instance details

Defined in Data.Torrent

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TorrentInfo -> c TorrentInfo Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TorrentInfo Source #

toConstr :: TorrentInfo -> Constr Source #

dataTypeOf :: TorrentInfo -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TorrentInfo) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TorrentInfo) Source #

gmapT :: (forall b. Data b => b -> b) -> TorrentInfo -> TorrentInfo Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TorrentInfo -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TorrentInfo -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TorrentInfo -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TorrentInfo -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TorrentInfo -> m TorrentInfo Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TorrentInfo -> m TorrentInfo Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TorrentInfo -> m TorrentInfo Source #

Read TorrentInfo Source # |
Instance details Defined in Data.Torrent Methods readsPrec :: Int -> ReadS TorrentInfo Source # readList :: ReadS [TorrentInfo] Source # readPrec :: ReadPrec TorrentInfo Source # readListPrec :: ReadPrec [TorrentInfo] Source #
Show TorrentInfo Source # |
Instance details Defined in Data.Torrent Methods showsPrec :: Int -> TorrentInfo -> ShowS Source # show :: TorrentInfo -> String Source # showList :: [TorrentInfo] -> ShowS Source #

data TorrentFile Source #

Constructors

TorrentFile |

Fields

- fileLength :: Integer
- filePath :: [ByteString]

#### Instances

Instances details

Data TorrentFile Source # |

Instance details

Defined in Data.Torrent

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TorrentFile -> c TorrentFile Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TorrentFile Source #

toConstr :: TorrentFile -> Constr Source #

dataTypeOf :: TorrentFile -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TorrentFile) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TorrentFile) Source #

gmapT :: (forall b. Data b => b -> b) -> TorrentFile -> TorrentFile Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TorrentFile -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TorrentFile -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TorrentFile -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TorrentFile -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TorrentFile -> m TorrentFile Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TorrentFile -> m TorrentFile Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TorrentFile -> m TorrentFile Source #

Read TorrentFile Source # |
Instance details Defined in Data.Torrent Methods readsPrec :: Int -> ReadS TorrentFile Source # readList :: ReadS [TorrentFile] Source # readPrec :: ReadPrec TorrentFile Source # readListPrec :: ReadPrec [TorrentFile] Source #
Show TorrentFile Source # |
Instance details Defined in Data.Torrent Methods showsPrec :: Int -> TorrentFile -> ShowS Source # show :: TorrentFile -> String Source # showList :: [TorrentFile] -> ShowS Source #

readTorrent :: ByteString -> Either String Torrent Source #

serializeTorrent :: Torrent -> BEncode Source #

torrentSize :: Torrent -> Integer Source #

Size of the files in the torrent.

showTorrent :: Torrent -> ByteString Source #

generates a torrent file

Due to lexographical ordering requirements of BEncoded data, this should generate the same ByteString that readTorrent read to generate the Torrent. However, torrent files may contain extensions and nonstandard fields that prevent that from holding for all torrent files.