identity

package
v0.16.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2016 License: BSD-3-Clause Imports: 6 Imported by: 54

Documentation

Overview

Package identity defines the ID format used for uniquely identifying objects in Torus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID [18]byte

ID is an encoded unique identifier for an object.

The first byte holds the schema version of the id itself. The second byte holds the type of the object. The remaining 16 bytes hold a digest of the contents of the object for immutable objects, or a random value for mutable objects.

func DecodeFromString

func DecodeFromString(value string) (ID, error)

DecodeFromString returns an ID that is stored in the given string.

func DeriveMutable added in v0.15.0

func DeriveMutable(body Mutable, base *ID, derivableType byte) ID

DeriveMutable returns a ID for a mutable object based on another ID.

func NewImmutable added in v0.9.0

func NewImmutable(body Immutable, sig interface{}) (ID, error)

NewImmutable returns a new signed ID for an immutable object.

sig should be a registry.Signature type

func NewMutable added in v0.9.0

func NewMutable(body Mutable) (ID, error)

NewMutable returns a new ID for a mutable object.

func (*ID) MarshalJSON

func (id *ID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for IDs.

IDs are encoded in unpadded base32.

func (*ID) String

func (id *ID) String() string

func (*ID) Type

func (id *ID) Type() byte

Type returns the binary encoded object type represented by this ID.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for IDs.

type Identifiable

type Identifiable interface {
	Version() int
	Type() byte
}

Identifiable is the interface implemented by objects that can be given IDs.

type Immutable

type Immutable interface {
	Identifiable
	Immutable() // We don't ever need to call this, its just for type checking.
}

Immutable structs are Identifiables that do not change, and should be signed.

type Mutable

type Mutable interface {
	Identifiable
	Mutable() // also just for type checking.
}

Mutable structs are Identifiables that can be changed.

Jump to

Keyboard shortcuts

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