master
go 37 lines 1.04 KB
Raw
1 package iface
2
3 import (
4 "context"
5 "io"
6
7 "github.com/ipfs/boxo/path"
8 "github.com/ipfs/kubo/core/coreiface/options"
9 )
10
11 // BlockStat contains information about a block
12 type BlockStat interface {
13 // Size is the size of a block
14 Size() int
15
16 // Path returns path to the block
17 Path() path.ImmutablePath
18 }
19
20 // BlockAPI specifies the interface to the block layer
21 type BlockAPI interface {
22 // Put imports raw block data, hashing it using specified settings.
23 Put(context.Context, io.Reader, ...options.BlockPutOption) (BlockStat, error)
24
25 // Get attempts to resolve the path and return a reader for data in the block
26 Get(context.Context, path.Path) (io.Reader, error)
27
28 // Rm removes the block specified by the path from local blockstore.
29 // By default an error will be returned if the block can't be found locally.
30 //
31 // NOTE: If the specified block is pinned it won't be removed and no error
32 // will be returned
33 Rm(context.Context, path.Path, ...options.BlockRmOption) error
34
35 // Stat returns information on
36 Stat(context.Context, path.Path) (BlockStat, error)
37 }