pack

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2015 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pack provides functions for combining and parsing pack files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blob

type Blob struct {
	Type   BlobType
	Length uint32
	ID     backend.ID
	Offset uint
}

Blob is a blob within a pack.

func (Blob) GetReader

func (e Blob) GetReader(rd io.ReadSeeker) (io.Reader, error)

GetReader returns an io.Reader for the blob entry e.

type BlobType

type BlobType uint8
const (
	Data BlobType = 0
	Tree          = 1
)

func (BlobType) MarshalJSON

func (t BlobType) MarshalJSON() ([]byte, error)

func (BlobType) String

func (t BlobType) String() string

func (*BlobType) UnmarshalJSON

func (t *BlobType) UnmarshalJSON(buf []byte) error

type Packer

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

Packer is used to create a new Pack.

func NewPacker

func NewPacker(k *crypto.Key, w io.Writer) *Packer

NewPacker returns a new Packer that can be used to pack blobs together.

func (*Packer) Add

func (p *Packer) Add(t BlobType, id backend.ID, rd io.Reader) (int64, error)

Add saves the data read from rd as a new blob to the packer. Returned is the number of bytes written to the pack.

func (*Packer) Blobs

func (p *Packer) Blobs() []Blob

Blobs returns the slice of blobs that have been written.

func (*Packer) Count

func (p *Packer) Count() int

Count returns the number of blobs in this packer.

func (*Packer) Finalize

func (p *Packer) Finalize() (bytesWritten uint, err error)

Finalize writes the header for all added blobs and finalizes the pack. Returned are the complete number of bytes written, including the header. After Finalize() has finished, the ID of this pack can be obtained by calling ID().

func (*Packer) ID

func (p *Packer) ID() backend.ID

ID returns the ID of all data written so far.

func (*Packer) Size

func (p *Packer) Size() uint

Size returns the number of bytes written so far.

func (*Packer) String

func (p *Packer) String() string

func (*Packer) Writer

func (p *Packer) Writer() io.Writer

Writer returns the underlying writer.

type Unpacker

type Unpacker struct {
	Entries []Blob
	// contains filtered or unexported fields
}

Unpacker is used to read individual blobs from a pack.

func NewUnpacker

func NewUnpacker(k *crypto.Key, entries []Blob, rd io.ReadSeeker) (*Unpacker, error)

NewUnpacker returns a pointer to Unpacker which can be used to read individual Blobs from a pack.

Jump to

Keyboard shortcuts

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