reference

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalBinaryHashSize          = 28
	LocalBinaryPulseAndScopeSize = 4
	LocalBinarySize              = LocalBinaryPulseAndScopeSize + LocalBinaryHashSize
	GlobalBinarySize             = 2 * LocalBinarySize
)
View Source
const JetDepthPosition = 0
View Source
const LegacyDomainName = "11111111111111111111111111111111"
View Source
const RecordDomainName = "record"
View Source
const SubScopeMask = 0x03
View Source
const SuperScopeMask = 0x0C

Variables

This section is empty.

Functions

func IsReservedName

func IsReservedName(domainName string) bool

func IsValidDomainName

func IsValidDomainName(domainName string) bool

func IsValidObjectName

func IsValidObjectName(objectName string) bool

Types

type ByteDecodeFunc

type ByteDecodeFunc func(s string, target io.ByteWriter) (stringRead int, err error)

type ByteDecoderFactory

type ByteDecoderFactory interface {
	GetByteDecoder(encodingName string) ByteDecodeFunc
	DefaultDecoder() ByteDecodeFunc
	LegacyDecoder() ByteDecodeFunc
}

func NewByteDecoderFactory

func NewByteDecoderFactory() ByteDecoderFactory

type ByteEncodeFunc

type ByteEncodeFunc func(source io.ByteReader, builder *strings.Builder) error

type DecoderOptions

type DecoderOptions uint8
const (
	AllowLegacy DecoderOptions = 1 << iota
	AllowRecords
	IgnoreParity
)

type Encoder

type Encoder interface {
	Encode(ref *Global) (string, error)
	EncodeToBuilder(ref *Global, b *strings.Builder) error
	EncodeRecord(rec *Local) (string, error)
}

func Base64Encoder added in v0.9.8

func Base64Encoder() Encoder

func DefaultEncoder

func DefaultEncoder() Encoder

func NewBase58Encoder

func NewBase58Encoder(opts EncoderOptions) Encoder

func NewBase64Encoder

func NewBase64Encoder(opts EncoderOptions) Encoder

type EncoderOptions

type EncoderOptions uint8
const (
	Parity EncoderOptions = 1 << iota
	EncodingSchema
	FormatSchema

	NilRef   = "<nil>" // non-parsable
	SchemaV1 = "insolarv1"
)

type Global

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

func NewGlobal

func NewGlobal(domainID, localID Local) Global

func NewRecordRef

func NewRecordRef(recID Local) Global

For LIMITED USE ONLY - can only be used by observer/analytical code

func NewSelfRef

func NewSelfRef(localID Local) Global

func (*Global) AsByteString

func (v *Global) AsByteString() longbits.ByteString

func (*Global) AsBytes

func (v *Global) AsBytes() []byte

func (Global) Bytes

func (v Global) Bytes() []byte

Bytes returns byte slice of Reference

func (*Global) CheckParity

func (v *Global) CheckParity(bytes []byte) error

func (Global) Compare

func (v Global) Compare(other Global) int

Compare compares two record references

func (Global) Equal

func (v Global) Equal(other Global) bool

Equal checks if reference points to the same record.

func (Global) GetBase

func (v Global) GetBase() *Local

GetBase returns base address from Global.

func (Global) GetLocal

func (v Global) GetLocal() *Local

GetLocal returns local address from Global.

func (*Global) GetParity

func (v *Global) GetParity() []byte

func (*Global) GetScope

func (v *Global) GetScope() Scope

func (Global) IsEmpty

func (v Global) IsEmpty() bool

IsEmpty - check for void

func (*Global) IsGlobalScope

func (v *Global) IsGlobalScope() bool

func (*Global) IsLifelineScope

func (v *Global) IsLifelineScope() bool

func (*Global) IsLocalDomainScope

func (v *Global) IsLocalDomainScope() bool

func (*Global) IsObjectReference added in v0.9.1

func (v *Global) IsObjectReference() bool

func (*Global) IsRecordScope

func (v *Global) IsRecordScope() bool

func (*Global) IsSelfScope

func (v *Global) IsSelfScope() bool

func (Global) Marshal

func (v Global) Marshal() ([]byte, error)

func (Global) MarshalBinary

func (v Global) MarshalBinary() ([]byte, error)

func (*Global) MarshalJSON

func (v *Global) MarshalJSON() ([]byte, error)

MarshalJSON serializes reference into JSONFormat.

func (Global) MarshalTo

func (v Global) MarshalTo(data []byte) (int, error)

func (*Global) Read

func (v *Global) Read(p []byte) (int, error)

func (Global) Size

func (v Global) Size() int

