optional

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOptional = errors.New("decoding failed, invalid optional")

ErrInvalidOptional is returned when decoding an optional fails

Functions

This section is empty.

Types

type Body

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

Body represents an optional types.Body.

func NewBody

func NewBody(exists bool, value CoreBody) *Body

NewBody returns a new optional.Body

func (*Body) Exists

func (x *Body) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Body) Set

func (x *Body) Set(exists bool, value CoreBody)

Set sets the exists and value fields.

func (*Body) String

func (x *Body) String() string

String returns the value as a string.

func (*Body) Value

func (x *Body) Value() []byte

Value returns the value as []byte if it exists

type Boolean added in v0.3.0

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

Boolean represents an optional bool type.

func NewBoolean added in v0.3.0

func NewBoolean(exists bool, value bool) *Boolean

NewBoolean returns a new optional.Boolean

func (*Boolean) Decode added in v0.3.0

func (x *Boolean) Decode(r io.Reader) (*Boolean, error)

Decode return an optional Boolean from scale encoded data

func (*Boolean) Encode added in v0.3.0

func (x *Boolean) Encode() ([]byte, error)

Encode returns the SCALE encoded optional

func (*Boolean) Exists added in v0.3.0

func (x *Boolean) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Boolean) Set added in v0.3.0

func (x *Boolean) Set(value bool)

Set sets the exists and value fields.

func (*Boolean) Value added in v0.3.0

func (x *Boolean) Value() bool

Value returns the []byte value. It returns nil if it is None.

type Bytes

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

Bytes represents an optional Bytes type.

func NewBytes

func NewBytes(exists bool, value []byte) *Bytes

NewBytes returns a new optional.Bytes

func (*Bytes) Decode added in v0.2.0

func (x *Bytes) Decode(r io.Reader) (*Bytes, error)

Decode return an optional Bytes from scale encoded data

func (*Bytes) Encode added in v0.2.0

func (x *Bytes) Encode() ([]byte, error)

Encode returns the SCALE encoded optional

func (*Bytes) Exists

func (x *Bytes) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Bytes) Set

func (x *Bytes) Set(exists bool, value []byte)

Set sets the exists and value fields.

func (*Bytes) String

func (x *Bytes) String() string

String returns the value as a string.

func (*Bytes) Value

func (x *Bytes) Value() []byte

Value returns the []byte value. It returns nil if it is None.

type CoreBody

type CoreBody []byte

CoreBody is the extrinsics inside a state block

type CoreHeader

type CoreHeader struct {
	ParentHash     common.Hash `json:"parentHash"`
	Number         *big.Int    `json:"number"`
	StateRoot      common.Hash `json:"stateRoot"`
	ExtrinsicsRoot common.Hash `json:"extrinsicsRoot"`
	Digest         Digest      `json:"digest"`
}

CoreHeader is a state block header This is copied from core/types since core/types imports this package, we cannot import core/types.

func (*CoreHeader) String added in v0.3.0

func (h *CoreHeader) String() string

type Digest added in v0.3.0

type Digest interface {
	Encode() ([]byte, error)
	Decode(io.Reader) error // Decode assumes the type byte (first byte) has been removed from the encoding.
}

Digest is the interface implemented by the block digest

type FixedSizeBytes added in v0.3.2

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

FixedSizeBytes represents an optional FixedSizeBytes type. It does not length-encode the value when encoding.

func NewFixedSizeBytes added in v0.3.2

func NewFixedSizeBytes(exists bool, value []byte) *FixedSizeBytes

NewFixedSizeBytes returns a new optional.FixedSizeBytes

func (*FixedSizeBytes) Decode added in v0.3.2

func (x *FixedSizeBytes) Decode(r io.Reader) (*FixedSizeBytes, error)

Decode return an optional FixedSizeBytes from scale encoded data

func (*FixedSizeBytes) Encode added in v0.3.2

func (x *FixedSizeBytes) Encode() ([]byte, error)

Encode returns the SCALE encoded optional

func (*FixedSizeBytes) Exists added in v0.3.2

func (x *FixedSizeBytes) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*FixedSizeBytes) Set added in v0.3.2

func (x *FixedSizeBytes) Set(exists bool, value []byte)

Set sets the exists and value fields.

func (*FixedSizeBytes) String added in v0.3.2

func (x *FixedSizeBytes) String() string

String returns the value as a string.

func (*FixedSizeBytes) Value added in v0.3.2

func (x *FixedSizeBytes) Value() []byte

Value returns the []byte value. It returns nil if it is None.

type Hash

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

Hash represents an optional Hash type.

func NewHash

func NewHash(exists bool, value common.Hash) *Hash

NewHash returns a new optional.Hash

func (*Hash) Exists

func (x *Hash) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Hash) Set

func (x *Hash) Set(exists bool, value common.Hash)

Set sets the exists and value fields.

func (*Hash) String

func (x *Hash) String() string

String returns the value as a string.

func (*Hash) Value

func (x *Hash) Value() common.Hash

Value returns Hash Value

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

Header represents an optional header type

func NewHeader

func NewHeader(exists bool, value *CoreHeader) *Header

NewHeader returns a new optional.Header

func (*Header) Exists

func (x *Header) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Header) Set

func (x *Header) Set(exists bool, value *CoreHeader)

Set sets the exists and value fields.

func (*Header) String

func (x *Header) String() string

String returns the value as a string.

func (*Header) Value

func (x *Header) Value() *CoreHeader

Value returns the value of the header. It returns nil if the header is None.

type Uint32

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

Uint32 represents an optional uint32 type.

func NewUint32

func NewUint32(exists bool, value uint32) *Uint32

NewUint32 returns a new optional.Uint32

func (*Uint32) Encode added in v0.3.0

func (x *Uint32) Encode() []byte

Encode returns the SCALE encoding of the optional.Uint32

func (*Uint32) Exists

func (x *Uint32) Exists() bool

Exists returns true if the value is Some, false if it is None.

func (*Uint32) Set

func (x *Uint32) Set(exists bool, value uint32)

Set sets the exists and value fields.

func (*Uint32) String

func (x *Uint32) String() string

String returns the value as a string.

func (*Uint32) Value

func (x *Uint32) Value() uint32

Value returns the uint32 value. It returns 0 if it is None.

Jump to

Keyboard shortcuts

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