当前位置: 首页>>代码示例>>Golang>>正文


Golang Writer.WriteUint16方法代码示例

本文整理汇总了Golang中github.com/calmh/xdr.Writer.WriteUint16方法的典型用法代码示例。如果您正苦于以下问题:Golang Writer.WriteUint16方法的具体用法?Golang Writer.WriteUint16怎么用?Golang Writer.WriteUint16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/calmh/xdr.Writer的用法示例。


在下文中一共展示了Writer.WriteUint16方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: EncodeXDRInto

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()
}
开发者ID:kattunga,项目名称:syncthing,代码行数:31,代码来源:encdec_xdr_test.go

示例2: encodeXDR

func (o Address) encodeXDR(xw *xdr.Writer) (int, error) {
	if len(o.IP) > 16 {
		return xw.Tot(), xdr.ErrElementSizeExceeded
	}
	xw.WriteBytes(o.IP)
	xw.WriteUint16(o.Port)
	return xw.Tot(), xw.Error()
}
开发者ID:baa-archieve,项目名称:syncthing,代码行数:8,代码来源:packets_xdr.go

示例3: EncodeXDRInto

func (o Address) EncodeXDRInto(xw *xdr.Writer) (int, error) {
	if l := len(o.IP); l > 16 {
		return xw.Tot(), xdr.ElementSizeExceeded("IP", l, 16)
	}
	xw.WriteBytes(o.IP)
	xw.WriteUint16(o.Port)
	return xw.Tot(), xw.Error()
}
开发者ID:kattunga,项目名称:syncthing,代码行数:8,代码来源:packets_xdr.go

示例4: EncodeXDRInto

func (o SessionInvitation) EncodeXDRInto(xw *xdr.Writer) (int, error) {
	if l := len(o.From); l > 32 {
		return xw.Tot(), xdr.ElementSizeExceeded("From", l, 32)
	}
	xw.WriteBytes(o.From)
	if l := len(o.Key); l > 32 {
		return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 32)
	}
	xw.WriteBytes(o.Key)
	if l := len(o.Address); l > 32 {
		return xw.Tot(), xdr.ElementSizeExceeded("Address", l, 32)
	}
	xw.WriteBytes(o.Address)
	xw.WriteUint16(o.Port)
	xw.WriteBool(o.ServerSocket)
	return xw.Tot(), xw.Error()
}
开发者ID:readthecodes,项目名称:syncthing,代码行数:17,代码来源:packets_xdr.go

示例5: EncodeXDRInto

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()
}
开发者ID:kattunga,项目名称:syncthing,代码行数:17,代码来源:bench_xdr_test.go

示例6: encodeXDR

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()
}
开发者ID:GDXN,项目名称:syncthing,代码行数:17,代码来源:bench_xdr_test.go

示例7: encodeXDR

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()
}
开发者ID:Blueprint-Marketing,项目名称:syncthing,代码行数:18,代码来源:encdec_xdr_test.go

示例8: encodeXDR

func (o address) encodeXDR(xw *xdr.Writer) (int, error) {
	xw.WriteBytes(o.ip)
	xw.WriteUint16(o.port)
	xw.WriteUint64(uint64(o.seen))
	return xw.Tot(), xw.Error()
}
开发者ID:mapleshadow,项目名称:discosrv,代码行数:6,代码来源:types_xdr.go


注:本文中的github.com/calmh/xdr.Writer.WriteUint16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。