Documentation
¶
Index ¶
- type AbiKeyer
- type AddressKeyer
- type AddressPairKeyer
- type CborLink
- type CborT
- type CidKeyer
- type HamtMap
- type IntKeyer
- type Keyer
- type Map
- func (m *Map[M, K, R, V]) CollectKeys() ([]string, error)
- func (m *Map[M, K, R, V]) Delete(k K) error
- func (m *Map[M, K, R, V]) ForEach(fn func(k K, v V) error) error
- func (m *Map[M, K, R, V]) Get(k K, out cbor.Unmarshaler) (bool, error)
- func (m *Map[M, K, R, V]) GetValue(k K) (V, bool, error)
- func (m *Map[M, K, R, V]) Has(k K) (bool, error)
- func (m *Map[M, K, R, V]) IsEmpty() (bool, error)
- func (m *Map[M, K, R, V]) MarshalCBOR(w io.Writer) error
- func (m *Map[M, K, R, V]) Pop(k K, out cbor.Unmarshaler) (bool, error)
- func (m *Map[M, K, R, V]) Put(k K, v V) error
- func (m *Map[M, K, R, V]) PutIfAbsent(k K, v V) (bool, error)
- func (m *Map[M, K, R, V]) Root() (cid.Cid, error)
- func (m *Map[M, K, R, V]) TryDelete(k K) (bool, error)
- type Store
- type UIntKeyer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AbiKeyer ¶
-------------------------------------------------------------------- AbiKeyer -- pass-through for any built-in `abi.Keyer` type (abi.CidKey, abi.AddrKey, etc.), with a type-switch to parse the string. --------------------------------------------------------------------
type AddressKeyer ¶
type AddressKeyer struct{}
-------------------------------------------------------------------- AddressKeyer uses `abi.AddrKey` for arbitrary addresses --------------------------------------------------------------------
func (AddressKeyer) Keyer ¶
func (AddressKeyer) Keyer(k address.Address) abi.Keyer
func (AddressKeyer) ParseKey ¶
func (AddressKeyer) ParseKey(s string) (address.Address, error)
type AddressPairKeyer ¶
type AddressPairKeyer struct{}
-------------------------------------------------------------------- AddressPairKeyer uses `*abi.AddrPairKey` and round-trips via CBOR --------------------------------------------------------------------
func (AddressPairKeyer) Keyer ¶
func (AddressPairKeyer) Keyer(k *abi.AddrPairKey) abi.Keyer
func (AddressPairKeyer) ParseKey ¶
func (AddressPairKeyer) ParseKey(s string) (*abi.AddrPairKey, error)
ParseKey inverts k.Key() which is done by k.MarshalCBOR(...).
type CborLink ¶
type CborLink[T CborT] struct { // contains filtered or unexported fields }
CborLink holds an optional in-memory value of type T and a cid.Cid link pointing to that value when stored in an IPLD blockstore.
func (*CborLink[T]) Cid ¶
func (cl *CborLink[T]) Cid() cid.Cid
Cid returns the cid for this link (which may be cid.Undef if unset).
func (*CborLink[T]) Load ¶
Load fetches and decodes the linked value from the provided Store, caching it in cl.val. Returns the loaded/cached value. If the link is cid.Undef, returns an error.
func (*CborLink[T]) MarshalCBOR ¶
MarshalCBOR encodes this link the same way a bare CID is encoded in DAG-CBOR/Filecoin:
- A CBOR Tag(42)
- Followed by a CBOR byte-string: [ 0x00, <raw CID bytes> ]
type CidKeyer ¶
type CidKeyer struct{}
-------------------------------------------------------------------- CidKeyer adapts a `cid.Cid` using `abi.CidKey` and can parse the string key via cid.Parse(...) back to `cid.Cid`. --------------------------------------------------------------------
type HamtMap ¶
type HamtMap interface {
// MarshalCBOR serializes the map to CBOR format.
MarshalCBOR(w io.Writer) error
// Root returns the root CID of the underlying HAMT.
Root() (cid.Cid, error)
// Put adds a value `v` with key `k` to the map.
Put(k abi.Keyer, v cbor.Marshaler) error
// Get retrieves the value at `k` into `out`.
Get(k abi.Keyer, out cbor.Unmarshaler) (bool, error)
// Has checks whether the key exists in the map.
Has(k abi.Keyer) (bool, error)
// PutIfAbsent sets key `k` to value `v` if it is not already present.
PutIfAbsent(k abi.Keyer, v cbor.Marshaler) (bool, error)
// TryDelete removes the value at `k`, returning whether it was present.
TryDelete(k abi.Keyer) (bool, error)
// Delete removes the value at `k`, expecting it to exist.
Delete(k abi.Keyer) error
// ForEach iterates over all key-value pairs in the map.
ForEach(out cbor.Unmarshaler, fn func(key string) error) error
// CollectKeys returns all keys in the map as a slice.
CollectKeys() ([]string, error)
// Pop retrieves and removes the entry for `k`.
Pop(k abi.Keyer, out cbor.Unmarshaler) (bool, error)
// IsEmpty checks whether the map contains any elements.
IsEmpty() (bool, error)
}
type IntKeyer ¶
type IntKeyer struct{}
-------------------------------------------------------------------- IntKeyer adapts int64 using `abi.IntKey` --------------------------------------------------------------------
type Keyer ¶
Keyer maps a user-level key type `K` to a `abi.Keyer`, and also provides ParseKey to invert the string key back to `K`.
type Map ¶
func (*Map[M, K, R, V]) CollectKeys ¶
func (*Map[M, K, R, V]) ForEach ¶
ForEach iterates over all string keys in the map, parses them into `K`, fetches the corresponding `V`, and calls `fn(k, v)`.
func (*Map[M, K, R, V]) Get ¶
func (m *Map[M, K, R, V]) Get(k K, out cbor.Unmarshaler) (bool, error)
func (*Map[M, K, R, V]) GetValue ¶
GetValue is a typed convenience method that returns (value, found, error).
func (*Map[M, K, R, V]) Pop ¶
func (m *Map[M, K, R, V]) Pop(k K, out cbor.Unmarshaler) (bool, error)