src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/store/storedefs/storedefs.go (about) 1 // Package storedefs contains definitions of the store API. 2 // 3 // It is a separate package so that packages that only depend on the store API 4 // does not need to depend on the concrete implementation. 5 package storedefs 6 7 import "errors" 8 9 // NoBlacklist is an empty blacklist, to be used in GetDirs. 10 var NoBlacklist = map[string]struct{}{} 11 12 // ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query 13 // completes with no result. 14 var ErrNoMatchingCmd = errors.New("no matching command line") 15 16 // Store is an interface satisfied by the storage service. 17 type Store interface { 18 NextCmdSeq() (int, error) 19 AddCmd(text string) (int, error) 20 DelCmd(seq int) error 21 Cmd(seq int) (string, error) 22 CmdsWithSeq(from, upto int) ([]Cmd, error) 23 NextCmd(from int, prefix string) (Cmd, error) 24 PrevCmd(upto int, prefix string) (Cmd, error) 25 26 AddDir(dir string, incFactor float64) error 27 DelDir(dir string) error 28 Dirs(blacklist map[string]struct{}) ([]Dir, error) 29 } 30 31 // Dir is an entry in the directory history. 32 type Dir struct { 33 Path string 34 Score float64 35 } 36 37 func (Dir) IsStructMap() {} 38 39 // Cmd is an entry in the command history. 40 type Cmd struct { 41 Text string 42 Seq int 43 } 44 45 func (Cmd) IsStructMap() {}