Debian Codegraph @

storage/storage.go

raw
1 package storage
2
3 import "io"
4
5 // Storage implements an interface for reading, but not writing, objects in an
6 // object database.
7 type Storage interface {
8 // Open returns a handle on an existing object keyed by the given object
9 // ID. It returns an error if that file does not already exist.
10 Open(oid []byte) (f io.ReadCloser, err error)
11
12 // Close closes the filesystem, after which no more operations are
13 // allowed.
14 Close() error
15
16 // Compressed indicates whether data read from this storage source will
17 // be zlib-compressed.
18 IsCompressed() bool
19 }
20
21 // WritableStorage implements an interface for reading and writing objects in
22 // an object database.
23 type WritableStorage interface {
24 Storage
25
26 // Store copies the data given in "r" to the unique object path given by
27 // "oid". It returns an error if that file already exists (acting as if
28 // the `os.O_EXCL` mode is given in a bitmask to os.Open).
29 Store(oid []byte, r io.Reader) (n int64, err error)
30 }