util

package
v0.0.0-...-12d29e9 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 54

Documentation

Index

Constants

View Source
const (
	// TODO: this is an arbitrary size. lexicons can set more realistic limits,
	// and we should pass those limits through and only fall back to this when
	// undefined.
	MAX_BYTE_ARRAY_SIZE = 128 * 1024 * 1024
)

Variables

View Source
var ErrUnrecognizedType = fmt.Errorf("unrecognized lexicon type")

Functions

func CborTypeExtract

func CborTypeExtract(b []byte) (string, error)

func CborTypeExtractReader

func CborTypeExtractReader(r io.Reader) (string, []byte, error)

func JsonDecodeValue

func JsonDecodeValue(b []byte) (any, error)

func NewFromType

func NewFromType(typ string) (interface{}, error)

func RegisterType

func RegisterType(id string, val cbg.CBORMarshaler)

func TypeExtract

func TypeExtract(b []byte) (string, error)

Types

type BlobSchema

type BlobSchema struct {
	LexiconTypeID string  `json:"$type,const=blob" cborgen:"$type,const=blob"`
	Ref           LexLink `json:"ref" cborgen:"ref"`
	MimeType      string  `json:"mimeType" cborgen:"mimeType"`
	Size          int64   `json:"size" cborgen:"size"`
}

func (*BlobSchema) MarshalCBOR

func (t *BlobSchema) MarshalCBOR(w io.Writer) error

func (*BlobSchema) UnmarshalCBOR

func (t *BlobSchema) UnmarshalCBOR(r io.Reader) (err error)

type CBOR

type CBOR interface {
	cbg.CBORUnmarshaler
	cbg.CBORMarshaler
}

func CborDecodeValue

func CborDecodeValue(b []byte) (CBOR, error)

type CborChecker

type CborChecker struct {
	Type string `json:"$type" cborgen:"$type"`
}

func (*CborChecker) MarshalCBOR

func (t *CborChecker) MarshalCBOR(w io.Writer) error

func (*CborChecker) UnmarshalCBOR

func (t *CborChecker) UnmarshalCBOR(r io.Reader) (err error)

type JsonBytes

type JsonBytes struct {
	Bytes string `json:"$bytes"`
}

type LegacyBlob

type LegacyBlob struct {
	Cid      string `json:"cid" cborgen:"cid"`
	MimeType string `json:"mimeType" cborgen:"mimeType"`
}

func (*LegacyBlob) MarshalCBOR

func (t *LegacyBlob) MarshalCBOR(w io.Writer) error

func (*LegacyBlob) UnmarshalCBOR

func (t *LegacyBlob) UnmarshalCBOR(r io.Reader) (err error)

type LexBlob

type LexBlob struct {
	Ref      LexLink
	MimeType string
	Size     int64
}

used in schemas, and can represent either a legacy blob or a "new" (lex refactor) blob. size=-1 indicates that this is (and should be serialized as) a legacy blob (string CID, no size, etc).

func (*LexBlob) MarshalCBOR

func (b *LexBlob) MarshalCBOR(w io.Writer) error

func (LexBlob) MarshalJSON

func (b LexBlob) MarshalJSON() ([]byte, error)

func (*LexBlob) UnmarshalCBOR

func (lb *LexBlob) UnmarshalCBOR(r io.Reader) error

func (*LexBlob) UnmarshalJSON

func (b *LexBlob) UnmarshalJSON(raw []byte) error

type LexBytes

type LexBytes []byte

func (*LexBytes) MarshalCBOR

func (lb *LexBytes) MarshalCBOR(w io.Writer) error

func (LexBytes) MarshalJSON

func (lb LexBytes) MarshalJSON() ([]byte, error)

func (*LexBytes) UnmarshalCBOR

func (lb *LexBytes) UnmarshalCBOR(r io.Reader) error

func (*LexBytes) UnmarshalJSON

func (lb *LexBytes) UnmarshalJSON(raw []byte) error
type LexLink cid.Cid

func (LexLink) Defined

func (ll LexLink) Defined() bool

convenience helper

func (*LexLink) MarshalCBOR

func (ll *LexLink) MarshalCBOR(w io.Writer) error

func (LexLink) MarshalJSON

func (ll LexLink) MarshalJSON() ([]byte, error)

func (LexLink) String

func (ll LexLink) String() string

convenience helper

func (*LexLink) UnmarshalCBOR

func (ll *LexLink) UnmarshalCBOR(r io.Reader) error

func (*LexLink) UnmarshalJSON

func (ll *LexLink) UnmarshalJSON(raw []byte) error

type LexiconTypeDecoder

type LexiconTypeDecoder struct {
	Val cbg.CBORMarshaler
}

func (*LexiconTypeDecoder) MarshalJSON

func (ltd *LexiconTypeDecoder) MarshalJSON() ([]byte, error)

func (*LexiconTypeDecoder) UnmarshalJSON

func (ltd *LexiconTypeDecoder) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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