fields

package
v0.0.0-...-133031b Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 14 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// CurrentVersion is the Forest version that this library writes
	CurrentVersion Version = 1

	// HashDigestLengthSHA512_256 is the length of the digest produced by the SHA512/256 hash algorithm
	HashDigestLengthSHA512_256 ContentLength = 32
)
View Source
const (
	// MaxContentLength is the maximum representable content length in this
	// version of the Forest
	MaxContentLength = math.MaxUint16
)

Variables

View Source
var ContentNames = map[ContentType]string{
	ContentTypeUTF8String: "UTF-8",
	ContentTypeTwig:       "Twig",
}
View Source
var HashNames = map[HashType]string{
	HashTypeNullHash: "NullHash",
	HashTypeSHA512:   "SHA512",
}
View Source
var KeyNames = map[KeyType]string{
	KeyTypeNoKey:      "None",
	KeyTypeOpenPGPRSA: "OpenPGP-RSA",
}
View Source
var MultiByteSerializationOrder binary.ByteOrder = binary.BigEndian

MultiByteSerializationOrder defines the order in which multi-byte integers are serialized into binary

View Source
var NodeTypeNames = map[NodeType]string{
	NodeTypeIdentity:  "identity",
	NodeTypeCommunity: "community",
	NodeTypeReply:     "reply",
}
View Source
var SignatureNames = map[SignatureType]string{
	SignatureTypeOpenPGPRSA: "OpenPGP-RSA",
}
View Source
var ValidContentTypes = map[ContentType]struct{}{
	ContentTypeUTF8String: struct{}{},
	ContentTypeTwig:       struct{}{},
}

map to valid lengths

View Source
var ValidKeyTypes = map[KeyType]struct{}{
	KeyTypeNoKey:      struct{}{},
	KeyTypeOpenPGPRSA: struct{}{},
}
View Source
var ValidNodeTypes = map[NodeType]struct{}{
	NodeTypeIdentity:  struct{}{},
	NodeTypeCommunity: struct{}{},
	NodeTypeReply:     struct{}{},
}
View Source
var ValidSignatureTypes = map[SignatureType]struct{}{
	SignatureTypeOpenPGPRSA: struct{}{},
}

Functions

This section is empty.

Types

type Blob

type Blob []byte

Blob represents a quantity of arbitrary binary data in the Forest

func (*Blob) BytesConsumed

func (v *Blob) BytesConsumed() int

func (Blob) Contains

func (v Blob) Contains(c []byte) bool

Contains checks if a substing of bytes exists in a Blob

func (Blob) ContainsString

func (v Blob) ContainsString(s string) bool

ContainsString checks if a substing exists in a Blob

func (*Blob) Equals

func (v *Blob) Equals(v2 *Blob) bool

func (Blob) MarshalBinary

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

MarshalBinary converts the Blob into its binary representation

func (Blob) MarshalText

func (v Blob) MarshalText() ([]byte, error)

func (*Blob) UnmarshalBinary

func (v *Blob) UnmarshalBinary(b []byte) error

UnmarshalBinary converts from the binary representation of a Blob back to its structured form

func (*Blob) UnmarshalText

func (v *Blob) UnmarshalText(b []byte) error

type ContentDescriptor

type ContentDescriptor struct {
	Type   ContentType   `arbor:"order=0"`
	Length ContentLength `arbor:"order=1"`
}

func NewContentDescriptor

func NewContentDescriptor(t ContentType, length int) (*ContentDescriptor, error)

func (*ContentDescriptor) Equals

func (d *ContentDescriptor) Equals(other *ContentDescriptor) bool

func (*ContentDescriptor) MarshalText

func (d *ContentDescriptor) MarshalText() ([]byte, error)

func (*ContentDescriptor) Validate

func (d *ContentDescriptor) Validate() error

type ContentLength

type ContentLength uint16

ContentLength represents the length of a piece of data in the Forest

func NewContentLength

func NewContentLength(size int) (*ContentLength, error)

func (*ContentLength) BytesConsumed

func (c *ContentLength) BytesConsumed() int

func (*ContentLength) Equals

