1 Star 0 Fork 19

unsafe-rust/y3-codec-golang

forked from YoMo/y3-codec-golang 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
signalling.go 1013 Bytes
一键复制 编辑 原始数据 按行查看 历史
package y3
import (
"fmt"
)
// signal is builder for PrimitivePacketEncoder
type signal struct {
encoder *PrimitivePacketEncoder
}
// createSignal create a signal
func createSignal(key byte) *signal {
return &signal{encoder: NewPrimitivePacketEncoder(int(key))}
}
// SetString set a string Value for the signal
func (s *signal) SetString(v string) *signal {
s.encoder.SetStringValue(v)
return s
}
// SetString set a int64 Value for the signal
func (s *signal) SetInt64(v int64) *signal {
s.encoder.SetInt64Value(v)
return s
}
// SetString set a float64 Value for the signal
func (s *signal) SetFloat64(v float64) *signal {
s.encoder.SetFloat64Value(v)
return s
}
// ToEncoder return current PrimitivePacketEncoder, and checking legality
func (s *signal) ToEncoder(allow func(key byte) bool) *PrimitivePacketEncoder {
if allow != nil && !allow(byte(s.encoder.seqID)) {
panic(fmt.Errorf("it is not allowed to use this key to create a signal: %#x", byte(s.encoder.seqID)))
}
return s.encoder
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/unsafe-rust/y3-codec-golang.git
git@gitee.com:unsafe-rust/y3-codec-golang.git
unsafe-rust
y3-codec-golang
y3-codec-golang
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385