summaryrefslogtreecommitdiff
path: root/vendor/git.iim.gay/grufwub/go-store/storage/transform.go
blob: 3863dd774dbfefe85409708a8999e06a14470249 (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
package storage

// KeyTransform defines a method of converting store keys to storage paths (and vice-versa)
type KeyTransform interface {
	// KeyToPath converts a supplied key to storage path
	KeyToPath(string) string

	// PathToKey converts a supplied storage path to key
	PathToKey(string) string
}

type nopKeyTransform struct{}

// NopTransform returns a nop key transform (i.e. key = path)
func NopTransform() KeyTransform {
	return &nopKeyTransform{}
}

func (t *nopKeyTransform) KeyToPath(key string) string {
	return key
}

func (t *nopKeyTransform) PathToKey(path string) string {
	return path
}