types

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const IdHashLen = 8
View Source
const IdLen = sha256.Size
View Source
const IdentLen = 8
View Source
const LetterLen = 1
View Source
const MaxUint24 uint32 = 1<<24 - 1

MaxUint24 is the maximum value of a 24-bit unsigned integer: 2^24 - 1.

View Source
const MaxUint40 uint64 = 1<<40 - 1

MaxUint40 is the maximum value of a 40-bit unsigned integer: 2^40 - 1.

View Source
const PubHashLen = 8
View Source
const TimestampLen = 8

Variables

This section is empty.

Functions

This section is empty.

Types

type Id

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

func (*Id) Bytes

func (fi *Id) Bytes() (b []byte)

func (*Id) FromId

func (fi *Id) FromId(id []byte) (err error)

func (*Id) MarshalWrite

func (fi *Id) MarshalWrite(w io.Writer) (err error)

func (*Id) UnmarshalRead

func (fi *Id) UnmarshalRead(r io.Reader) (err error)

type IdHash

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

func (*IdHash) Bytes

func (i *IdHash) Bytes() (b []byte)

func (*IdHash) FromId

func (i *IdHash) FromId(id []byte) (err error)

func (*IdHash) FromIdBase64

func (i *IdHash) FromIdBase64(idb64 string) (err error)

func (*IdHash) FromIdHex

func (i *IdHash) FromIdHex(idh string) (err error)

func (*IdHash) MarshalWrite

func (i *IdHash) MarshalWrite(w io.Writer) (err error)

func (*IdHash) Set

func (i *IdHash) Set(idh []byte)

func (*IdHash) UnmarshalRead

func (i *IdHash) UnmarshalRead(r io.Reader) (err error)

type Ident

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

func (*Ident) Bytes

func (i *Ident) Bytes() (b []byte)

func (*Ident) FromIdent

func (i *Ident) FromIdent(id []byte)

func (*Ident) MarshalWrite

func (i *Ident) MarshalWrite(w io.Writer) (err error)

func (*Ident) UnmarshalRead

func (i *Ident) UnmarshalRead(r io.Reader) (err error)

type Letter

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

func (*Letter) Letter

func (p *Letter) Letter() byte

func (*Letter) MarshalWrite

func (p *Letter) MarshalWrite(w io.Writer) (err error)

func (*Letter) Set

func (p *Letter) Set(lb byte)

func (*Letter) UnmarshalRead

func (p *Letter) UnmarshalRead(r io.Reader) (err error)

type PubHash

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

func (*PubHash) Bytes

func (ph *PubHash) Bytes() (b []byte)

func (*PubHash) FromPubkey

func (ph *PubHash) FromPubkey(pk []byte) (err error)

func (*PubHash) FromPubkeyHex

func (ph *PubHash) FromPubkeyHex(pk string) (err error)

func (*PubHash) MarshalWrite

func (ph *PubHash) MarshalWrite(w io.Writer) (err error)

func (*PubHash) UnmarshalRead

func (ph *PubHash) UnmarshalRead(r io.Reader) (err error)

type Timestamp

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

func FromBytes

func FromBytes(timestampBytes []byte) (ts *Timestamp, err error)

func (*Timestamp) Bytes

func (ts *Timestamp) Bytes() (b []byte, err error)

func (*Timestamp) FromInt

func (ts *Timestamp) FromInt(t int)

func (*Timestamp) FromInt64

func (ts *Timestamp) FromInt64(t int64)

func (*Timestamp) MarshalWrite

func (ts *Timestamp) MarshalWrite(w io.Writer) (err error)

func (*Timestamp) ToTimestamp

func (ts *Timestamp) ToTimestamp() (timestamp int64)

func (*Timestamp) UnmarshalRead

func (ts *Timestamp) UnmarshalRead(r io.Reader) (err error)

type Uint16

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

Uint16 is a codec for encoding and decoding 16-bit unsigned integers.

func (*Uint16) Get

func (c *Uint16) Get() uint16

Get gets the value as a uint16.

func (*Uint16) GetInt

func (c *Uint16) GetInt() int

GetInt gets the value as an int, converted from uint16.

func (*Uint16) MarshalWrite

func (c *Uint16) MarshalWrite(w io.Writer) error

MarshalWrite writes the uint16 value to the provided writer in BigEndian order.

func (*Uint16) Set

func (c *Uint16) Set(value uint16)

Set sets the value as a uint16.

func (*Uint16) SetInt

