diff options
author | Joey Hess <joey@kitenet.net> | 2010-10-14 02:52:17 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-10-14 02:52:17 -0400 |
commit | 0b55bd05de7b83a474ea58e9d45676934667f4bd (patch) | |
tree | 1e2373381a650d0c2c5c1bc6c5cffa58cf922989 /BackendTypes.hs | |
parent | 4c1d8b9689043c18214b1da7d5c145fb0859443d (diff) |
more namespace cleanup
Diffstat (limited to 'BackendTypes.hs')
-rw-r--r-- | BackendTypes.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/BackendTypes.hs b/BackendTypes.hs new file mode 100644 index 000000000..2ef65f469 --- /dev/null +++ b/BackendTypes.hs @@ -0,0 +1,44 @@ +{- git-annex backend data types + - + - Mostly only backend implementations should need to import this. + -} + +module BackendTypes where + +import Control.Monad.State +import Data.String.Utils +import qualified GitRepo as Git + +-- git-annex's runtime state type doesn't really belong here, +-- but it uses Backend, so has to be here to avoid a depends loop. +data AnnexState = AnnexState { + repo :: Git.Repo, + backends :: [Backend] +} deriving (Show) + +-- git-annex's monad +type Annex = StateT AnnexState IO + +-- 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 :: FilePath -> Annex (Maybe Key), + -- stores a file's contents to a key + storeFileKey :: FilePath -> Key -> Annex Bool, + -- retrieves a key's contents to a file + retrieveKeyFile :: Key -> FilePath -> Annex Bool, + -- removes a key + removeKey :: Key -> Annex Bool +} + +instance Show Backend where + show backend = "Backend { name =\"" ++ (name backend) ++ "\" }" |