Documentation
¶
Overview ¶
Package xdr implements an XDR (RFC 4506) marshaller/unmarshaller.
Index ¶
- func ElementSizeExceeded(field string, size, limit int) error
- func Padding(l int) int
- func SizeOfSlice(ss interface{}) int
- type Marshaller
- func (m *Marshaller) MarshalBool(v bool)
- func (m *Marshaller) MarshalBytes(bs []byte)
- func (m *Marshaller) MarshalRaw(bs []byte)
- func (m *Marshaller) MarshalString(s string)
- func (m *Marshaller) MarshalUint16(v uint16)
- func (m *Marshaller) MarshalUint32(v uint32)
- func (m *Marshaller) MarshalUint64(v uint64)
- func (m *Marshaller) MarshalUint8(v uint8)
- type Sizer
- type Unmarshaller
- func (u *Unmarshaller) UnmarshalBool() bool
- func (u *Unmarshaller) UnmarshalBytes() []byte
- func (u *Unmarshaller) UnmarshalBytesMax(max int) []byte
- func (u *Unmarshaller) UnmarshalRaw(l int) []byte
- func (u *Unmarshaller) UnmarshalString() string
- func (u *Unmarshaller) UnmarshalStringMax(max int) string
- func (u *Unmarshaller) UnmarshalUint16() uint16
- func (u *Unmarshaller) UnmarshalUint32() uint32
- func (u *Unmarshaller) UnmarshalUint64() uint64
- func (u *Unmarshaller) UnmarshalUint8() uint8
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ElementSizeExceeded ¶
ElementSizeExceeded returns an error describing the violated size constraint. This function is used by the generated marshalling code.
func Padding ¶
Padding returns the number of bytes that should be added to an item of length l bytes to conform to the XDR padding standard. This function is used by the generated marshalling code.
func SizeOfSlice ¶
func SizeOfSlice(ss interface{}) int
SizeOfSlice returns the XDR encoded size of the given []T. Supported types for T are string, []byte and types implementing Sizer. SizeOfSlice panics if the parameter is not a slice or if T is not one of the supported types. This function is used by the generated marshalling code.
Types ¶
type Marshaller ¶
Marshaller is a thin wrapper around a byte buffer. The buffer must be of sufficient size to hold the complete marshalled object, or an io.ErrShortBuffer error will result. The Marshal... methods don't individually return an error - the intention is that multiple fields are marshalled in rapid succession, followed by a check of the Error field on the Marshaller.
func (*Marshaller) MarshalBool ¶
func (m *Marshaller) MarshalBool(v bool)
MarshalBool appends the bool to the buffer, as an uint32.
func (*Marshaller) MarshalBytes ¶
func (m *Marshaller) MarshalBytes(bs []byte)
MarshalBytes appends the bytes to the buffer, with a size prefix and correct padding.
func (*Marshaller) MarshalRaw ¶
func (m *Marshaller) MarshalRaw(bs []byte)
MarshalRaw copies the raw bytes to the buffer, without a size prefix or padding. This is suitable for appending data already in XDR format from another source.
func (*Marshaller) MarshalString ¶
func (m *Marshaller) MarshalString(s string)
MarshalString appends the string to the buffer, with a size prefix and correct padding.
func (*Marshaller) MarshalUint16 ¶
func (m *Marshaller) MarshalUint16(v uint16)
MarshalUint16 appends the uint16 to the buffer, as an uint32.
func (*Marshaller) MarshalUint32 ¶
func (m *Marshaller) MarshalUint32(v uint32)
MarshalUint32 appends the uint32 to the buffer.
func (*Marshaller) MarshalUint64 ¶
func (m *Marshaller) MarshalUint64(v uint64)
MarshalUint64 appends the uint64 to the buffer.
func (*Marshaller) MarshalUint8 ¶
func (m *Marshaller) MarshalUint8(v uint8)
MarshalUint8 appends the uint8 to the buffer, as an uint32.
type Sizer ¶
type Sizer interface {
XDRSize() int
}
Sizer is a value that can return its XDR serialized size.
type Unmarshaller ¶
Unmarshaller is a thin wrapper around a byte buffer. The Unmarshal... methods don't individually return an error - the intention is that multiple fields are unmarshalled in rapid succession, followed by a check of the Error field on the Unmarshaller.
func (*Unmarshaller) UnmarshalBool ¶
func (u *Unmarshaller) UnmarshalBool() bool
UnmarshalBool returns a bool from the buffer.
func (*Unmarshaller) UnmarshalBytes ¶
func (u *Unmarshaller) UnmarshalBytes() []byte
UnmarshalBytes returns a byte slice from the buffer.
func (*Unmarshaller) UnmarshalBytesMax ¶
func (u *Unmarshaller) UnmarshalBytesMax(max int) []byte
UnmarshalBytesMax returns a byte slice up to a max length from the buffer.
func (*Unmarshaller) UnmarshalRaw ¶
func (u *Unmarshaller) UnmarshalRaw(l int) []byte
UnmarshalRaw returns a byte slice of length l from the buffer, without a size prefix or padding. This is suitable for retrieving data already in XDR format.
func (*Unmarshaller) UnmarshalString ¶
func (u *Unmarshaller) UnmarshalString() string
UnmarshalString returns a string from the buffer.
func (*Unmarshaller) UnmarshalStringMax ¶
func (u *Unmarshaller) UnmarshalStringMax(max int) string
UnmarshalStringMax returns a string up to a max length from the buffer.
func (*Unmarshaller) UnmarshalUint16 ¶
func (u *Unmarshaller) UnmarshalUint16() uint16
UnmarshalUint16 returns a uint16 from the buffer.
func (*Unmarshaller) UnmarshalUint32 ¶
func (u *Unmarshaller) UnmarshalUint32() uint32
UnmarshalUint32 returns a uint32 from the buffer.
func (*Unmarshaller) UnmarshalUint64 ¶
func (u *Unmarshaller) UnmarshalUint64() uint64
UnmarshalUint64 returns a uint64 from the buffer.
func (*Unmarshaller) UnmarshalUint8 ¶
func (u *Unmarshaller) UnmarshalUint8() uint8
UnmarshalUint8 returns a uint8 from the buffer.