Documentation ¶
Overview ¶
Package schema implements miscellaneous data structures that can be converted to and from blobs.
Index ¶
- Variables
- func ProtectList(f gc.ProtectFunc) gc.ProtectFunc
- func ProtectMap(k, v gc.ProtectFunc) gc.ProtectFunc
- func ProtectSet(f gc.ProtectFunc) gc.ProtectFunc
- type List
- type Map
- func (*Map) Descriptor() ([]byte, []int)deprecated
- func (m *Map) Each(ctx context.Context, g bs.Getter, f func(*MapPair) error) error
- func (x *Map) GetMembers() []*MapPair
- func (x *Map) GetNode() *TreeNode
- func (m *Map) IsEmpty() bool
- func (m *Map) Lookup(ctx context.Context, g bs.Getter, key []byte) ([]byte, bool, error)
- func (*Map) ProtoMessage()
- func (x *Map) ProtoReflect() protoreflect.Message
- func (m *Map) Remove(ctx context.Context, store bs.Store, key []byte) (bs.Ref, bool, error)
- func (x *Map) Reset()
- func (m *Map) Set(ctx context.Context, store bs.Store, key, payload []byte) (bs.Ref, Outcome, error)
- func (x *Map) String() string
- type MapPair
- type Outcome
- type Set
- func (s *Set) Add(ctx context.Context, store bs.Store, ref bs.Ref) (bs.Ref, bool, error)
- func (s *Set) Check(ctx context.Context, g bs.Getter, ref bs.Ref) (bool, error)
- func (*Set) Descriptor() ([]byte, []int)deprecated
- func (s *Set) Each(ctx context.Context, g bs.Getter, f func(bs.Ref) error) error
- func (x *Set) GetMembers() [][]byte
- func (x *Set) GetNode() *TreeNode
- func (*Set) ProtoMessage()
- func (x *Set) ProtoReflect() protoreflect.Message
- func (s *Set) Remove(ctx context.Context, store bs.Store, ref bs.Ref) (bs.Ref, bool, error)
- func (x *Set) Reset()
- func (x *Set) String() string
- type SubNode
- type TreeNode
- func (*TreeNode) Descriptor() ([]byte, []int)deprecated
- func (x *TreeNode) GetDepth() int32
- func (x *TreeNode) GetLeft() *SubNode
- func (x *TreeNode) GetRight() *SubNode
- func (x *TreeNode) GetSize() int32
- func (*TreeNode) ProtoMessage()
- func (x *TreeNode) ProtoReflect() protoreflect.Message
- func (x *TreeNode) Reset()
- func (x *TreeNode) String() string
Constants ¶
This section is empty.
Variables ¶
var File_schema_proto protoreflect.FileDescriptor
Functions ¶
func ProtectList ¶ added in v0.3.0
func ProtectList(f gc.ProtectFunc) gc.ProtectFunc
ProtectList returns a gc.ProtectFunc that protects the list and its member refs from garbage collection. The function f is the ProtectFunc for the members of the list.
func ProtectMap ¶ added in v0.3.0
func ProtectMap(k, v gc.ProtectFunc) gc.ProtectFunc
ProtectMap returns a gc.ProtectFunc that protects the nodes of a Map and any refs they contain. The parameters k and v are ProtectFuncs for protecting keys and values found in the Map, if those should be interpreted as refs; they should be nil if not.
func ProtectSet ¶ added in v0.3.0
func ProtectSet(f gc.ProtectFunc) gc.ProtectFunc
ProtectSet returns a gc.ProtectFunc that protects the nodes of a Set and the refs they contain. The parameter f is the function that protects the refs that are members of the Set.
Types ¶
type List ¶
type List struct { Members [][]byte `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"` // contains filtered or unexported fields }
func ListFromRefs ¶
ListFromRefs creates a new list whose members are the given refs, and stores the resulting list in s. It returns the List and the ref at which it is stored.
func (*List) Descriptor
deprecated
func (*List) GetMembers ¶
func (*List) ProtoMessage ¶
func (*List) ProtoMessage()
func (*List) ProtoReflect ¶
func (x *List) ProtoReflect() protoreflect.Message
type Map ¶
type Map struct { Node *TreeNode `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // Mutually exclusive with node.left and node.right. Members []*MapPair `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` // contains filtered or unexported fields }
func (*Map) Descriptor
deprecated
func (*Map) Each ¶
Each calls a function for each member pair of a Map, in an indeterminate order. If the callback returns an error, Each exits with that error.
func (*Map) GetMembers ¶
func (*Map) Lookup ¶
Lookup finds the given key in a Map and returns its payload if found. The boolean return value indicates whether the key was in the Map.
func (*Map) ProtoMessage ¶
func (*Map) ProtoMessage()
func (*Map) ProtoReflect ¶
func (x *Map) ProtoReflect() protoreflect.Message
func (*Map) Remove ¶
Remove removes the member pair with the given key from a Map. It return's the Map's possibly-updated Ref and a boolean telling whether a change was made, which will be false if the key was not in the Map.
func (*Map) Set ¶
func (m *Map) Set(ctx context.Context, store bs.Store, key, payload []byte) (bs.Ref, Outcome, error)
Set sets the payload for a given key in a Map. It returns the Map's possibly-updated Ref and an Outcome: ONone if no change was needed (the key was already present and had the same payload), OUpdated (the key was present with a different payload), or OAdded (the key was not present).
type MapPair ¶
type MapPair struct { Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
func (*MapPair) Descriptor
deprecated
func (*MapPair) GetPayload ¶
func (*MapPair) ProtoMessage ¶
func (*MapPair) ProtoMessage()
func (*MapPair) ProtoReflect ¶
func (x *MapPair) ProtoReflect() protoreflect.Message
type Set ¶
type Set struct { Node *TreeNode `protobuf:"bytes,1,opt,name=node,proto3" json:"node,omitempty"` // Mutually exclusive with node.left and node.right. Members [][]byte `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` // contains filtered or unexported fields }
Set is a set of refs, represented as a tree. The shape of the tree is insensitive to the order of Add and Remove calls.
func SetFromRefs ¶
SetFromRefs creates a Set from a slice of bs.Ref.
func (*Set) Add ¶
Add adds a Ref to a Set. It returns the Set's own possibly-updated Ref, and a boolean indicating whether the Set was changed, which will be false if the input Ref was already present. If the Set is changed, it is written to the Store.
func (*Set) Descriptor
deprecated
func (*Set) GetMembers ¶
func (*Set) ProtoMessage ¶
func (*Set) ProtoMessage()
func (*Set) ProtoReflect ¶
func (x *Set) ProtoReflect() protoreflect.Message
type SubNode ¶
type SubNode struct { Ref []byte `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // contains filtered or unexported fields }
func (*SubNode) Descriptor
deprecated
func (*SubNode) ProtoMessage ¶
func (*SubNode) ProtoMessage()
func (*SubNode) ProtoReflect ¶
func (x *SubNode) ProtoReflect() protoreflect.Message
type TreeNode ¶
type TreeNode struct { Depth int32 `protobuf:"varint,1,opt,name=depth,proto3" json:"depth,omitempty"` Size int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` Left *SubNode `protobuf:"bytes,3,opt,name=left,proto3" json:"left,omitempty"` Right *SubNode `protobuf:"bytes,4,opt,name=right,proto3" json:"right,omitempty"` // contains filtered or unexported fields }
func (*TreeNode) Descriptor
deprecated
func (*TreeNode) ProtoMessage ¶
func (*TreeNode) ProtoMessage()
func (*TreeNode) ProtoReflect ¶
func (x *TreeNode) ProtoReflect() protoreflect.Message