pub struct Packer { /* private fields */ }
Expand description

Implementations§

Writes the “IP” value at the offset in 16-byte representation and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackIP” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackIP ref. https://doc.rust-lang.org/std/net/enum.IpAddr.html ref. https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html ref. https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html

Unpacks the “IP” in the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackIP” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackIP

Writes the list of “IP” values at the offset in 16-byte representation and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackIPs” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackIPs

Unpacks the list of “IP“s in the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackIPs” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackIPs

Creates a new Packer with 32-bit message length header.

Create a new packer from the existing bytes. Resets the offset to the end of the existing bytes.

Create a new packer from the existing bytes. Resets the offset to the beginning of the existing bytes.

Returns the current bytes array as an immutable bytes array. If the packer header is set to “true”, the first 4-byte represents the message length in the big-endian order. The returned bytes length will be 4-byte + message.

Be cautious! Once bytes are taken out, the “bytes” field is set to default (empty). To continue to write to bytes, remember to put it back with “set_bytes” because “bytes.take” leaves the field as “Default::default()”. TODO: make sure this does shallow copy!

Sets the current bytes array as an immutable bytes array. Useful to reuse packer after calling “take_bytes”, which makes the “bytes” field default (empty).

Returns the “offset” value.

Returns the current length of the bytes array.

Returns the current capacity of the bytes array.

Ensures the remaining capacity of the bytes array so it can write “n” bytes to the array. ref. “avalanchego/utils/wrappers.Packer.Expand” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.Expand

Writes the “u8” value at the offset and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackByte” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackByte

Unpacks the byte in the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackByte” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackByte

Writes the “u16” value at the offset and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackShort” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackShort

Unpacks the u16 from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackShort” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackShort

Writes the “u32” value at the offset and increments the offset afterwards. This is also used for encoding the type IDs from codec. ref. “avalanchego/utils/wrappers.Packer.PackInt” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackInt

Unpacks the u32 from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackInt” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackInt

Writes the “u64” value at the offset and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackLong” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackLong

Unpacks the u64 from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackLong” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackLong

Writes the “bool” value at the offset and increments the offset afterwards. ref. “avalanchego/utils/wrappers.Packer.PackBool” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackBool

Unpacks the bool in the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackBool” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackBool

Writes the “u8” fixed-size array from the offset and increments the offset as much. ref. “avalanchego/utils/wrappers.Packer.PackFixedBytes” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackFixedBytes

Unpacks the “u8” fixed-size array from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackFixedBytes” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackFixedBytes

Writes the “u8” slice from the offset and increments the offset as much. The first 4-byte is used for encoding length header. ref. “avalanchego/utils/wrappers.Packer.PackBytes” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackBytes

Unpacks the “u8” slice from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackBytes” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackBytes

Writes the two-dimensional “u8” slice from the offset and increments the offset as much. ref. “avalanchego/utils/wrappers.Packer.PackFixedByteSlices” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackFixedByteSlices

Unpacks the two-dimensional “u8” slice from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.UnpackFixedByteSlices” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackFixedByteSlices

Writes the two-dimensional “u8” slice from the offset and increments the offset as much. ref. “avalanchego/utils/wrappers.Packer.Pack2DByteSlice” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.Pack2DByteSlice

Unpacks the two-dimensional “u8” slice from the “offset” position, and advances the cursor and offset. ref. “avalanchego/utils/wrappers.Packer.Unpack2DByteSlice” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.Unpack2DByteSlice

Writes str from the offset and increments the offset as much. ref. “avalanchego/utils/wrappers.Packer.PackStr” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.PackStr

Unpacks str from the offset. ref. “avalanchego/utils/wrappers.Packer.UnpackStr”

TODO: Go “UnpackStr” does deep-copy of bytes to “string” cast Can we bypass deep-copy by passing around bytes? ref. https://github.com/golang/go/issues/25484

ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/wrappers#Packer.UnpackStr

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Wrap the input message T in a tonic::Request
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more