mirror of
https://github.com/ipfs/kubo.git
synced 2025-08-06 19:44:01 +08:00

This commit was moved from ipfs/interface-go-ipfs-core@515a114be2 This commit was moved from ipfs/boxo@5c537a46d3
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package iface
|
|
|
|
import (
|
|
"context"
|
|
"github.com/ipfs/interface-go-ipfs-core/options"
|
|
|
|
ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format"
|
|
"gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs"
|
|
"gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files"
|
|
)
|
|
|
|
type AddEvent struct {
|
|
Name string
|
|
Path ResolvedPath `json:",omitempty"`
|
|
Bytes int64 `json:",omitempty"`
|
|
Size string `json:",omitempty"`
|
|
}
|
|
|
|
type FileType int32
|
|
|
|
const (
|
|
TRaw = FileType(unixfs.TRaw)
|
|
TFile = FileType(unixfs.TFile)
|
|
TDirectory = FileType(unixfs.TDirectory)
|
|
TMetadata = FileType(unixfs.TMetadata)
|
|
TSymlink = FileType(unixfs.TSymlink)
|
|
THAMTShard = FileType(unixfs.THAMTShard)
|
|
)
|
|
|
|
type LsLink struct {
|
|
Link *ipld.Link
|
|
Size uint64
|
|
Type FileType
|
|
|
|
Err error
|
|
}
|
|
|
|
// UnixfsAPI is the basic interface to immutable files in IPFS
|
|
// NOTE: This API is heavily WIP, things are guaranteed to break frequently
|
|
type UnixfsAPI interface {
|
|
// Add imports the data from the reader into merkledag file
|
|
//
|
|
// TODO: a long useful comment on how to use this for many different scenarios
|
|
Add(context.Context, files.Node, ...options.UnixfsAddOption) (ResolvedPath, error)
|
|
|
|
// Get returns a read-only handle to a file tree referenced by a path
|
|
//
|
|
// Note that some implementations of this API may apply the specified context
|
|
// to operations performed on the returned file
|
|
Get(context.Context, Path) (files.Node, error)
|
|
|
|
// Ls returns the list of links in a directory. Links aren't guaranteed to be
|
|
// returned in order
|
|
Ls(context.Context, Path, ...options.UnixfsLsOption) (<-chan LsLink, error)
|
|
}
|