func (c *ContentLength) Equals(c2 *ContentLength) bool

func (ContentLength) MarshalBinary

func (c ContentLength) MarshalBinary() ([]byte, error)

MarshalBinary converts the ContentLength into its binary representation

func (ContentLength) MarshalText

func (c ContentLength) MarshalText() ([]byte, error)

func (*ContentLength) UnmarshalBinary

func (c *ContentLength) UnmarshalBinary(b []byte) error

UnmarshalBinary converts from the binary representation of a ContentLength back to its structured form

func (*ContentLength) UnmarshalText

func (c *ContentLength) UnmarshalText(b []byte) error

type ContentType

type ContentType genericType
const (
	ContentTypeUTF8String ContentType = 1
	ContentTypeTwig       ContentType = 2
)

func (*ContentType) BytesConsumed

func (t *ContentType) BytesConsumed() int

func (*ContentType) Equals

func (t *ContentType) Equals(t2 *ContentType) bool

func (ContentType) MarshalBinary

func (t ContentType) MarshalBinary() ([]byte, error)

func (ContentType) MarshalText

func (t ContentType) MarshalText() ([]byte, error)

func (*ContentType) UnmarshalBinary

func (t *ContentType) UnmarshalBinary(b []byte) error

type HashDescriptor

type HashDescriptor struct {
	Type   HashType      `arbor:"order=0"`
	Length ContentLength `arbor:"order=1"`
}

concrete descriptors

func NewHashDescriptor

func NewHashDescriptor(t HashType, length int) (*HashDescriptor, error)

func (*HashDescriptor) Equals

func (d *HashDescriptor) Equals(other *HashDescriptor) bool

func (*HashDescriptor) MarshalText

func (d *HashDescriptor) MarshalText() ([]byte, error)

func (*HashDescriptor) UnmarshalText

func (d *HashDescriptor) UnmarshalText(b []byte) error

func (*HashDescriptor) Validate

func (d *HashDescriptor) Validate() error

type HashType

type HashType genericType
const (
	HashTypeNullHash HashType = iota
	HashTypeSHA512
)

func (*HashType) BytesConsumed

func (t *HashType) BytesConsumed() int

func (*HashType) Equals

func (t *HashType) Equals(t2 *HashType) bool

func (HashType) MarshalBinary

func (t HashType) MarshalBinary() ([]byte, error)

func (HashType) MarshalText

func (t HashType) MarshalText() ([]byte, error)

func (*HashType) UnmarshalBinary

func (t *HashType) UnmarshalBinary(b []byte) error

func (*HashType) UnmarshalText

func (t *HashType) UnmarshalText(b []byte) error

type KeyDescriptor

type KeyDescriptor struct {
	Type   KeyType       `arbor:"order=0"`
	Length ContentLength `arbor:"order=1"`
}

func NewKeyDescriptor

func NewKeyDescriptor(t KeyType, length int) (*KeyDescriptor, error)

func (*KeyDescriptor) Equals

func (d *KeyDescriptor) Equals(other *KeyDescriptor) bool

func (*KeyDescriptor) MarshalText

func (d *KeyDescriptor) MarshalText() ([]byte, error)

func (*KeyDescriptor) Validate

func (d *KeyDescriptor) Validate() error

type KeyType

type KeyType genericType
const (
	KeyTypeNoKey      KeyType = 0
	KeyTypeOpenPGPRSA KeyType = 1
)

func (*KeyType) BytesConsumed

func (t *KeyType) BytesConsumed() int

func (*KeyType) Equals

func (t *KeyType) Equals(t2 *KeyType) bool

func (KeyType) MarshalBinary

func (t KeyType) MarshalBinary() ([]byte, error)

func (KeyType) MarshalText

func (t KeyType) MarshalText() ([]byte, error)

func (*KeyType) UnmarshalBinary

func (t *KeyType) UnmarshalBinary(b []byte) error

type NodeType

type NodeType genericType

specialized types

const (
	NodeTypeIdentity NodeType = iota
	NodeTypeCommunity
	NodeTypeReply
)

func (*NodeType) BytesConsumed

func (t *NodeType) BytesConsumed() int

