Documentation
¶
Index ¶
- Variables
- type Iterator
- type Meta
- func (m *Meta) Add(key string, val any) error
- func (m *Meta) AddEncrypted(key string, val any, encryptionKey []byte) error
- func (m *Meta) Clone() *Meta
- func (m *Meta) Equals(other *Meta) bool
- func (m *Meta) GetBool(key string) (bool, error)
- func (m *Meta) GetBytes(key string) ([]byte, error)
- func (m *Meta) GetEncryptedBytes(key string, encryptionKey []byte) ([]byte, error)
- func (m *Meta) GetEncryptedString(key string, encryptionKey []byte) (string, error)
- func (m *Meta) GetFloat64(key string) (float64, error)
- func (m *Meta) GetInt64(key string) (int64, error)
- func (m *Meta) GetNode(key string) (ipld.Node, error)
- func (m *Meta) GetString(key string) (string, error)
- func (m *Meta) Include(other Iterator)
- func (m *Meta) Iter() iter.Seq2[string, ipld.Node]
- func (m *Meta) Len() int
- func (m *Meta) ReadOnly() ReadOnly
- func (m *Meta) String() string
- type ReadOnly
- func (r ReadOnly) Equals(other ReadOnly) bool
- func (r ReadOnly) GetBool(key string) (bool, error)
- func (r ReadOnly) GetBytes(key string) ([]byte, error)
- func (r ReadOnly) GetEncryptedBytes(key string, encryptionKey []byte) ([]byte, error)
- func (r ReadOnly) GetEncryptedString(key string, encryptionKey []byte) (string, error)
- func (r ReadOnly) GetFloat64(key string) (float64, error)
- func (r ReadOnly) GetInt64(key string) (int64, error)
- func (r ReadOnly) GetNode(key string) (ipld.Node, error)
- func (r ReadOnly) GetString(key string) (string, error)
- func (r ReadOnly) Iter() iter.Seq2[string, ipld.Node]
- func (r ReadOnly) Len() int
- func (r ReadOnly) String() string
- func (r ReadOnly) WriteableClone() *Meta
Constants ¶
This section is empty.
Variables ¶
var ErrNotEncryptable = errors.New("value of this type cannot be encrypted")
var ErrNotFound = errors.New("key not found in meta")
Functions ¶
This section is empty.
Types ¶
type Meta ¶
Meta is a container for meta key-value pairs in a UCAN token. This also serves as a way to construct the underlying IPLD data with minimum allocations and transformations, while hiding the IPLD complexity from the caller.
func (*Meta) Add ¶
Add adds a key/value pair in the meta set. Accepted types for val are any CBOR compatible type, or directly IPLD values.
func (*Meta) AddEncrypted ¶
AddEncrypted adds a key/value pair in the meta set. The value is encrypted with the given encryptionKey. Accepted types for the value are: string, []byte. The ciphertext will be 40 bytes larger than the plaintext due to encryption overhead.
func (*Meta) GetBool ¶
GetBool retrieves a value as a bool. Returns ErrNotFound if the given key is missing. Returns datamodel.ErrWrongKind if the value has the wrong type.
func (*Meta) GetBytes ¶
GetBytes retrieves a value as a []byte. Returns ErrNotFound if the given key is missing. Returns datamodel.ErrWrongKind if the value has the wrong type.
func (*Meta) GetEncryptedBytes ¶
GetEncryptedBytes decorates GetBytes and decrypt its output with the given symmetric encryption key.
func (*Meta) GetEncryptedString ¶
GetEncryptedString decorates GetString and decrypt its output with the given symmetric encryption key.
func (*Meta) GetFloat64 ¶
GetFloat64 retrieves a value as a float64. Returns ErrNotFound if the given key is missing. Returns datamodel.ErrWrongKind if the value has the wrong type.
func (*Meta) GetInt64 ¶
GetInt64 retrieves a value as an int64. Returns ErrNotFound if the given key is missing. Returns datamodel.ErrWrongKind if the value has the wrong type.
func (*Meta) GetNode ¶
GetNode retrieves a value as a raw IPLD node. Returns ErrNotFound if the given key is missing.
func (*Meta) GetString ¶
GetString retrieves a value as a string. Returns ErrNotFound if the given key is missing. Returns datamodel.ErrWrongKind if the value has the wrong type.
func (*Meta) Include ¶
Include merges the provided meta into the existing one.
If duplicate keys are encountered, the new value is silently dropped without causing an error.
type ReadOnly ¶
type ReadOnly struct {
// contains filtered or unexported fields
}
ReadOnly wraps a Meta into a read-only facade.