ipldmulti

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 9 Imported by: 0

README

Multiverse IPLD Codec

Go Report Card

About

IPLD codec for Multiverse objects.

License

MIT

Documentation

Index

Constants

View Source
const (
	// RepositoryCodec is the multicodec value for repositories.
	RepositoryCodec = 0x300000
	// CommitCodec is the multicodec value for repositories.
	CommitCodec = 0x300001
)

Variables

View Source
var (
	// ErrNoLink is returned when an invalid path is resolved.
	ErrNoLink = errors.New("no such link")
	// ErrZeroLenPath is returned when a path of len zero is resolved.
	ErrZeroLenPath = errors.New("zero length path")
)

Functions

func DecodeCommit

func DecodeCommit(block blocks.Block) (format.Node, error)

DecodeCommit is a block decoder for raw IPLD nodes.

func DecodeRepository

func DecodeRepository(block blocks.Block) (format.Node, error)

DecodeRepository is a block decoder for raw IPLD nodes.

Types

type Commit

type Commit struct {
	// Date is the timestamp of when the commit was created.
	Date time.Time `json:"date"`
	// Message is a description of the changes.
	Message string `json:"message"`
	// WorkTree is the current state of the repo files.
	WorkTree cid.Cid `json:"tree"`
	// Parents contains the CIDs of parent commits.
	Parents Parents `json:"parents"`
}

Commit contains info about changes to a repo.

func (*Commit) Cid

func (c *Commit) Cid() cid.Cid

Cid returns the cid of the commit.

func (*Commit) Copy

func (c *Commit) Copy() format.Node

Copy will go away. It is here to comply with the Node interface.

func (c *Commit) Links() []*format.Link

Links is a helper function that returns all links within this object

func (*Commit) Loggable

func (c *Commit) Loggable() map[string]interface{}

Loggable returns a go-log loggable item.

func (*Commit) RawData

func (c *Commit) RawData() []byte

RawData returns the block raw contents as a byte slice.

func (*Commit) Resolve

func (c *Commit) Resolve(path []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (c *Commit) ResolveLink(path []string) (*format.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*Commit) Size

func (c *Commit) Size() (uint64, error)

Size returns the size in bytes of the serialized object

func (*Commit) Stat

func (c *Commit) Stat() (*format.NodeStat, error)

Stat returns info about the node.

func (*Commit) String

func (c *Commit) String() string

String returns a string representation of the commit.

func (*Commit) Tree

func (c *Commit) Tree(path string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type Parents

type Parents []cid.Cid

Parents contains parent commit CIDs.

func (Parents) Resolve

func (p Parents) Resolve(path []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (Parents) Tree

func (p Parents) Tree(path string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type References

type References map[string]cid.Cid

References is a mapping of names to commit CIDs.

func (References) Resolve

func (r References) Resolve(path []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (References) Tree

func (r References) Tree(path string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

type Repository

type Repository struct {
	// Branches contains references to versions.
	Branches References `json:"branches"`
	// Tags contains references to versions.
	Tags References `json:"tags"`
}

Repository contains references to branches and tags.

func (*Repository) Cid

func (r *Repository) Cid() cid.Cid

Cid returns the cid of the commit.

func (*Repository) Copy

func (r *Repository) Copy() format.Node

Copy will go away. It is here to comply with the Node interface.

func (r *Repository) Links() []*format.Link

Links is a helper function that returns all links within this object

func (*Repository) Loggable

func (r *Repository) Loggable() map[string]interface{}

Loggable returns a go-log loggable item.

func (*Repository) RawData

func (r *Repository) RawData() []byte

RawData returns the block raw contents as a byte slice.

func (*Repository) Resolve

func (r *Repository) Resolve(path []string) (interface{}, []string, error)

Resolve resolves a path through this node, stopping at any link boundary and returning the object found as well as the remaining path to traverse

func (r *Repository) ResolveLink(path []string) (*format.Link, []string, error)

ResolveLink is a helper function that calls resolve and asserts the output is a link

func (*Repository) Size

func (r *Repository) Size() (uint64, error)

Size returns the size in bytes of the serialized object

func (*Repository) Stat

func (r *Repository) Stat() (*format.NodeStat, error)

Stat returns info about the node.

func (*Repository) String

func (r *Repository) String() string

String returns a string representation of the commit.

func (*Repository) Tree

func (r *Repository) Tree(path string, depth int) []string

Tree lists all paths within the object under 'path', and up to the given depth. To list the entire object (similar to `find .`) pass "" and -1

Jump to

Keyboard shortcuts

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