cidlink

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 12 Imported by: 386

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLinkSystem added in v0.9.0

func DefaultLinkSystem() linking.LinkSystem

DefaultLinkSystem returns a linking.LinkSystem which uses cidlink.Link for datamodel.Link. During selection of encoders, decoders, and hashers, it examines the multicodec indicator numbers and multihash indicator numbers from the CID, and uses the default global multicodec registry (see the go-ipld-prime/multicodec package) for resolving codec implementations, and the default global multihash registry (see the go-multihash/core package) for resolving multihash implementations.

No storage functions are present in the returned LinkSystem. The caller can assign those themselves as desired.

func LinkSystemUsingMulticodecRegistry added in v0.10.0

func LinkSystemUsingMulticodecRegistry(mcReg multicodec.Registry) linking.LinkSystem

LinkSystemUsingMulticodecRegistry is similar to DefaultLinkSystem, but accepts a multicodec.Registry as a parameter.

This can help create a LinkSystem which uses different multicodec implementations than the global registry. (Sometimes this can be desired if you want some parts of a program to support a more limited suite of codecs than other parts of the program, or needed to use a different multicodec registry than the global one for synchronization purposes, or etc.)

Types

type Link struct {
	cid.Cid
}

Link implements the datamodel.Link interface using a CID. See https://github.com/ipfs/go-cid for more information about CIDs.

When using this value, typically you'll use it as `Link`, and not `*Link`. This includes when handling the value as an `datamodel.Link` interface -- the non-pointer form is typically preferable. This is because the datamodel.Link inteface is often desirable to be able to use as a golang map key, and in that context, pointers would not result in the desired behavior.

func (Link) Binary added in v0.14.0

func (lnk Link) Binary() string

func (Link) Prototype added in v0.9.0

func (lnk Link) Prototype() datamodel.LinkPrototype

func (Link) String

func (lnk Link) String() string

type LinkPrototype added in v0.9.0

type LinkPrototype struct {
	cid.Prefix
}
func (lp LinkPrototype) BuildLink(hashsum []byte) datamodel.Link

type Memory added in v0.14.0

type Memory struct {
	Bag map[string][]byte
}

Memory is a simple in-memory storage for cidlinks. It's the same as `storage.Memory` but uses typical multihash semantics used when reading/writing cidlinks.

Using multihash as the storage key rather than the whole CID will remove the distinction between CIDv0 and their CIDv1 counterpart. It also removes the distinction between CIDs where the multihash is the same but the codec is different, e.g. `dag-cbor` and a `raw` version of the same data.

func (*Memory) OpenRead added in v0.14.0

func (store *Memory) OpenRead(lnkCtx linking.LinkContext, lnk datamodel.Link) (io.Reader, error)

func (*Memory) OpenWrite added in v0.14.0

func (store *Memory) OpenWrite(lnkCtx linking.LinkContext) (io.Writer, linking.BlockWriteCommitter, error)

Jump to

Keyboard shortcuts

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