types/views,cmd/viewer: add ByteSlice[T] to replace mem.RO

Add a new views.ByteSlice[T ~[]byte] to provide a better API to use
with views.

Updates #cleanup

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2023-08-20 14:35:39 -04:00
committed by Maisem Ali
parent 8a5ec72c85
commit 2548496cef
5 changed files with 118 additions and 30 deletions

View File

@@ -10,7 +10,6 @@ import (
"errors"
"net/netip"
"go4.org/mem"
"tailscale.com/types/views"
)
@@ -312,7 +311,7 @@ func (v StructWithSlicesView) Slice() views.Slice[string] { return views.SliceOf
func (v StructWithSlicesView) Prefixes() views.Slice[netip.Prefix] {
return views.SliceOf(v.ж.Prefixes)
}
func (v StructWithSlicesView) Data() mem.RO { return mem.B(v.ж.Data) }
func (v StructWithSlicesView) Data() views.ByteSlice[[]byte] { return views.ByteSliceOf(v.ж.Data) }
// A compilation failure here means this code must be regenerated, with the command at the top of this file.
var _StructWithSlicesViewNeedsRegeneration = StructWithSlices(struct {