代码拉取完成,页面将自动刷新
package claimsheader
// NewClaimsHeader returns claims header handler
func NewClaimsHeader(opts ...Option) *ClaimsHeader {
c := &ClaimsHeader{}
for _, opt := range opts {
opt(c)
}
return c
}
// ToBytes generates the 32-bit header in bytes
// 0 1 2 3 4
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | D |CT|E| R (reserved) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// D [0:5] - Datapath version
// CT [6,7] - Compressed tag type
// E [8] - Encryption enabled
// R [9:31] - Reserved
func (c *ClaimsHeader) ToBytes() HeaderBytes {
claimsHeaderData := make([]byte, maxHeaderLen)
claimsHeaderData[0] |= c.datapathVersion.toMask().toUint8()
claimsHeaderData[0] |= c.compressionType.toMask().toUint8()
claimsHeaderData[1] |= boolToUint8(c.encrypt)
return claimsHeaderData
}
// CompressionType is the compression type
func (c *ClaimsHeader) CompressionType() CompressionType {
return c.compressionType
}
// Encrypt is the encrypt in bool
func (c *ClaimsHeader) Encrypt() bool {
return c.encrypt
}
// DatapathVersion is the datapath version
func (c *ClaimsHeader) DatapathVersion() DatapathVersion {
return c.datapathVersion
}
// SetCompressionType sets the compression type
func (c *ClaimsHeader) SetCompressionType(ct CompressionType) {
c.compressionType = ct
}
// SetEncrypt sets the encrypt
func (c *ClaimsHeader) SetEncrypt(e bool) {
c.encrypt = e
}
// SetDatapathVersion sets the datapath version
func (c *ClaimsHeader) SetDatapathVersion(dv DatapathVersion) {
c.datapathVersion = dv
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。