reference

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Parity EncoderOptions = 1 << iota
	EncodingSchema
	FormatSchema

	NilRef   = "<nil>" // non-parsable
	SchemaV1 = "insolar"

	RecordRefIDSeparator = '.'
)
View Source
const (
	LocalBinaryHashSize          = 28
	LocalBinaryPulseAndScopeSize = 4
	LocalBinarySize              = LocalBinaryPulseAndScopeSize + LocalBinaryHashSize
	GlobalBinarySize             = 2 * LocalBinarySize
)
View Source
const LegacyDomainName = "11111111111111111111111111111111"
View Source
const RecordDomainName = "record"
View Source
const SubScopeMask = 1<<scopeBits - 1
View Source
const SuperScopeMask = SubScopeMask << scopeBits

Variables

This section is empty.

Functions

func AsBytes

func AsBytes(h Holder) []byte

func BinarySize

func BinarySize(h Holder) int

func BinarySizeLocal

func BinarySizeLocal(h LocalHolder) int

func CheckParity

func CheckParity(ref Holder, b []byte) error

func Compare

func Compare(ref0, ref1 Holder) int

func Encode

func Encode(h Holder) string

func EncodeLocal

func EncodeLocal(h LocalHolder) string

func Equal

func Equal(ref0, ref1 Holder) bool

func GetParity

func GetParity(ref Holder) []byte

func IsEmpty

func IsEmpty(ref Holder) bool

func IsGlobalScope

func IsGlobalScope(ref Holder) bool

func IsLifelineScope

func IsLifelineScope(ref Holder) bool

func IsLocalDomainScope

func IsLocalDomainScope(ref Holder) bool

func IsObjectReference

func IsObjectReference(ref Holder) bool

func IsRecordScope

func IsRecordScope(ref Holder) bool

func IsReservedName

func IsReservedName(domainName string) bool

func IsSelfScope

func IsSelfScope(ref Holder) bool

func IsValidDomainName

func IsValidDomainName(domainName string) bool

func IsValidObjectName

func IsValidObjectName(objectName string) bool

func Marshal

func Marshal(h Holder) ([]byte, error)

func MarshalJSON

func MarshalJSON(h Holder) ([]byte, error)

func MarshalLocal

func MarshalLocal(h LocalHolder) ([]byte, error)

func MarshalLocalJSON

func MarshalLocalJSON(v LocalHolder) (b []byte, err error)

func MarshalLocalTo

func MarshalLocalTo(h LocalHolder, data []byte) (int, error)

func MarshalLocalToSizedBuffer

func MarshalLocalToSizedBuffer(h LocalHolder, data []byte) (int, error)

func MarshalTo

func MarshalTo(h Holder, b []byte) (int, error)

func MarshalToSizedBuffer

func MarshalToSizedBuffer(h Holder, b []byte) (int, error)

func PulseNumberOf

func PulseNumberOf(ref LocalHolder) pulse.Number

func WriteWholeLocalTo

func WriteWholeLocalTo(v Local, b []byte) int

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
	DoNotVerify
)

type Encoder

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

func Base58Encoder

func Base58Encoder() 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

type Global

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

func Copy

func Copy(h Holder) Global

func GlobalFromBytes

func GlobalFromBytes(data []byte) (v Global)

func GlobalFromString

func GlobalFromString(input string) (Global, error)

func GlobalObjectFromString

func GlobalObjectFromString(input string) (Global, error)

func New

func New(domainID, localID Local) Global

func NewRecordOf

func NewRecordOf(owner Global, localID Local) Global

func NewRecordRef

func NewRecordRef(recID Local) Global

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

func NewSelf

func NewSelf(localID Local) Global

func NormCopy

func NormCopy(h Holder) Global

func UnmarshalGlobal

func UnmarshalGlobal(b []byte) (v Global, err error)

func UnmarshalJSON

func UnmarshalJSON(b []byte) (v Global, err error)

func (Global) AsByteString

func (v Global) AsByteString() longbits.ByteString

func (Global) AsBytes

func (v Global) AsBytes() []byte

deprecated // use reference.AsBytes()

func (Global) AsRecordID

func (v Global) AsRecordID() Local

func (Global) Compare

func (v Global) Compare(other Holder) int

func (Global) Equal

func (v Global) Equal(other Holder) bool

func (Global) GetBase

func (v Global) GetBase() Local

func (Global) GetLocal

func (v Global) GetLocal() Local

func (Global) GetScope

func (v Global) GetScope() Scope

func (Global) IsEmpty

func (v Global) IsEmpty() bool

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

func (v Global) IsObjectReference() bool

func (Global) IsRecordScope

func (v Global) IsRecordScope() bool

func (Global) IsSelfScope

func (v Global) IsSelfScope() bool

func (Global) IsZero

func (v Global) IsZero() bool

func (*Global) MarshalBinary

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

