objects

package
v0.1.23-oss Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrentDeepTreeRequestVersion                     = "0.2"
	ObjectTypeDeepTreeRequest     entities.ObjectType = "deeptree-request"
)
View Source
const MaxHeaderSize = 64

Variables

View Source
var Factory factoryMap = make(factoryMap)

Functions

func HashBlobBytes

func HashBlobBytes(b []byte) entities.Hash

func HashBlobReader

func HashBlobReader(size int64, r io.Reader) (entities.Hash, error)

func HashBytes

func HashBytes(b []byte) entities.Hash

func HashFileBlob

func HashFileBlob(fileName string) (entities.Hash, int64, error)

func NewHasher

func NewHasher() hash.Hash

func ObjectJSONDecode

func ObjectJSONDecode(o JSONObject, magic ObjectType, hash Hash, content []byte) error

func ObjectJSONEncode

func ObjectJSONEncode(o JSONObject, magic ObjectType) error

func ParseHeader

func ParseHeader(buf []byte) (string, int64, error)

func PrependHeaderReader

func PrependHeaderReader(r io.Reader, objType string, size int64) io.Reader

func PutHeader

func PutHeader(objType string, content []byte) ([]byte, error)

PutHeader expects to receive an object type with the content of the object prefixed with a fixed header of MaxHeaderSize bytes. It will put the correct git header right before the actual content. It will return a slice where the actual content begins and includes the actual content.

func ReadBlob

func ReadBlob(r io.Reader) ([]byte, error)

func ReadBlobHeader

func ReadBlobHeader(r io.Reader) (int64, error)

func ReadHeader

func ReadHeader(r io.Reader) (string, int64, error)

func WriteHeader

func WriteHeader(w io.Writer, objType string, size int64) error

Types

type DeepTreeRequest

type DeepTreeRequest struct {
	JSONBaseObject
	Version string
	Tree    Hash
}

func (*DeepTreeRequest) Decode

func (e *DeepTreeRequest) Decode(hash Hash, content []byte) error

func (*DeepTreeRequest) Encode

func (e *DeepTreeRequest) Encode() error
func (e *DeepTreeRequest) Links() []Hash

type Hash

type Hash = entities.Hash

type JSONBaseObject

type JSONBaseObject struct {
	Hash    Hash   `json:"-"`
	Encoded []byte `json:"-"`
}

func (*JSONBaseObject) Base

func (o *JSONBaseObject) Base() *JSONBaseObject

func (*JSONBaseObject) GetEncoded

func (o *JSONBaseObject) GetEncoded() []byte

func (*JSONBaseObject) GetHash

func (o *JSONBaseObject) GetHash() Hash

type JSONObject

type JSONObject interface {
	Base() *JSONBaseObject
}

type Object

type Object interface {
	GetHash() Hash
	GetEncoded() []byte
	Encode() error
	Decode(Hash, []byte) error
	Links() []Hash
}

type ObjectType

type ObjectType = entities.ObjectType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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