Documentation ¶
Index ¶
- Variables
- type AssemblerFunc
- type HAMTBuilder
- type HAMTContainer
- func (hc *HAMTContainer) CID() (cid.Cid, error)
- func (hc *HAMTContainer) Get(key []byte) (interface{}, error)
- func (hc *HAMTContainer) GetAsBytes(key []byte) ([]byte, error)
- func (hc *HAMTContainer) GetAsLink(key []byte) (ipld.Link, error)
- func (hc *HAMTContainer) GetAsString(key []byte) (string, error)
- func (hc *HAMTContainer) GetLink() (ipld.Link, error)
- func (hc *HAMTContainer) Key() []byte
- func (hc *HAMTContainer) LoadLink(link ipld.Link) error
- func (hc *HAMTContainer) MustBuild(assemblyFuncs ...AssemblerFunc) error
- func (hc *HAMTContainer) Set(key []byte, value interface{})
- func (hc *HAMTContainer) Storage() storage.Storage
- func (hc *HAMTContainer) View(iterFunc func(key []byte, value interface{}) error) error
- func (hc *HAMTContainer) WriteCar(writer io.Writer) error
- type HAMTSetter
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrHAMTNotBuild = errors.New("HAMT not ready, build first") ErrHAMTValueNotFound = errors.New("Value not found at HAMT") ErrHAMTNoNestedFound = errors.New("No nested found with the given key") ErrHAMTFailedToLoadNested = errors.New("Failed to load link from nested HAMT") ErrHAMTUnsupportedValueType = errors.New("Unsupported value") ErrHAMTUnsupportedCacheValueType = errors.New("Unsupported cache value") ErrHAMTFailedToGetAsLink = errors.New("Value returned should be ipld.Link") ErrHAMTFailedToGetAsBytes = errors.New("Value returned should be Bytes") ErrHAMTFailedToGetAsString = errors.New("Value returned should be String") BitWidth = 8 BucketSize = 1024 )
var ErrCantUseParentAndLink = errors.New("Cannot use Parant and Link in the same build")
var ErrCantUseStorageAndNested = errors.New("Cannot use Storage and FromNested in the same build")
Functions ¶
This section is empty.
Types ¶
type AssemblerFunc ¶
type AssemblerFunc func(hamtSetter HAMTSetter) error
AssemblerFunc function used to set assembler routines
type HAMTBuilder ¶
type HAMTBuilder struct {
// contains filtered or unexported fields
}
func NewHAMTBuilder ¶
func NewHAMTBuilder(options ...Option) *HAMTBuilder
NewHAMTBuilder create a new HAMTBuilder helper
func (HAMTBuilder) Build ¶
func (hb HAMTBuilder) Build() (*HAMTContainer, error)
Build creates the HAMT Container based on the params from HAMTBuilder
type HAMTContainer ¶
type HAMTContainer struct {
// contains filtered or unexported fields
}
func (*HAMTContainer) CID ¶
func (hc *HAMTContainer) CID() (cid.Cid, error)
CID will return the cid.Cid for the ipld.Node Or it will return an error if the ipld.Node for the HAMT isn't built
func (*HAMTContainer) Get ¶
func (hc *HAMTContainer) Get(key []byte) (interface{}, error)
Get will return the value by the key It will return error if the hamt not build or if the value not found
func (*HAMTContainer) GetAsBytes ¶
func (hc *HAMTContainer) GetAsBytes(key []byte) ([]byte, error)
GetAsBytes returns a byte slice type by key The method will fail if the returned type isn't of type byte slice
func (*HAMTContainer) GetAsLink ¶
func (hc *HAMTContainer) GetAsLink(key []byte) (ipld.Link, error)
GetAsLink returns a ipld.Link type by key The method will fail if the returned type isn't of type ipld.Link
func (*HAMTContainer) GetAsString ¶
func (hc *HAMTContainer) GetAsString(key []byte) (string, error)
GetAsString returns a string type by key The method will fail if the returned type isn't of type string or failed to convert to string
func (*HAMTContainer) GetLink ¶
func (hc *HAMTContainer) GetLink() (ipld.Link, error)
GetLink will return the ipld.Link for the ipld.Node Or it will return an error if the ipld.Node for the HAMT isn't built
func (*HAMTContainer) Key ¶
func (hc *HAMTContainer) Key() []byte
Key returns the key that identifies the HAMT
func (*HAMTContainer) LoadLink ¶
func (hc *HAMTContainer) LoadLink(link ipld.Link) error
LoadLink will load the storage data from a new HAMTContainer Or it illl return and error if the load failed
func (*HAMTContainer) MustBuild ¶
func (hc *HAMTContainer) MustBuild(assemblyFuncs ...AssemblerFunc) error
MustBuild is used to build the key maps It'll generate the final version of the node with the link
func (*HAMTContainer) Set ¶
func (hc *HAMTContainer) Set(key []byte, value interface{})
Set adds k/v to the hamt but not imediately and only when build
func (*HAMTContainer) Storage ¶
func (hc *HAMTContainer) Storage() storage.Storage
Storage returns the linking storage used by the HAMT
type HAMTSetter ¶
type HAMTSetter struct {
// contains filtered or unexported fields
}
HAMTSetter is a helper structure for set HAMT key values
func (*HAMTSetter) Set ¶
func (hs *HAMTSetter) Set(key []byte, value interface{}) error
Set adds a new k/v content for the HAMT For string values it will add k/v pair of strings For ipld.Link values it will add string key and a link for another HAMT structure as value
type Option ¶
type Option func(*HAMTBuilder)
func WithHAMTContainer ¶
func WithHAMTContainer(hamtContainer *HAMTContainer) Option
WithHAMTContainer sets the parent container to load from the future HAMTContainer
func WithStorage ¶
WithStorage sets the storage for the future HAMTContainer