deprecated: use reference.Marshal, seems to be used by CBOR

func (Global) String

func (v Global) String() string

func (*Global) UnmarshalBinary

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

deprecated: use reference.Unmarshal, seems to be used by CBOR

func (Global) WriteTo

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

type GlobalDecoder

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

func DefaultDecoder

func DefaultDecoder() GlobalDecoder

func NewDecoder

func NewDecoder(options DecoderOptions, factory ByteDecoderFactory) GlobalDecoder

func NewDefaultDecoder

func NewDefaultDecoder(options DecoderOptions) GlobalDecoder

type Holder

type Holder interface {
	LocalHolder

	GetScope() Scope

	// GetBase returns base portion of a full reference
	GetBase() Local
}

func Decode

func Decode(s string) (Holder, error)

type IdentityDecoder

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

type IdentityEncoder

type IdentityEncoder func(ref Holder) (domain, object string)

type Local

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

func AsRecordID

func AsRecordID(v Holder) Local

func CopyLocal

func CopyLocal(h LocalHolder) Local

func EmptyLocal

func EmptyLocal() *Local

func LocalFromString

func LocalFromString(input string) (Local, error)

func NewLocal

func NewLocal(pn pulse.Number, scope SubScope, hash LocalHash) Local

func NewRecordID

func NewRecordID(pn pulse.Number, hash LocalHash) Local

func ReadWholeLocalFrom

func ReadWholeLocalFrom(b []byte) (v Local)

func Unmarshal

func Unmarshal(b []byte) (base, local Local, err error)

func UnmarshalLocal

func UnmarshalLocal(data []byte) (v Local, err error)

func UnmarshalLocalJSON

func UnmarshalLocalJSON(data []byte) (v Local, err error)

func (Local) AsByteString

func (v Local) AsByteString() longbits.ByteString

func (Local) AsBytes

func (v Local) AsBytes() []byte

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) Encode

func (v Local) Encode(enc Encoder) string

Encoder encodes Local to string with chosen encoder.

func (Local) Equal

func (v Local) Equal(o LocalHolder) bool

func (Local) GetHeader

func (v Local) GetHeader() LocalHeader

func (Local) GetLocal

func (v Local) GetLocal() Local

func (Local) GetPulseNumber

func (v Local) GetPulseNumber() pulse.Number

func (Local) IdentityHash

func (v Local) IdentityHash() LocalHash

func (Local) IdentityHashBytes

func (v Local) IdentityHashBytes() []byte

func (Local) IsEmpty

func (v Local) IsEmpty() bool

func (Local) IsZero

func (v Local) IsZero() bool

func (Local) NotEmpty

func (v Local) NotEmpty() bool

func (Local) ProtoSize

func (v Local) ProtoSize() int

deprecated

func (Local) Pulse

func (v Local) Pulse() pulse.Number

func (Local) String

func (v Local) String() string

func (Local) SubScope

func (v Local) SubScope() SubScope

func (Local) WithHash

func (v Local) WithHash(hash LocalHash) Local

func (Local) WithHeader

func (v Local) WithHeader(h LocalHeader) Local

func (Local) WithPulse

func (v Local) WithPulse(pn pulse.Number) Local

func (Local) WithSubScope

func (v Local) WithSubScope(scope SubScope) Local

func (Local) WriteTo

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

type LocalHash

type LocalHash = longbits.Bits224

func BytesToLocalHash

func BytesToLocalHash(b []byte) (result LocalHash)

func CopyToLocalHash

func CopyToLocalHash(r longbits.FixedReader) (result LocalHash)

type LocalHeader

type LocalHeader uint32

func NewLocalHeader

func NewLocalHeader(pn pulse.Number, scope SubScope) LocalHeader

func (LocalHeader) Pulse

func (v LocalHeader) Pulse() pulse.Number

func (LocalHeader) String

func (v LocalHeader) String() string

func (LocalHeader) SubScope

func (v LocalHeader) SubScope() SubScope

func (LocalHeader) WithHash

func (v LocalHeader) WithHash(h LocalHash) Local

func (LocalHeader) WithPulse

func (v LocalHeader) WithPulse(pn pulse.Number) LocalHeader

func (LocalHeader) WithSubScope

func (v LocalHeader) WithSubScope(scope SubScope) LocalHeader

type LocalHolder

type LocalHolder interface {
	// GetLocal returns local portion of a full reference
	GetLocal() Local

	IsEmpty() bool
}

type MutableTemplate

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

func (*MutableTemplate) AsTemplate

func (p *MutableTemplate) AsTemplate() Template

func (*MutableTemplate) CanAsRecord

func (p *MutableTemplate) CanAsRecord() bool

func (*MutableTemplate) GetBase

func (p *MutableTemplate) GetBase() Local

func (*MutableTemplate) GetLocal

func (p *MutableTemplate) GetLocal() Local

