dirserv

package
v0.0.0-...-817062f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NullOID = 0
	RootOID = math.MaxUint64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DirServer

type DirServer struct {
	// contains filtered or unexported fields
}

func New

func New(db bcdb.DB) *DirServer

func (*DirServer) Create

func (s *DirServer) Create(ctx context.Context, x Handle, name string, data []byte) (*Handle, error)

Create a node in the directory tree, with optionally associated data. Associating data with a node prevents creating children beneath it.

func (*DirServer) Ensure

func (s *DirServer) Ensure(ctx context.Context, x Handle, p Path, data []byte) (OID, error)

Ensure is a Create falling back to Resolve if the object already exists.

func (*DirServer) Get

func (s *DirServer) Get(ctx context.Context, x Handle, p Path) (OID, []byte, error)

Get returns the data associated with an object id

func (*DirServer) List

func (s *DirServer) List(ctx context.Context, x Handle) ([]Entry, error)

List returns the children in the directory referenced by x.

func (*DirServer) Open

func (s *DirServer) Open(ctx context.Context, x Handle, p Path) (*Handle, error)

Open returns a handle to the object at path under x

func (*DirServer) Remove

func (s *DirServer) Remove(ctx context.Context, h Handle, name string) (OID, error)

Remove removes an entry from a directory, and returns the ID of the deleted object.

func (*DirServer) Resolve

func (s *DirServer) Resolve(ctx context.Context, x Handle, p Path) (OID, error)

Resolve resolves a path to Handle and returns an OID

func (*DirServer) Root

func (s *DirServer) Root() Handle

Root returns a handle to the root directory.

type Entry

type Entry struct {
	Name string
	ID   OID
}

type Handle

type Handle struct {
	ID     OID      `json:"id"`
	Secret [16]byte `json:"secret"`
}

func ParseHandle

func ParseHandle(x []byte) (*Handle, error)

func (Handle) MarshalText

func (h Handle) MarshalText() (ret []byte, _ error)

func (Handle) String

func (h Handle) String() string

func (*Handle) UnmarshalText

func (h *Handle) UnmarshalText(data []byte) error

type OID

type OID uint64

OID is an Object ID

func (OID) String

func (id OID) String() string

type Path

type Path []string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL