-
Notifications
You must be signed in to change notification settings - Fork 0
/
storedefs.go
49 lines (39 loc) · 1.29 KB
/
storedefs.go
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
// Package storedefs contains definitions of the store API.
//
// It is a separate package so that packages that only depend on the store API
// does not need to depend on the concrete implementation.
package storedefs
import "errors"
// NoBlacklist is an empty blacklist, to be used in GetDirs.
var NoBlacklist = map[string]struct{}{}
// ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query
// completes with no result.
var ErrNoMatchingCmd = errors.New("no matching command line")
// Store is an interface satisfied by the storage service.
type Store interface {
NextCmdSeq() (int, error)
AddCmd(text string) (int, error)
DelCmd(seq int) error
Cmd(seq int) (string, error)
CmdsWithSeq(from, upto int) ([]Cmd, error)
NextCmd(from int, prefix string) (Cmd, error)
PrevCmd(upto int, prefix string) (Cmd, error)
AddDir(dir string, incFactor float64) error
DelDir(dir string) error
Dirs(blacklist map[string]struct{}) ([]Dir, error)
SharedVar(name string) (string, error)
SetSharedVar(name, value string) error
DelSharedVar(name string) error
}
// Dir is an entry in the directory history.
type Dir struct {
Path string
Score float64
}
func (Dir) IsStructMap() {}
// Cmd is an entry in the command history.
type Cmd struct {
Text string
Seq int
}
func (Cmd) IsStructMap() {}