github.com/advanderveer/restic@v0.8.1-0.20171209104529-42a8c19aaea6/internal/restic/repository.go (about) 1 package restic 2 3 import ( 4 "context" 5 6 "github.com/restic/restic/internal/crypto" 7 ) 8 9 // Repository stores data in a backend. It provides high-level functions and 10 // transparently encrypts/decrypts data. 11 type Repository interface { 12 13 // Backend returns the backend used by the repository 14 Backend() Backend 15 16 Key() *crypto.Key 17 18 SetIndex(Index) 19 20 Index() Index 21 SaveFullIndex(context.Context) error 22 SaveIndex(context.Context) error 23 LoadIndex(context.Context) error 24 25 Config() Config 26 27 LookupBlobSize(ID, BlobType) (uint, error) 28 29 List(context.Context, FileType) <-chan ID 30 ListPack(context.Context, ID) ([]Blob, int64, error) 31 32 Flush(context.Context) error 33 34 SaveUnpacked(context.Context, FileType, []byte) (ID, error) 35 SaveJSONUnpacked(context.Context, FileType, interface{}) (ID, error) 36 37 LoadJSONUnpacked(context.Context, FileType, ID, interface{}) error 38 LoadAndDecrypt(context.Context, FileType, ID) ([]byte, error) 39 40 LoadBlob(context.Context, BlobType, ID, []byte) (int, error) 41 SaveBlob(context.Context, BlobType, []byte, ID) (ID, error) 42 43 LoadTree(context.Context, ID) (*Tree, error) 44 SaveTree(context.Context, *Tree) (ID, error) 45 } 46 47 // Lister allows listing files in a backend. 48 type Lister interface { 49 List(context.Context, FileType) <-chan string 50 } 51 52 // Index keeps track of the blobs are stored within files. 53 type Index interface { 54 Has(ID, BlobType) bool 55 Lookup(ID, BlobType) ([]PackedBlob, error) 56 Count(BlobType) uint 57 58 // Each returns a channel that yields all blobs known to the index. When 59 // the context is cancelled, the background goroutine terminates. This 60 // blocks any modification of the index. 61 Each(ctx context.Context) <-chan PackedBlob 62 }