1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-23 00:00:04 +01:00
restic/internal/restic/backend.go

55 lines
1.6 KiB
Go
Raw Normal View History

package restic
2017-06-03 17:39:57 +02:00
import (
"context"
"io"
)
// Backend is used to store and access data.
type Backend interface {
// Location returns a string that describes the type and location of the
// repository.
Location() string
2016-08-31 20:29:54 +02:00
// Test a boolean value whether a File with the name and type exists.
2017-06-03 17:39:57 +02:00
Test(ctx context.Context, h Handle) (bool, error)
2017-12-22 18:34:17 +01:00
// Remove removes a File described by h.
2017-06-03 17:39:57 +02:00
Remove(ctx context.Context, h Handle) error
// Close the backend
Close() error
// Save stores the data in the backend under the given handle.
2017-06-03 17:39:57 +02:00
Save(ctx context.Context, h Handle, rd io.Reader) error
2017-01-23 18:11:10 +01:00
// Load returns a reader that yields the contents of the file at h at the
2017-01-23 17:20:08 +01:00
// given offset. If length is larger than zero, only a portion of the file
// is returned. rd must be closed after use. If an error is returned, the
// ReadCloser must be nil.
2017-06-03 17:39:57 +02:00
Load(ctx context.Context, h Handle, length int, offset int64) (io.ReadCloser, error)
2017-01-22 22:01:12 +01:00
2016-08-31 20:29:54 +02:00
// Stat returns information about the File identified by h.
2017-06-03 17:39:57 +02:00
Stat(ctx context.Context, h Handle) (FileInfo, error)
// List runs fn for each file in the backend which has the type t. When an
// error occurs (or fn returns an error), List stops and returns it.
2018-01-23 21:21:54 +01:00
//
// The function fn is called in the same Goroutine that List() is called
// from.
List(ctx context.Context, t FileType, fn func(FileInfo) error) error
2017-06-15 13:40:27 +02:00
// IsNotExist returns true if the error was caused by a non-existing file
// in the backend.
IsNotExist(err error) bool
// Delete removes all data in the backend.
Delete(ctx context.Context) error
}
// FileInfo is contains information about a file in the backend.
type FileInfo struct {
Size int64
Name string
}