func (c *Uint16) SetInt(value int)

SetInt sets the value as an int, converting it to uint16. Truncates values outside uint16 range (0-65535).

func (*Uint16) UnmarshalRead

func (c *Uint16) UnmarshalRead(r io.Reader) error

UnmarshalRead reads a uint16 value from the provided reader in BigEndian order.

type Uint16s

type Uint16s []*Uint16

func (Uint16s) Difference

func (s Uint16s) Difference(other Uint16s) Uint16s

Difference computes the difference of the current Uint16s slice with another Uint16s slice. The result contains only the elements that are in the current slice but not in the other slice.

func (Uint16s) Intersection

func (s Uint16s) Intersection(other Uint16s) Uint16s

Intersection computes the intersection of the current Uint16s slice with another Uint16s slice. The result contains only the elements that exist in both slices.

func (Uint16s) Union

func (s Uint16s) Union(other Uint16s) Uint16s

Union computes the union of the current Uint16s slice with another Uint16s slice. The result contains all unique elements from both slices.

type Uint24

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

Uint24 is a codec for encoding and decoding 24-bit unsigned integers.

func (*Uint24) Get

func (c *Uint24) Get() uint32

Get gets the value as a 24-bit unsigned integer.

func (*Uint24) Int

func (c *Uint24) Int() int

Int gets the value as an int, converted from the 24-bit unsigned integer.

func (*Uint24) MarshalWrite

func (c *Uint24) MarshalWrite(w io.Writer) error

MarshalWrite encodes the 24-bit unsigned integer and writes it directly to the provided io.Writer. The encoding uses 3 bytes in BigEndian order.

func (*Uint24) Set

func (c *Uint24) Set(value uint32) error

Set sets the value as a 24-bit unsigned integer. If the value exceeds the maximum allowable value for 24 bits, it returns an error.

func (*Uint24) SetInt

func (c *Uint24) SetInt(value int) error

SetInt sets the value as an int, converting it to a 24-bit unsigned integer. If the value is out of the 24-bit range, it returns an error.

func (*Uint24) UnmarshalRead

func (c *Uint24) UnmarshalRead(r io.Reader) error

UnmarshalRead reads 3 bytes directly from the provided io.Reader and decodes it into a 24-bit unsigned integer.

type Uint24s

type Uint24s []*Uint24

func (Uint24s) Difference

func (s Uint24s) Difference(other Uint24s) Uint24s

Difference computes the difference of the current Uint24s slice with another Uint24s slice. The result contains only the elements that are in the current slice but not in the other slice.

func (Uint24s) Intersection

func (s Uint24s) Intersection(other Uint24s) Uint24s

Intersection computes the intersection of the current Uint24s slice with another Uint24s slice. The result contains only the elements that exist in both slices.

func (Uint24s) Union

func (s Uint24s) Union(other Uint24s) Uint24s

Union computes the union of the current Uint24s slice with another Uint24s slice. The result contains all unique elements from both slices.

type Uint32

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

Uint32 is a codec for encoding and decoding 32-bit unsigned integers.

func (*Uint32) Get

func (c *Uint32) Get() uint32

Get gets the value as a uint32.

func (*Uint32) Int

func (c *Uint32) Int() int

Int gets the value as an int, converted from uint32.

func (*Uint32) MarshalWrite

func (c *Uint32) MarshalWrite(w io.Writer) error

MarshalWrite writes the uint32 value to the provided writer in BigEndian order.

func (*Uint32) Set

func (c *Uint32) Set(value uint32)

Set sets the value as a uint32.

func (*Uint32) SetInt

func (c *Uint32) SetInt(value int)

SetInt sets the value as an int, converting it to uint32. Values outside the range of uint32 (0–4294967295) will be truncated.

func (*Uint32) UnmarshalRead

func (c *Uint32) UnmarshalRead(r io.Reader) error

UnmarshalRead reads a uint32 value from the provided reader in BigEndian order.

type Uint32s

type Uint32s []*Uint32

func (Uint32s) Difference

func (s Uint32s) Difference(other Uint32s) Uint32s

Difference computes the difference of the current Uint32s slice with another Uint32s slice. The result contains only the elements that are in the current slice but not in the other slice.

func (Uint32s) Intersection

func (s Uint32s) Intersection(other Uint32s) Uint32s

Intersection computes the intersection of the current Uint32s slice with another Uint32s slice. The result contains only the elements that exist in both slices.

func (Uint32s) Union

