Introduce AddressMask.AsSlice

...to get a slice view into the AddressMask.

PiperOrigin-RevId: 532583738
This commit is contained in:
Ghanan Gowripalan
2023-05-16 15:08:57 -07:00
committed by gVisor bot
parent 74e63e9e29
commit 891259ffa8
+6
View File
@@ -326,6 +326,12 @@ func (m AddressMask) String() string {
return fmt.Sprintf("%x", m.mask)
}
// AsSlice returns a as a byte slice. Callers should be careful as it can
// return a window into existing memory.
func (m *AddressMask) AsSlice() []byte {
return []byte(m.mask)
}
// BitLen returns the length of the mask in bits.
func (m AddressMask) BitLen() int {
return len(m.mask) * 8