idxfile

package
v4.0.0-rc6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package idxfile implements a encoder/decoder of idx files

Index

Constants

View Source
const (
	// VersionSupported is the only idx version supported.
	VersionSupported = 2
)

Variables

View Source
var (
	// ErrUnsupportedVersion is returned by Decode when the idx file version
	// is not supported.
	ErrUnsupportedVersion = errors.New("Unsuported version")
	// ErrMalformedIdxFile is returned by Decode when the idx file is corrupted.
	ErrMalformedIdxFile = errors.New("Malformed IDX file")
)

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	io.Reader
}

A Decoder reads and decodes idx files from an input stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new decoder that reads from r.

func (*Decoder) Decode

func (d *Decoder) Decode(idx *Idxfile) error

Decode reads the whole idx object from its input and stores it in the value pointed to by idx.

type Encoder

type Encoder struct {
	io.Writer
	// contains filtered or unexported fields
}

An Encoder writes idx files to an output stream.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new encoder that writes to w.

func (*Encoder) Encode

func (e *Encoder) Encode(idx *Idxfile) (int, error)

Encode writes the idx in an idx file format to the stream of the encoder.

type Entry

type Entry struct {
	Hash   plumbing.Hash
	CRC32  uint32
	Offset uint64
}

An Entry represents data about an object in the packfile: its hash, offset and CRC32 checksum.

type EntryList

type EntryList []Entry

func (EntryList) Len

func (p EntryList) Len() int

func (EntryList) Less

func (p EntryList) Less(i, j int) bool

func (EntryList) Sort

func (p EntryList) Sort()

func (EntryList) Swap

func (p EntryList) Swap(i, j int)

type Idxfile

type Idxfile struct {
	Version          uint32
	Fanout           [255]uint32
	ObjectCount      uint32
	Entries          EntryList
	PackfileChecksum [20]byte
	IdxChecksum      [20]byte
}

An Idxfile represents an idx file in memory.

func (*Idxfile) Add

func (idx *Idxfile) Add(h plumbing.Hash, offset uint64, crc32 uint32)

Jump to

Keyboard shortcuts

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