Esempio n. 1
0
func (o TestStruct) EncodeXDRInto(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(uint64(o.I))
	xw.WriteUint8(uint8(o.I8))
	xw.WriteUint8(o.UI8)
	xw.WriteUint16(uint16(o.I16))
	xw.WriteUint16(o.UI16)
	xw.WriteUint32(uint32(o.I32))
	xw.WriteUint32(o.UI32)
	xw.WriteUint64(uint64(o.I64))
	xw.WriteUint64(o.UI64)
	if l := len(o.BS); l > 1024 {
		return xw.Tot(), xdr.ElementSizeExceeded("BS", l, 1024)
	}
	xw.WriteBytes(o.BS)
	if l := len(o.S); l > 1024 {
		return xw.Tot(), xdr.ElementSizeExceeded("S", l, 1024)
	}
	xw.WriteString(o.S)
	_, err := o.C.EncodeXDRInto(xw)
	if err != nil {
		return xw.Tot(), err
	}
	if l := len(o.SS); l > 1024 {
		return xw.Tot(), xdr.ElementSizeExceeded("SS", l, 1024)
	}
	xw.WriteUint32(uint32(len(o.SS)))
	for i := range o.SS {
		xw.WriteString(o.SS[i])
	}
	return xw.Tot(), xw.Error()
}
Esempio n. 2
0
func (o XDRBenchStruct) EncodeXDRInto(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(o.I1)
	xw.WriteUint32(o.I2)
	xw.WriteUint16(o.I3)
	xw.WriteUint8(o.I4)
	if l := len(o.Bs0); l > 128 {
		return xw.Tot(), xdr.ElementSizeExceeded("Bs0", l, 128)
	}
	xw.WriteBytes(o.Bs0)
	xw.WriteBytes(o.Bs1)
	if l := len(o.S0); l > 128 {
		return xw.Tot(), xdr.ElementSizeExceeded("S0", l, 128)
	}
	xw.WriteString(o.S0)
	xw.WriteString(o.S1)
	return xw.Tot(), xw.Error()
}
Esempio n. 3
0
func (o XDRBenchStruct) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(o.I1)
	xw.WriteUint32(o.I2)
	xw.WriteUint16(o.I3)
	xw.WriteUint8(o.I4)
	if len(o.Bs0) > 128 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.Bs0)
	xw.WriteBytes(o.Bs1)
	if len(o.S0) > 128 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteString(o.S0)
	xw.WriteString(o.S1)
	return xw.Tot(), xw.Error()
}
func (o TestStruct) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteUint64(uint64(o.I))
	xw.WriteUint8(uint8(o.I8))
	xw.WriteUint8(o.UI8)
	xw.WriteUint16(uint16(o.I16))
	xw.WriteUint16(o.UI16)
	xw.WriteUint32(uint32(o.I32))
	xw.WriteUint32(o.UI32)
	xw.WriteUint64(uint64(o.I64))
	xw.WriteUint64(o.UI64)
	xw.WriteBytes(o.BS)
	xw.WriteString(o.S)
	_, err := o.C.encodeXDR(xw)
	if err != nil {
		return xw.Tot(), err
	}
	return xw.Tot(), xw.Error()
}