func (*NodeType) Equals

func (t *NodeType) Equals(t2 *NodeType) bool

func (NodeType) MarshalBinary

func (t NodeType) MarshalBinary() ([]byte, error)

func (NodeType) MarshalText

func (t NodeType) MarshalText() ([]byte, error)

func (NodeType) String

func (t NodeType) String() string

func (*NodeType) UnmarshalBinary

func (t *NodeType) UnmarshalBinary(b []byte) error

type QualifiedContent

type QualifiedContent struct {
	Descriptor ContentDescriptor `arbor:"order=0,recurse=serialize"`
	Blob       `arbor:"order=1"`
}

func NewQualifiedContent

func NewQualifiedContent(t ContentType, content []byte) (*QualifiedContent, error)

NewQualifiedContent returns a valid QualifiedContent from the given data

func (*QualifiedContent) BytesConsumed

func (q *QualifiedContent) BytesConsumed() int

func (*QualifiedContent) Equals

func (q *QualifiedContent) Equals(other *QualifiedContent) bool

func (*QualifiedContent) MarshalText

func (q *QualifiedContent) MarshalText() ([]byte, error)

func (*QualifiedContent) UnmarshalBinary

func (q *QualifiedContent) UnmarshalBinary(b []byte) error

func (*QualifiedContent) Validate

func (q *QualifiedContent) Validate() error

type QualifiedHash

type QualifiedHash struct {
	Descriptor HashDescriptor `arbor:"order=0,recurse=serialize"`
	Blob       `arbor:"order=1"`
}

concrete qualified data types

func NewQualifiedHash

func NewQualifiedHash(t HashType, content []byte) (*QualifiedHash, error)

NewQualifiedHash returns a valid QualifiedHash from the given data

func NullHash

func NullHash() *QualifiedHash

func (*QualifiedHash) BytesConsumed

func (q *QualifiedHash) BytesConsumed() int

func (*QualifiedHash) Equals

func (q *QualifiedHash) Equals(other *QualifiedHash) bool

func (*QualifiedHash) MarshalString

func (q *QualifiedHash) MarshalString() (string, error)

func (*QualifiedHash) MarshalText

func (q *QualifiedHash) MarshalText() ([]byte, error)

func (*QualifiedHash) String

func (q *QualifiedHash) String() string

String returns the output of MarshalString, but does not return an error.

func (*QualifiedHash) UnmarshalBinary

func (q *QualifiedHash) UnmarshalBinary(b []byte) error

func (*QualifiedHash) UnmarshalText

func (q *QualifiedHash) UnmarshalText(b []byte) error

func (*QualifiedHash) Validate

func (q *QualifiedHash) Validate() error

type QualifiedKey

type QualifiedKey struct {
	Descriptor KeyDescriptor `arbor:"order=0,recurse=serialize"`
	Blob       `arbor:"order=1"`
}

func NewQualifiedKey

func NewQualifiedKey(t KeyType, content []byte) (*QualifiedKey, error)

NewQualifiedKey returns a valid QualifiedKey from the given data

func (*QualifiedKey) AsEntity

func (q *QualifiedKey) AsEntity() (*openpgp.Entity, error)

func (*QualifiedKey) BytesConsumed

func (q *QualifiedKey) BytesConsumed() int

func (*QualifiedKey) Equals

func (q *QualifiedKey) Equals(other *QualifiedKey) bool

func (*QualifiedKey) MarshalText

func (q *QualifiedKey) MarshalText() ([]byte, error)

func (*QualifiedKey) UnmarshalBinary

func (q *QualifiedKey) UnmarshalBinary(b []byte) error

func (*QualifiedKey) Validate

func (q *QualifiedKey) Validate() error

type QualifiedSignature

type QualifiedSignature struct {
	Descriptor SignatureDescriptor `arbor:"order=0,recurse=serialize"`
	Blob       `arbor:"order=1"`
}

func NewQualifiedSignature

func NewQualifiedSignature(t SignatureType, content []byte) (*QualifiedSignature, error)

NewQualifiedSignature returns a valid QualifiedSignature from the given data

