1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-07 05:44:28 -04:00
v2fly/common/serial/bytes.go

36 lines
617 B
Go
Raw Normal View History

2015-12-12 07:11:49 -05:00
package serial
type Bytes interface {
Bytes() []byte
}
type BytesLiteral []byte
func (this BytesLiteral) Value() []byte {
return []byte(this)
}
func (this BytesLiteral) Int64Value() int64 {
value := this.Value()
return int64(value[0])<<56 +
int64(value[1])<<48 +
int64(value[2])<<40 +
int64(value[3])<<32 +
int64(value[4])<<24 +
int64(value[5])<<16 +
int64(value[6])<<8 +
int64(value[7])
}
2016-01-18 06:58:04 -05:00
func (this BytesLiteral) String() string {
return string(this.Value())
}
2016-01-20 11:45:50 -05:00
func (this BytesLiteral) AllZero() bool {
for _, b := range this {
if b != 0 {
return false
}
}
return true
}