mem

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2022 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryBackend

type MemoryBackend struct {
	// contains filtered or unexported fields
}

MemoryBackend is a mock backend that uses a map for storing all data in memory. This should only be used for tests.

func New

func New() *MemoryBackend

New returns a new backend that saves all data in a map in memory.

func (*MemoryBackend) Close

func (be *MemoryBackend) Close() error

Close closes the backend.

func (*MemoryBackend) Delete

func (be *MemoryBackend) Delete(ctx context.Context) error

Delete removes all data in the backend.

func (*MemoryBackend) Hasher added in v0.13.0

func (be *MemoryBackend) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*MemoryBackend) IsNotExist

func (be *MemoryBackend) IsNotExist(err error) bool

IsNotExist returns true if the file does not exist.

func (*MemoryBackend) List

func (be *MemoryBackend) List(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error

List returns a channel which yields entries from the backend.

func (*MemoryBackend) Load

func (be *MemoryBackend) Load(ctx context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*MemoryBackend) Location

func (be *MemoryBackend) Location() string

Location returns the location of the backend (RAM).

func (*MemoryBackend) Remove

func (be *MemoryBackend) Remove(ctx context.Context, h restic.Handle) error

Remove deletes a file from the backend.

func (*MemoryBackend) Save

Save adds new Data to the backend.

func (*MemoryBackend) Stat

Stat returns information about a file in the backend.

func (*MemoryBackend) Test

func (be *MemoryBackend) Test(ctx context.Context, h restic.Handle) (bool, error)

Test returns whether a file exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL