aboutsummaryrefslogtreecommitdiff
path: root/Types.hs
blob: 9b0bb00fd54aa970f16f4ad99b4b7ac4d5e1ffba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{- git-annex core data types -}

module Types (
	State(..),
	Key(..),
	Backend(..)
) where

import Data.String.Utils
import GitRepo

-- git-annex's runtime state
data State = State {
	repo :: GitRepo,
	backends :: [Backend]
} deriving (Show)

-- annexed filenames are mapped into keys
data Key = Key String deriving (Eq)

-- show a key to convert it to a string
instance Show Key where
	show (Key v) = v

-- this structure represents a key/value backend
data Backend = Backend {
	-- name of this backend
	name :: String,
	-- converts a filename to a key
	getKey :: State -> FilePath -> IO (Maybe Key),
	-- stores a file's contents to a key
	storeFileKey :: State -> FilePath -> Key -> IO Bool,
	-- retrieves a key's contents to a file
	retrieveKeyFile :: State -> Key -> FilePath -> IO Bool,
	-- removes a key
	removeKey :: State -> Key -> IO Bool
}

instance Show Backend where
	show backend = "Backend { name =\"" ++ (name backend) ++ "\" }"