asset

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package asset contains Go implementations C4 asset identification.

Creating IDs

To create a C4 ID, use the IDEncoder type as a hash writer.

e := asset.NewIDEncoder()
io.Copy(e, src)
id := e.ID()

Parsing IDs

To parse an ID from a string, use the ParseID function.

asset.ParseID(src)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SearchIDs

func SearchIDs(a IDSlice, x *ID) int

SearchIDs searches for x in a sorted slice of *ID and returns the index as specified by sort.Search. The slice must be sorted in ascending order.

Types

type ID

type ID big.Int

ID represents a C4 Asset ID.

func ParseBytesID

func ParseBytesID(src []byte) (*ID, error)

ParseBytesID parses a C4 ID as []byte into an ID.

func ParseID

func ParseID(src string) (*ID, error)

ParseID parses a C4 ID string into an ID.

func (*ID) Bytes

func (id *ID) Bytes() []byte

Bytes encodes the written bytes to C4 ID format.

func (*ID) Cmp

func (id *ID) Cmp(y *ID) int

Cmp compares two IDs.

func (*ID) String

func (id *ID) String() string

type IDEncoder

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

IDEncoder generates C4 Asset IDs.

func NewIDEncoder

func NewIDEncoder() *IDEncoder

NewIDEncoder makes a new IDEncoder.

func (*IDEncoder) BlockSize

func (e *IDEncoder) BlockSize() int

BlockSize gets the block size of the underlying sha512 hash object.

func (*IDEncoder) ID

func (e *IDEncoder) ID() *ID

ID gets the ID for the written bytes.

func (*IDEncoder) Reset

func (e *IDEncoder) Reset()

Reset resets the underlying sha512 hash object.

func (*IDEncoder) Size

func (e *IDEncoder) Size() int

Size gets the size of the underlying sha512 hash object.

func (*IDEncoder) Sum

func (e *IDEncoder) Sum(b []byte) []byte

Sum gets the C4ID sum of the underlying sha512 hash object. Recommended to use ID() instead.

func (*IDEncoder) Write

func (e *IDEncoder) Write(b []byte) (int, error)

Write writes bytes to the hash that makes up the ID.

type IDSlice

type IDSlice []*ID

IDSlice represents a slice of IDs.

func (IDSlice) ID

func (s IDSlice) ID() *ID

ID gets the ID from the IDSlice.

func (IDSlice) Len

func (s IDSlice) Len() int

func (IDSlice) Less

func (s IDSlice) Less(i, j int) bool

func (*IDSlice) Push

func (s *IDSlice) Push(id *ID)

Push adds the item to the IDSlice.

func (IDSlice) Sort

func (s IDSlice) Sort()

Sort is a convenience method.

func (*IDSlice) String

func (s *IDSlice) String() string

func (IDSlice) Swap

func (s IDSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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