func (*QualifiedSignature) BytesConsumed

func (q *QualifiedSignature) BytesConsumed() int

func (*QualifiedSignature) Equals

func (q *QualifiedSignature) Equals(other *QualifiedSignature) bool

func (*QualifiedSignature) MarshalText

func (q *QualifiedSignature) MarshalText() ([]byte, error)

func (*QualifiedSignature) UnmarshalBinary

func (q *QualifiedSignature) UnmarshalBinary(b []byte) error

func (*QualifiedSignature) Validate

func (q *QualifiedSignature) Validate() error

type SignatureDescriptor

type SignatureDescriptor struct {
	Type   SignatureType `arbor:"order=0"`
	Length ContentLength `arbor:"order=1"`
}

func NewSignatureDescriptor

func NewSignatureDescriptor(t SignatureType, length int) (*SignatureDescriptor, error)

func (*SignatureDescriptor) Equals

func (d *SignatureDescriptor) Equals(other *SignatureDescriptor) bool

func (*SignatureDescriptor) MarshalText

func (d *SignatureDescriptor) MarshalText() ([]byte, error)

func (*SignatureDescriptor) Validate

func (d *SignatureDescriptor) Validate() error

type SignatureType

type SignatureType genericType
const (
	SignatureTypeOpenPGPRSA SignatureType = 1
)

func (*SignatureType) BytesConsumed

func (t *SignatureType) BytesConsumed() int

func (*SignatureType) Equals

func (t *SignatureType) Equals(t2 *SignatureType) bool

func (SignatureType) MarshalBinary

func (t SignatureType) MarshalBinary() ([]byte, error)

func (SignatureType) MarshalText

func (t SignatureType) MarshalText() ([]byte, error)

func (*SignatureType) UnmarshalBinary

func (t *SignatureType) UnmarshalBinary(b []byte) error

type Timestamp

type Timestamp uint64

Timestamp represents the time at which a node was created. It is measured as milliseconds since the start of the UNIX epoch.

func TimestampFrom

func TimestampFrom(t time.Time) Timestamp

func (*Timestamp) BytesConsumed

func (v *Timestamp) BytesConsumed() int

func (*Timestamp) Equals

func (v *Timestamp) Equals(v2 *Timestamp) bool

func (Timestamp) MarshalBinary

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

MarshalBinary converts the Timestamp into its binary representation

func (Timestamp) MarshalText

func (v Timestamp) MarshalText() ([]byte, error)

func (Timestamp) Time

func (t Timestamp) Time() time.Time

func (*Timestamp) UnmarshalBinary

func (v *Timestamp) UnmarshalBinary(b []byte) error

UnmarshalBinary converts from the binary representation of a Timestamp back to its structured form

type TreeDepth

type TreeDepth uint32

TreeDepth represents the depth of a node within a tree

func (*TreeDepth) BytesConsumed

func (t *TreeDepth) BytesConsumed() int

func (*TreeDepth) Equals

func (t *TreeDepth) Equals(t2 *TreeDepth) bool

func (TreeDepth) MarshalBinary

func (t TreeDepth) MarshalBinary() ([]byte, error)

MarshalBinary converts the TreeDepth into its binary representation

func (TreeDepth) MarshalText

func (t TreeDepth) MarshalText() ([]byte, error)

func (*TreeDepth) UnmarshalBinary

func (t *TreeDepth) UnmarshalBinary(b []byte) error

UnmarshalBinary converts from the binary representation of a TreeDepth back to its structured form

type Version

type Version uint16

Version represents the version of the Arbor Forest Schema used to construct a particular node

func (*Version) BytesConsumed

func (v *Version) BytesConsumed() int

func (*Version) Equals

func (v *Version) Equals(v2 *Version) bool

func (Version) MarshalBinary

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

MarshalBinary converts the Version into its binary representation

func (Version) MarshalText

func (v Version) MarshalText() ([]byte, error)

func (*Version) UnmarshalBinary

func (v *Version) UnmarshalBinary(b []byte) error

UnmarshalBinary converts from the binary representation of a Version back to its structured form

Jump to

Keyboard shortcuts

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