func (*MutableTemplate) GetScope

func (p *MutableTemplate) GetScope() Scope

func (*MutableTemplate) HasBase

func (p *MutableTemplate) HasBase() bool

func (*MutableTemplate) HasHash

func (p *MutableTemplate) HasHash() bool

func (*MutableTemplate) IsEmpty

func (p *MutableTemplate) IsEmpty() bool

func (*MutableTemplate) IsZero

func (p *MutableTemplate) IsZero() bool

func (*MutableTemplate) MustGlobal

func (p *MutableTemplate) MustGlobal() Global

func (*MutableTemplate) MustRecord

func (p *MutableTemplate) MustRecord() Local

func (*MutableTemplate) SetHash

func (p *MutableTemplate) SetHash(h LocalHash)

SetHash enables MustGlobal() and MustLocal(). Can be called multiple times to change hash.

func (*MutableTemplate) SetZeroValue

func (p *MutableTemplate) SetZeroValue()

func (*MutableTemplate) WithHash

func (p *MutableTemplate) WithHash(h LocalHash) Global

WithHash panics on zero template

func (*MutableTemplate) WithHashAsRecord

func (p *MutableTemplate) WithHashAsRecord(h LocalHash) Local

WithHashAsLocal is valid for record ref or self ref template. Panics otherwise.

type PtrHolder

type PtrHolder interface {
	Holder

	// GetBase returns base portion of a full reference
	GetLocalPtr() *Local
	GetBasePtr() *Local
}

func Empty

func Empty() PtrHolder

func NewNoCopy

func NewNoCopy(base, local *Local) PtrHolder

func NewPtrHolder

func NewPtrHolder(base, local Local) PtrHolder

func NewPtrRecord

func NewPtrRecord(local Local) PtrHolder

func NewPtrSelf

func NewPtrSelf(local Local) PtrHolder

type Scope

type Scope uint8
const (
	LifelineRecordOrSelf Scope = superScopeLifeline + iota
	LifelinePrivateChild
	LifelinePublicChild
	LifelineDelegate
)
const (
	LocalDomainMember Scope = superScopeLocalDomain + iota
	LocalDomainPrivatePolicy
	LocalDomainPublicPolicy
)
const (
	GlobalDomainPublicPolicy Scope
	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

func (Scope) Scope

func (v Scope) Scope() Scope

func (Scope) SubScope

func (v Scope) SubScope() SubScope

func (Scope) SuperScope

func (v Scope) SuperScope() SubScope

type SelfScope

type SelfScope uint8
const (
	SelfScopeLifeline     SelfScope = baseScopeLifeline
	SelfScopeLocalDomain  SelfScope = baseScopeLocalDomain
	SelfScopeGlobalDomain SelfScope = baseScopeGlobal
)

func (SelfScope) Scope

func (v SelfScope) Scope() Scope

func (SelfScope) SubScope

func (v SelfScope) SubScope() SubScope

func (SelfScope) SuperScope

func (v SelfScope) SuperScope() SubScope

type SubScope

type SubScope uint8
const (
	SubScopeLifeline SubScope = baseScopeLifeline
	SubScopeLocal    SubScope = baseScopeLocalDomain
	SubScopeGlobal   SubScope = baseScopeGlobal
)

func (SubScope) AsBaseOf

func (v SubScope) AsBaseOf(o SubScope) Scope

func (SubScope) AsSelfScope

func (v SubScope) AsSelfScope() SelfScope

type Template

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

func NewRecordRefTemplate

func NewRecordRefTemplate(pn pulse.Number) Template

func NewRefTemplate

func NewRefTemplate(template Holder, pn pulse.Number) Template

func NewRefTemplateExt

func NewRefTemplateExt(base Local, local LocalHeader) Template

func NewSelfRefTemplate

func NewSelfRefTemplate(pn pulse.Number, scope SelfScope) Template

func NewSelfRefTemplateExt

func NewSelfRefTemplateExt(pn pulse.Number, scope Scope) Template

func (Template) AsMutable

func (v Template) AsMutable() MutableTemplate

func (Template) CanAsRecord

func (v Template) CanAsRecord() bool

func (Template) GetScope

func (v Template) GetScope() Scope

func (Template) HasBase

func (v Template) HasBase() bool

func (Template) IsZero

func (v Template) IsZero() bool

func (Template) LocalHeader

func (v Template) LocalHeader() LocalHeader

func (Template) WithHash

func (v Template) WithHash(h LocalHash) Global

WithHash panics on zero or record ref template

func (Template) WithHashAsRecord

func (v Template) WithHashAsRecord(h LocalHash) Local

WithHashAsLocal is valid for record ref or self ref template. Panics otherwise.

func (Template) WithHashAsSelf

func (v Template) WithHashAsSelf(h LocalHash) Global

WithHashAsSelf panics on zero or record ref template

Jump to

Keyboard shortcuts

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