Documentation ¶
Overview ¶
Package blob defines a common data interchange type for keyvalue FS's.
Index ¶
- func Grow(b Blob, offset int64) error
- func Set(dest Blob, src Blob, offset int64) (n int, err error)
- func Truncate(b Blob, size int64) error
- func Write(dest io.Writer, src Blob) (n int, err error)
- func WriteAt(dest io.WriterAt, src Blob, destOffset int64) (n int, err error)
- type Blob
- type Bytes
- func (b *Bytes) Bytes() []byte
- func (b *Bytes) Grow(offset int64) error
- func (b *Bytes) Len() int
- func (b *Bytes) Set(src Blob, destStart int64) (n int, err error)
- func (b *Bytes) Slice(start, end int64) (Blob, error)
- func (b *Bytes) Truncate(size int64) error
- func (b *Bytes) View(start, end int64) (Blob, error)
- type GrowBlob
- type Reader
- type ReaderAt
- type SetBlob
- type SliceBlob
- type TruncateBlob
- type ViewBlob
- type Writer
- type WriterAt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Grow ¶
Grow attempts to call an optimized blob.Grow(), falls back to copying into Bytes and running Bytes.Grow().
func Set ¶
Set attempts to call an optimized blob.Set(), falls back to copying into Bytes and running Bytes.Set().
func Truncate ¶
Truncate attempts to call an optimized blob.Truncate(), falls back to copying into Bytes and running Bytes.Truncate().
Types ¶
type Blob ¶
type Blob interface { // Bytes returns the byte slice equivalent to the data in this Blob. Bytes() []byte // Len returns the number of bytes contained in this blob. // Can be used to avoid unnecessary conversions and allocations from len(Bytes()). Len() int }
Blob is a binary blob of data that can support platform-optimized mutations for better performance.
func Read ¶
Read reads 'src' into a new Blob up to length bytes. Attempts to use an optimized ReadBlob if available.
func ReadAt ¶
ReadAt reads 'src' into a new Blob up to length bytes starting at 'srcOffset'. Attempts to use an optimized ReadBlobAt if available.
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes is a Blob that wraps a byte slice.
func NewBytes ¶
NewBytes returns a Blob that wraps the given byte slice. Mutations to this Blob are reflected in the original slice.
func NewBytesLength ¶
NewBytesLength returns a new Bytes with the given length of zero-byte data.
type GrowBlob ¶
GrowBlob is a Blob that can increase it's size by allocating offset bytes at the end.
type ReaderAt ¶
ReaderAt reads a Blob of up to 'length' bytes starting from this reader's 'srcOffset'.
type SetBlob ¶
SetBlob is a Blob that can copy 'src' into itself starting at the given offset into this Blob. Use View() on 'src' to control the maximum that is copied into this Blob.
type TruncateBlob ¶
TruncateBlob is a Blob that can cut off bytes from the end until it is 'size' bytes long.
type ViewBlob ¶
ViewBlob is a Blob that can return a view into the same underlying data. Mutating the returned Blob also mutates the original.