func (Global) String

func (v Global) String() string

String outputs base58 Reference representation.

func (*Global) Unmarshal

func (v *Global) Unmarshal(data []byte) error

func (*Global) UnmarshalBinary

func (v *Global) UnmarshalBinary(data []byte) error

func (*Global) UnmarshalJSON

func (v *Global) UnmarshalJSON(data []byte) error

func (*Global) WriteTo

func (v *Global) WriteTo(w io.Writer) (int64, error)

type GlobalDecoder

type GlobalDecoder interface {
	Decode(ref string) (Global, error)
}

func DefaultDecoder

func DefaultDecoder() GlobalDecoder

func NewDecoder

func NewDecoder(options DecoderOptions, factory ByteDecoderFactory) GlobalDecoder

func NewDefaultDecoder

func NewDefaultDecoder(options DecoderOptions) GlobalDecoder

type IdentityDecoder

type IdentityDecoder func(base *Global, name string) *Global

type IdentityEncoder

type IdentityEncoder func(ref *Global) (domain, object string)

type Local

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

func NewLocal

func NewLocal(pn pulse.Number, scope uint8, hash longbits.Bits224) Local

func NewRecordID

func NewRecordID(pn pulse.Number, hash longbits.Bits224) Local

func (*Local) AsByteString

func (v *Local) AsByteString() longbits.ByteString

func (*Local) AsBytes

func (v *Local) AsBytes() []byte

func (*Local) AsReader

func (v *Local) AsReader() io.ByteReader

func (Local) Bytes

func (v Local) Bytes() []byte

Bytes returns byte slice of ID.

func (Local) Compare

func (v Local) Compare(other Local) int

func (*Local) DebugString

func (v *Local) DebugString() string

DebugString prints ID in human readable form.

func (*Local) Equal

func (v *Local) Equal(other Local) bool

Equal checks if reference points to the same record

func (Local) GetHash

func (v Local) GetHash() longbits.Bits224

func (Local) GetPulseNumber

func (v Local) GetPulseNumber() pulse.Number

func (Local) Hash

func (v Local) Hash() []byte

Hash returns a copy of Hash part of ID

func (Local) IsEmpty

func (v Local) IsEmpty() bool

IsEmpty - check for void

func (Local) Marshal

func (v Local) Marshal() ([]byte, error)

func (Local) MarshalBinary

func (v Local) MarshalBinary() ([]byte, error)

func (*Local) MarshalJSON

func (v *Local) MarshalJSON() ([]byte, error)

MarshalJSON serializes ID into JSONFormat

func (Local) MarshalTo

func (v Local) MarshalTo(data []byte) (int, error)

func (Local) NotEmpty

func (v Local) NotEmpty() bool

NotEmpty - check for non void

func (Local) Pulse

func (v Local) Pulse() pulse.Number

Pulse returns a copy of Pulse part of ID.

func (*Local) Read

func (v *Local) Read(p []byte) (n int, err error)

func (Local) Size

func (v Local) Size() int

func (Local) String

func (v Local) String() string

String implements stringer on ID and returns base58 encoded value

func (*Local) Unmarshal

func (v *Local) Unmarshal(data []byte) error

func (*Local) UnmarshalBinary

func (v *Local) UnmarshalBinary(data []byte) error

func (*Local) UnmarshalJSON

func (v *Local) UnmarshalJSON(data []byte) error

func (*Local) WriteTo

func (v *Local) WriteTo(w io.Writer) (int64, error)

type Scope

type Scope uint8
const (
	LifelineSuperScope    Scope = 0x04 * baseScopeLifeline
	LocalDomainSuperScope Scope = 0x04 * baseScopeLocalDomain
	GlobalSuperScope      Scope = 0x04 * baseScopeGlobal
)
const (
	LifelineRecordOrSelf Scope = LifelineSuperScope + iota
	LifelinePrivateChild
	LifelinePublicChild
	LifelineDelegate
)
const (
	LocalDomainMember Scope = LocalDomainSuperScope + iota
	LocalDomainPrivatePolicy
	LocalDomainPublicPolicy
)
const (
	RemoteDomainMember Scope = GlobalSuperScope + iota

	GlobalDomainPublicPolicy
	GlobalDomainMember
)

func (Scope) IsGlobal

func (v Scope) IsGlobal() bool

func (Scope) IsLocal

func (v Scope) IsLocal() bool

func (Scope) IsOfLifeline

func (v Scope) IsOfLifeline() bool

func (Scope) IsOfLocalDomain

func (v Scope) IsOfLocalDomain() bool

Jump to

Keyboard shortcuts

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