File: Backend.hs

package info (click to toggle)
git-annex 10.20250416-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 73,572 kB
  • sloc: haskell: 90,656; javascript: 9,103; sh: 1,469; makefile: 211; perl: 137; ansic: 44
file content (50 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download | duplicates (3)
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
41
42
43
44
45
46
47
48
49
50
{- git-annex key backend data type
 -
 - Most things should not need this, using Types instead
 -
 - Copyright 2010-2024 Joey Hess <id@joeyh.name>
 -
 - Licensed under the GNU AGPL version 3 or higher.
 -}

module Types.Backend where

import Types.Key
import Types.KeySource
import Utility.Metered
import Utility.OsPath
import Utility.FileSystemEncoding
import Utility.Hash (IncrementalVerifier)

data BackendA a = Backend
	{ backendVariety :: KeyVariety
	, genKey :: Maybe (KeySource -> MeterUpdate -> a Key)
	-- Verifies the content of a key, stored in a file, using a hash.
	-- This does not need to be cryptographically secure.
	, verifyKeyContent :: Maybe (Key -> OsPath -> a Bool)
	-- Incrementally verifies the content of a key, using the same
	-- hash as verifyKeyContent, but with the content provided
	-- incrementally a piece at a time, until finalized.
	, verifyKeyContentIncrementally :: Maybe (Key -> a IncrementalVerifier)
	-- Checks if a key can be upgraded to a better form.
	, canUpgradeKey :: Maybe (Key -> Bool)
	-- Checks if there is a fast way to migrate a key to a different
	-- backend (ie, without re-hashing).
	-- The Bool is true if the content of the key has been verified to
	-- be inAnnex.
	, fastMigrate :: Maybe (Key -> BackendA a -> AssociatedFile -> Bool -> a (Maybe Key))
	-- Checks if a key is known (or assumed) to always refer to the
	-- same data.
	, isStableKey :: Key -> Bool
	-- Are all keys using this backend verified using a cryptographically
	-- secure hash?
	, isCryptographicallySecure :: Bool
	-- Checks if a key is verified using a cryptographically secure hash.
	, isCryptographicallySecureKey :: Key -> a Bool
	}

instance Show (BackendA a) where
	show backend = "Backend { name =\"" ++ decodeBS (formatKeyVariety (backendVariety backend)) ++ "\" }"

instance Eq (BackendA a) where
	a == b = backendVariety a == backendVariety b