kubo/core/coreiface/object.go
Jorropo 8c2ae9cf22 feat: Über Migration (and Boxo rename)
Include rename from:
  github.com/ipfs/go-libipfs => github.com/ipfs/boxo

This migration was reverted:
  ./blocks => github.com/ipfs/go-block-format

Migrated repos:
- github.com/ipfs/interface-go-ipfs-core         => ./coreiface
- github.com/ipfs/go-pinning-service-http-client => ./pinning/remote/client
- github.com/ipfs/go-path                        => ./path
- github.com/ipfs/go-namesys                     => ./namesys
- github.com/ipfs/go-mfs                         => ./mfs
- github.com/ipfs/go-ipfs-provider               => ./provider
- github.com/ipfs/go-ipfs-pinner                 => ./pinning/pinner
- github.com/ipfs/go-ipfs-keystore               => ./keystore
- github.com/ipfs/go-filestore                   => ./filestore
- github.com/ipfs/go-ipns                        => ./ipns
- github.com/ipfs/go-blockservice                => ./blockservice
- github.com/ipfs/go-ipfs-chunker                => ./chunker
- github.com/ipfs/go-fetcher                     => ./fetcher
- github.com/ipfs/go-ipfs-blockstore             => ./blockstore
- github.com/ipfs/go-ipfs-posinfo                => ./filestore/posinfo
- github.com/ipfs/go-ipfs-util                   => ./util
- github.com/ipfs/go-ipfs-ds-help                => ./datastore/dshelp
- github.com/ipfs/go-verifcid                    => ./verifcid
- github.com/ipfs/go-ipfs-exchange-offline       => ./exchange/offline
- github.com/ipfs/go-ipfs-routing                => ./routing
- github.com/ipfs/go-ipfs-exchange-interface     => ./exchange
- github.com/ipfs/go-unixfs                      => ./ipld/unixfs
- github.com/ipfs/go-merkledag                   => ./ipld/merkledag
- github.com/ipld/go-car                         => ./ipld/car

Fixes #215
Updates #202


This commit was moved from ipfs/boxo@038bdd291d
2023-03-27 19:29:40 +02:00

109 lines
3.0 KiB
Go

package iface
import (
"context"
"io"
path "github.com/ipfs/boxo/coreiface/path"
"github.com/ipfs/boxo/coreiface/options"
"github.com/ipfs/go-cid"
ipld "github.com/ipfs/go-ipld-format"
)
// ObjectStat provides information about dag nodes
type ObjectStat struct {
// Cid is the CID of the node
Cid cid.Cid
// NumLinks is number of links the node contains
NumLinks int
// BlockSize is size of the raw serialized node
BlockSize int
// LinksSize is size of the links block section
LinksSize int
// DataSize is the size of data block section
DataSize int
// CumulativeSize is size of the tree (BlockSize + link sizes)
CumulativeSize int
}
// ChangeType denotes type of change in ObjectChange
type ChangeType int
const (
// DiffAdd is set when a link was added to the graph
DiffAdd ChangeType = iota
// DiffRemove is set when a link was removed from the graph
DiffRemove
// DiffMod is set when a link was changed in the graph
DiffMod
)
// ObjectChange represents a change ia a graph
type ObjectChange struct {
// Type of the change, either:
// * DiffAdd - Added a link
// * DiffRemove - Removed a link
// * DiffMod - Modified a link
Type ChangeType
// Path to the changed link
Path string
// Before holds the link path before the change. Note that when a link is
// added, this will be nil.
Before path.Resolved
// After holds the link path after the change. Note that when a link is
// removed, this will be nil.
After path.Resolved
}
// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
// for manipulating MerkleDAG data structures.
type ObjectAPI interface {
// New creates new, empty (by default) dag-node.
New(context.Context, ...options.ObjectNewOption) (ipld.Node, error)
// Put imports the data into merkledag
Put(context.Context, io.Reader, ...options.ObjectPutOption) (path.Resolved, error)
// Get returns the node for the path
Get(context.Context, path.Path) (ipld.Node, error)
// Data returns reader for data of the node
Data(context.Context, path.Path) (io.Reader, error)
// Links returns lint or links the node contains
Links(context.Context, path.Path) ([]*ipld.Link, error)
// Stat returns information about the node
Stat(context.Context, path.Path) (*ObjectStat, error)
// AddLink adds a link under the specified path. child path can point to a
// subdirectory within the patent which must be present (can be overridden
// with WithCreate option).
AddLink(ctx context.Context, base path.Path, name string, child path.Path, opts ...options.ObjectAddLinkOption) (path.Resolved, error)
// RmLink removes a link from the node
RmLink(ctx context.Context, base path.Path, link string) (path.Resolved, error)
// AppendData appends data to the node
AppendData(context.Context, path.Path, io.Reader) (path.Resolved, error)
// SetData sets the data contained in the node
SetData(context.Context, path.Path, io.Reader) (path.Resolved, error)
// Diff returns a set of changes needed to transform the first object into the
// second.
Diff(context.Context, path.Path, path.Path) ([]ObjectChange, error)
}