schema

package
v0.0.0-...-c9fddc1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatDataSize  = "size" // size of all raw blobs (excluding the schema)
	StatDataCount = "cnt"  // number of full objects (logical trees)
)
View Source
const (
	// MagicSize is a maximal size of a magic prefix of schema blobs.
	MagicSize = len(magic)
)

Variables

View Source
var ErrNotSchema = errors.New("not a schema file")

Functions

func DecodeType

func DecodeType(r io.Reader) (string, error)

DecodeType decodes the type of an object from the reader. Reader will not be usable after the call. See PeekType to reserve a reader in a usable state.

func Encode

func Encode(w io.Writer, o Object) error

Encode writes a schema blob to w.

func IsSchema

func IsSchema(p []byte) bool

IsSchema checks if the buffer is likely to contain an object with a CAS schema. The buffer should be at least of MagicSize.

func MustTypeOf

func MustTypeOf(o Object) string

MustTypeOf is the same as TypeOf but panics on error.

func PeekType

func PeekType(r io.Reader) (io.Reader, string, error)

PeekType reads a portion of data from r, reports the type of the schema blob that it describes, and returns a new restored reader.

func RegisterName

func RegisterName(name string, o Object)

RegisterName associates a schema object with a given type name.

func TypeOf

func TypeOf(o Object) (string, error)

TypeOf returns the type of an object.

Types

type BlobWrapper

type BlobWrapper interface {
	DataBlob() types.Ref
}

type Compressed

type Compressed struct {
	Algo string         `json:"algo"`
	Arch types.SizedRef `json:"arch"`
	Ref  types.SizedRef `json:"ref"`
}

func (*Compressed) References

func (c *Compressed) References() []types.Ref

type DirEntry

type DirEntry struct {
	Ref   types.Ref `json:"ref"`
	Name  string    `json:"name"`
	Stats Stats     `json:"stats"`
}

func (*DirEntry) References

func (d *DirEntry) References() []types.Ref

func (*DirEntry) Size

func (d *DirEntry) Size() uint64

type InlineList

type InlineList struct {
	Ref   *types.Ref `json:"ref,omitempty"`   // ref of concatenated content, if applicable
	Elem  string     `json:"elem,omitempty"`  // type of elements in List
	List  []Object   `json:"list,omitempty"`  // Elem
	Stats Stats      `json:"stats,omitempty"` // optional stats
}

InlineList is an inlined list of entries of a specific type.

func (*InlineList) References

func (l *InlineList) References() []types.Ref

func (*InlineList) UnmarshalJSON

func (l *InlineList) UnmarshalJSON(p []byte) error

type List

type List struct {
	Ref   *types.Ref  `json:"ref,omitempty"`   // ref of concatenated content, if applicable
	Elem  string      `json:"elem,omitempty"`  // type of elements in List
	List  []types.Ref `json:"list,omitempty"`  // List<Elem> or InlineList<Elem>
	Stats Stats       `json:"stats,omitempty"` // optional stats
}

List is an ordered list of entries of a specific type.

func (*List) References

func (l *List) References() []types.Ref

type Multipart

type Multipart struct {
	Ref   types.Ref        `json:"ref,omitempty"`
	Parts []types.SizedRef `json:"parts"`
}

func (*Multipart) References

func (m *Multipart) References() []types.Ref

type Object

type Object interface {
	References() []types.Ref
}

Object is a generic schema object for CAS.

func Decode

func Decode(r io.Reader) (Object, error)

Decode decodes a schema object from a stream. It will strictly validate formatting of the content.

func DecodeJSON

func DecodeJSON(r io.Reader) (Object, error)

DecodeJSON decodes a JSON config. It will not validate JSON formatting as Decode does.

func NewType

func NewType(typ string) (Object, error)

NewType creates a schema object with a specified type. The type should be registered with RegisterName.

type Stats

type Stats map[string]uint64

Stats is a collection of stat values.

func (Stats) Size

func (s Stats) Size() uint64

type TransformOp

type TransformOp struct {
	Src types.Ref `json:"src"`
	Op  types.Ref `json:"op"`
	Dst types.Ref `json:"dst"`
}

func (*TransformOp) References

func (t *TransformOp) References() []types.Ref

type WebContent

type WebContent struct {
	URL  string     `json:"url"`
	Ref  types.Ref  `json:"ref"`
	Size uint64     `json:"size,omitempty"`
	ETag string     `json:"etag,omitempty"`
	TS   *time.Time `json:"ts,omitempty"`
}

func (*WebContent) DataBlob

func (c *WebContent) DataBlob() types.Ref

func (*WebContent) References

func (c *WebContent) References() []types.Ref

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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