Documentation ¶
Index ¶
- Variables
- func DecodeTo(data []byte, dest Item) (int, error)
- func Encode(data Item) ([]byte, error)
- type BigIntItem
- type BinaryMarshaler
- type BinaryMarshalerItem
- type Item
- type ListItem
- type RLP
- func (r RLP) Bytes() []byte
- func (r *RLP) DecodeRLP(data []byte) (int, error)
- func (r RLP) DecodeTo(dest Item) error
- func (r RLP) EncodeRLP() ([]byte, error)
- func (r RLP) Get(i Item, fn func(Item)) error
- func (r RLP) GetBigInt() (*big.Int, error)
- func (r RLP) GetBigIntItem() (*BigIntItem, error)
- func (r RLP) GetBinaryMarshalerItem() (*BinaryMarshalerItem, error)
- func (r RLP) GetBytes() ([]byte, error)
- func (r RLP) GetList() ([]*RLP, error)
- func (r RLP) GetListItem() (*ListItem, error)
- func (r RLP) GetString() (string, error)
- func (r RLP) GetStringItem() (*StringItem, error)
- func (r RLP) GetUint() (uint64, error)
- func (r RLP) GetUintItem() (*UintItem, error)
- func (r RLP) IsList() bool
- func (r RLP) IsString() bool
- func (r RLP) Length() uint64
- type StringItem
- type UintItem
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("rlp: value too large")
var ErrUnexpectedEndOfData = errors.New("rlp: unexpected end of data")
var ErrUnsupportedType = errors.New("rlp: unsupported type")
Functions ¶
Types ¶
type BigIntItem ¶
BigIntItem is a RLP encoded big integer.
func (BigIntItem) EncodeRLP ¶
func (b BigIntItem) EncodeRLP() ([]byte, error)
type BinaryMarshaler ¶
type BinaryMarshaler interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
type BinaryMarshalerItem ¶
type BinaryMarshalerItem struct {
X BinaryMarshaler
}
BinaryMarshalerItem is a RLP encoded struct that implements the encoding.BinaryMarshaler and encoding.BinaryUnmarshaler interfaces.
func NewBinaryMarshaler ¶
func NewBinaryMarshaler(x BinaryMarshaler) *BinaryMarshalerItem
NewBinaryMarshaler creates a new BinaryMarshaler item.
func (*BinaryMarshalerItem) DecodeRLP ¶
func (m *BinaryMarshalerItem) DecodeRLP(d []byte) (int, error)
func (BinaryMarshalerItem) EncodeRLP ¶
func (m BinaryMarshalerItem) EncodeRLP() ([]byte, error)
type Item ¶
type Item interface { // EncodeRLP returns the RLP encoding of the item. EncodeRLP() ([]byte, error) // DecodeRLP decodes the given RLP data and returns the number of bytes // read. The given data may be longer than the encoded item, in which case // the remaining data is ignored. DecodeRLP([]byte) (int, error) }
Item represents an item that can be encoded and decoded using RLP.
https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/
type ListItem ¶
type ListItem []Item
ListItem is a RLP encoded list. During decoding, the data is decoded into existing items if possible. If there are more items in the list than existing items, new items are created.
type RLP ¶
type RLP []byte
RLP is a raw RLP encoded data that can be decoded into any other type later.
func Decode ¶
Decode performs lazy decoding of RLP encoded data. It returns an RLP type that provides methods for further decoding, the number of bytes read and an error, if any.
Because decoding is performed lazily, the Encode function may not return an error if the data is invalid.
func (RLP) Bytes ¶
Bytes returns raw RLP encoded data. To get the decoded data use one of the Get* methods.
func (RLP) Get ¶
Get decodes RLP encoded data into the given item and if decoding was successful it invokes the fn callback.
func (RLP) GetBigInt ¶
GetBigInt tries to decode itself as a big.Int. If the decoding was successful it returns the decoded big.Int.
func (RLP) GetBigIntItem ¶
func (r RLP) GetBigIntItem() (*BigIntItem, error)
GetBigIntItem tries to decode itself as a big integer. If the decoding was successful it returns the decoded BigIntItem.
func (RLP) GetBinaryMarshalerItem ¶
func (r RLP) GetBinaryMarshalerItem() (*BinaryMarshalerItem, error)
GetBinaryMarshalerItem tries to decode itself as a BinaryMarshaler. If the decoding was successful it returns the decoded BinaryMarshalerItem.
func (RLP) GetBytes ¶
GetBytes tries to decode itself as a byte slice. If the decoding was successful it returns the decoded byte slice.
func (RLP) GetList ¶
GetList tries to decode itself as a slice of RLP items. If the decoding was successful it returns the decoded slice.
func (RLP) GetListItem ¶
GetListItem tries to decode itself as a list. If the decoding was successful it returns the decoded ListItem.
func (RLP) GetString ¶
GetString tries to decode itself as a string. If the decoding was successful it returns the decoded string.
func (RLP) GetStringItem ¶
func (r RLP) GetStringItem() (*StringItem, error)
GetStringItem tries to decode itself as a string. If the decoding was successful it returns the decoded StringItem.
func (RLP) GetUint ¶
GetUint tries to decode itself as an uint64. If the decoding was successful it returns the decoded uint64.
func (RLP) GetUintItem ¶
GetUintItem tries to decode itself as an integer. If the decoding was successful it returns the decoded UintItem.
func (RLP) IsList ¶
IsList returns true if the encoded data is a list. If the data is empty, it returns false.
type StringItem ¶
type StringItem []byte
StringItem is a RLP encoded string.
func NewBytes ¶
func NewBytes(data []byte) *StringItem
NewBytes creates a new String item from byte slice.
func (StringItem) Bytes ¶
func (s StringItem) Bytes() []byte
Bytes returns the byte slice representation of the string type.
func (StringItem) EncodeRLP ¶
func (s StringItem) EncodeRLP() ([]byte, error)
func (StringItem) String ¶
func (s StringItem) String() string
String returns the string representation of the string type.