blobs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 12 Imported by: 4

Documentation

Overview

blobs provides a thin layer around crypto/sha512, adding value semantics and origin data's size to hashes. blobs is intended for trusted environments as checksums or data pointers.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoBLOB = errors.New("no BLOB")
View Source
var ErrVerificationFailure = errors.New("verification failure")

Functions

func Verify

func Verify(blob BLOB, r io.Reader) io.Reader

Types

type BLOB

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

BLOB is an opaque data reference

func Make

func Make(sha512hash []byte, size int64) BLOB

func Parse

func Parse(raw string) (BLOB, error)

func SlurpBytes

func SlurpBytes(data []byte) BLOB

func SlurpFile

func SlurpFile(name string) (BLOB, error)

func SlurpString

func SlurpString(data string) BLOB

func (BLOB) Equal

func (blob BLOB) Equal(other BLOB) bool

func (BLOB) IsZero

func (blob BLOB) IsZero() bool

func (BLOB) MarshalText

func (blob BLOB) MarshalText() ([]byte, error)

func (BLOB) Path

func (blob BLOB) Path() string

Path injectively returns a relative path where a BLOB's associated file may be stored on a filesystem. NOTE: Different to e.g. git, this path's base is the complete hash. This is done deliberately so that the BLOB's associated file fully represents the BLOB even if it is viewed without the context of a surrounding directory structure.

func (BLOB) Short added in v1.1.0

func (blob BLOB) Short() string

Short returns the first seven hexits of a BLOB's string representation, often enough to uniquely identify it. In scenarios with large amounts of data, uniqueness should be ascertained.

func (BLOB) Size

func (blob BLOB) Size() int64

func (BLOB) String

func (blob BLOB) String() string

func (*BLOB) UnmarshalText

func (blob *BLOB) UnmarshalText(text []byte) error

type Reader

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

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) BLOB

func (r *Reader) BLOB() BLOB

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

type Writer

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

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) BLOB

func (w *Writer) BLOB() BLOB

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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