memory

package
v3.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedObjectType = fmt.Errorf("unsupported object type")

Functions

This section is empty.

Types

type Object

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

Object on memory core.Object implementation

func (*Object) Close

func (o *Object) Close() error

Close releases any resources consumed by the object when it is acting as a core.ObjectWriter.

func (*Object) Hash

func (o *Object) Hash() core.Hash

Hash return the object Hash, the hash is calculated on-the-fly the first time is called, the subsequent calls the same Hash is returned even in the type or the content has changed. The Hash is only generated if the size of the content is exactly the Object.Size

func (*Object) Reader

func (o *Object) Reader() (core.ObjectReader, error)

Reader returns a core.ObjectReader used to read the object's content.

func (*Object) SetSize

func (o *Object) SetSize(s int64)

SetSize set the object size, the given size should be written afterwards

func (*Object) SetType

func (o *Object) SetType(t core.ObjectType)

SetType sets the core.ObjectType

func (*Object) Size

func (o *Object) Size() int64

Size return the size of the object

func (*Object) Type

func (o *Object) Type() core.ObjectType

Type return the core.ObjectType

func (*Object) Write

func (o *Object) Write(p []byte) (n int, err error)

func (*Object) Writer

func (o *Object) Writer() (core.ObjectWriter, error)

Writer returns a core.ObjectWriter used to write the object's content.

type ObjectStorage

type ObjectStorage struct {
	Objects map[core.Hash]core.Object
	Commits map[core.Hash]core.Object
	Trees   map[core.Hash]core.Object
	Blobs   map[core.Hash]core.Object
	Tags    map[core.Hash]core.Object
}

ObjectStorage is the implementation of core.ObjectStorage for memory.Object

func NewObjectStorage

func NewObjectStorage() *ObjectStorage

NewObjectStorage returns a new empty ObjectStorage

func (*ObjectStorage) Get

func (o *ObjectStorage) Get(h core.Hash) (core.Object, error)

Get returns a object with the given hash

func (*ObjectStorage) Iter

Iter returns a core.ObjectIter for the given core.ObjectTybe

func (*ObjectStorage) New

func (o *ObjectStorage) New() (core.Object, error)

New returns a new empty memory.Object

func (*ObjectStorage) Set

func (o *ObjectStorage) Set(obj core.Object) (core.Hash, error)

Set stores an object, the object should be properly filled before set it.

Jump to

Keyboard shortcuts

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