func (s Uint32s) Union(other Uint32s) Uint32s

Union computes the union of the current Uint32s slice with another Uint32s slice. The result contains all unique elements from both slices.

type Uint40

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

Uint40 is a codec for encoding and decoding 40-bit unsigned integers.

func (*Uint40) Get

func (c *Uint40) Get() uint64

Get gets the value as a 40-bit unsigned integer.

func (*Uint40) GetInt

func (c *Uint40) GetInt() int

GetInt gets the value as an int, converted from the 40-bit unsigned integer. Note: If the value exceeds the int range, it will be truncated.

func (*Uint40) MarshalWrite

func (c *Uint40) MarshalWrite(w io.Writer) (err error)

MarshalWrite encodes the 40-bit unsigned integer and writes it to the provided writer. The encoding uses 5 bytes in BigEndian order.

func (*Uint40) Set

func (c *Uint40) Set(value uint64) error

Set sets the value as a 40-bit unsigned integer. If the value exceeds the maximum allowable value for 40 bits, it returns an error.

func (*Uint40) SetInt

func (c *Uint40) SetInt(value int) error

SetInt sets the value as an int, converting it to a 40-bit unsigned integer. If the value is out of the 40-bit range, it returns an error.

func (*Uint40) UnmarshalRead

func (c *Uint40) UnmarshalRead(r io.Reader) (err error)

UnmarshalRead reads 5 bytes from the provided reader and decodes it into a 40-bit unsigned integer.

type Uint40s

type Uint40s []*Uint40

func (Uint40s) Difference

func (s Uint40s) Difference(other Uint40s) Uint40s

Difference computes the difference of the current Uint40s slice with another Uint40s slice. The result contains only the elements that are in the current slice but not in the other slice.

func (Uint40s) Intersection

func (s Uint40s) Intersection(other Uint40s) Uint40s

Intersection computes the intersection of the current Uint40s slice with another Uint40s slice. The result contains only the elements that exist in both slices.

func (Uint40s) Union

func (s Uint40s) Union(other Uint40s) Uint40s

Union computes the union of the current Uint40s slice with another Uint40s slice. The result contains all unique elements from both slices.

type Uint64

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

Uint64 is a codec for encoding and decoding 64-bit unsigned integers.

func (*Uint64) Get

func (c *Uint64) Get() uint64

Get gets the value as a uint64.

func (*Uint64) Int

func (c *Uint64) Int() int

Int gets the value as an int, converted from uint64. May truncate if the value exceeds the range of int.

func (*Uint64) MarshalWrite

func (c *Uint64) MarshalWrite(w io.Writer) error

MarshalWrite writes the uint64 value to the provided writer in BigEndian order.

func (*Uint64) Set

func (c *Uint64) Set(value uint64)

Set sets the value as a uint64.

func (*Uint64) SetInt

func (c *Uint64) SetInt(value int)

SetInt sets the value as an int, converting it to uint64. Values outside the range of uint64 are truncated.

func (*Uint64) UnmarshalRead

func (c *Uint64) UnmarshalRead(r io.Reader) error

UnmarshalRead reads a uint64 value from the provided reader in BigEndian order.

type Uint64s

type Uint64s []*Uint64

func (Uint64s) Difference

func (s Uint64s) Difference(other Uint64s) Uint64s

Difference computes the difference of the current Uint64s slice with another Uint64s slice. The result contains only the elements that are in the current slice but not in the other slice.

func (Uint64s) Intersection

func (s Uint64s) Intersection(other Uint64s) Uint64s

Intersection computes the intersection of the current Uint64s slice with another Uint64s slice. The result contains only the elements that exist in both slices.

func (Uint64s) Union

func (s Uint64s) Union(other Uint64s) Uint64s

Union computes the union of the current Uint64s slice with another Uint64s slice. The result contains all unique elements from both slices.

type Word

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

func (*Word) Bytes

func (w *Word) Bytes() []byte

Bytes returns the raw word without any end-of-word marker

func (*Word) FromWord

func (w *Word) FromWord(word []byte)

FromWord stores the word without any modifications

func (*Word) MarshalWrite

func (w *Word) MarshalWrite(wr io.Writer) (err error)

MarshalWrite writes the word to the writer, appending the zero-byte marker

func (*Word) UnmarshalRead

func (w *Word) UnmarshalRead(r io.Reader) error

UnmarshalRead reads the word from the reader, stopping at the zero-byte marker

Jump to

Keyboard shortcuts

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