rtorrent-rpc-0.2.2.0: A library for communicating with RTorrent over its XML-RPC interface.

Copyright(c) Kai Lindholm, 2014
LicenseMIT
Maintainermegantti@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Network.RTorrent.Action

Description

Action is a command acting on various kinds of objects:

They all have the property that they can be executed on a single object or on a group of objects.

For example,

callRTorrent "localhost" 5000 $ some_action (some_id :: SomeId)

is a valid thing to write when some is one of the previous objects.

To call an action on all torrents, you can use allTorrents, so that

callRTorrent "localhost" 5000 $ allTorrents getTorrentId

will return a list of torrent ids.

To call a action on other types of objects, you can use allPeers, allFiles, or allTrackers, which will act on all peers, files, or trackers that are associated to a torrent. They will also return ids for each object. Then for example

allFiles getFileSizeBytes :: TorrentId -> TorrentAction [FileId :*: Int]

is an action that will return a list of ids and file sizes when run on a torrent. These can further be used with allTorrents.

To combine actions, you can use <+> and sequenceActions which correspond to :*: and [] for commands.

In order to write new actions, simpleAction can be used.

Synopsis

Documentation

data Action i a Source

A type for actions that can act on different things like torrents and files.

a is the return type.

Instances

Functor (Action i) 
XmlRpcType i => Command (Action i a) 
type Ret (Action i a) = a 

simpleAction :: XmlRpcType a => String -> [Param] -> i -> Action i a Source

A simple action that can be used when constructing new ones.

Watch out for using Bool as a since using it with this function will probably result in an error, since RTorrent actually returns 0 or 1 instead of a bool. One workaround is to get an Int and use Bool's Enum instance.

pureAction :: a -> i -> Action i a Source

An action that does nothing but return the value.

sequenceActions :: Traversable f => f (i -> Action i a) -> i -> Action i (f a) Source

Sequence multiple actions, for example with f = [].

(<+>) :: (i -> Action i a) -> (i -> Action i b) -> i -> Action i (a :*: b) infixr 6 Source

Combine two actions to get a new one.

newtype ActionB i a Source

Wrapper to get monoid and applicative instances.

Constructors

ActionB 

Fields

runActionB :: i -> Action i a
 

Instances