github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/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 SharedVar(name string) (string, error) 31 SetSharedVar(name, value string) error 32 DelSharedVar(name string) error 33 } 34 35 // Dir is an entry in the directory history. 36 type Dir struct { 37 Path string 38 Score float64 39 } 40 41 func (Dir) IsStructMap() {} 42 43 // Cmd is an entry in the command history. 44 type Cmd struct { 45 Text string 46 Seq int 47 } 48 49 func (Cmd) IsStructMap() {}