datamodel

package
v0.0.0-...-8bebe15 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any struct {
	Value any
}

Any is a CBOR backed implementation of the IPLD data model. Any supports serializing/deserializing the following kinds/types:

  • Null (nil)
  • Boolean (bool)
  • Integer (int64, int)
  • String (string)
  • Bytes ([]byte)
  • List ([]Any)
  • Map (Map)
  • Link (cid.Cid)

Map values and list items may be any of the above types.

func NewAny

func NewAny(data ipld.Any) *Any

NewAny creates an CBOR backed IPLD data model type from the passed data. The following Go types are supported:

  • nil
  • bool
  • int
  • int64
  • string
  • []byte
  • slice
  • Map
  • cid.Cid

Using a value other than the above types will result in an error when the value is serialized to CBOR.

func (*Any) MarshalCBOR

func (a *Any) MarshalCBOR(w io.Writer) error

func (*Any) MarshalDagJSON

func (a *Any) MarshalDagJSON(w io.Writer) error

func (*Any) UnmarshalCBOR

func (a *Any) UnmarshalCBOR(r io.Reader) (err error)

func (*Any) UnmarshalDagJSON

func (a *Any) UnmarshalDagJSON(r io.Reader) (err error)

type Map

type Map map[string]ipld.Any

Map is a CBOR backed implementation of ipld.Map. Keys are strings and values may be any of the types supported by ipld.Any.

func (Map) MarshalCBOR

func (mp Map) MarshalCBOR(w io.Writer) error

func (Map) MarshalDagJSON

func (mp Map) MarshalDagJSON(w io.Writer) error

func (*Map) UnmarshalCBOR

func (mp *Map) UnmarshalCBOR(r io.Reader) (err error)

func (*Map) UnmarshalDagJSON

func (mp *Map) UnmarshalDagJSON(r io.Reader) error

type Raw

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

Raw is a CBOR-canonical opaque value backed by raw CBOR bytes.

On the CBOR side it is a pure byte-passthrough (delegates to cbg.Deferred semantics) — decoded bytes are stored verbatim and re-emitted verbatim. This makes Raw suitable for envelope fields whose schema is determined at runtime by another field (e.g. UCAN args/meta determined by cmd) and removes the need to re-encode-then-re-decode in order to bind to a typed Go struct.

On the dag-json side, Raw decodes the underlying CBOR via the Any machinery and emits dag-json (and inversely on Unmarshal). The dag-json path is for debug/inspection only — UCAN signing happens on CBOR bytes.

func NewRaw

func NewRaw(cborBytes []byte) Raw

NewRaw constructs a Raw from already-encoded CBOR bytes. The caller is responsible for ensuring the bytes are valid CBOR.

func (*Raw) Bytes

func (r *Raw) Bytes() []byte

Bytes returns the raw CBOR bytes. Typed callers should pass these to their own UnmarshalCBOR to bind directly into their schema.

func (*Raw) MarshalCBOR

func (r *Raw) MarshalCBOR(w io.Writer) error

func (*Raw) MarshalDagJSON

func (r *Raw) MarshalDagJSON(w io.Writer) error

func (*Raw) UnmarshalCBOR

func (r *Raw) UnmarshalCBOR(rd io.Reader) error

func (*Raw) UnmarshalDagJSON

func (r *Raw) UnmarshalDagJSON(rd io.Reader) error

Jump to

Keyboard shortcuts

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