master
go 67 lines 1.88 KB
Raw
1 package iface
2
3 import (
4 "context"
5
6 "github.com/ipfs/boxo/path"
7
8 "github.com/ipfs/kubo/core/coreiface/options"
9 )
10
11 // Pin holds information about pinned resource
12 type Pin interface {
13 // Path to the pinned object
14 Path() path.ImmutablePath
15
16 // Name is the name of the pin.
17 Name() string
18
19 // Type of the pin
20 Type() string
21 }
22
23 // PinStatus holds information about pin health
24 type PinStatus interface {
25 // Ok indicates whether the pin has been verified to be correct
26 Ok() bool
27
28 // BadNodes returns any bad (usually missing) nodes from the pin
29 BadNodes() []BadPinNode
30
31 // if not nil, an error happened. Everything else should be ignored.
32 Err() error
33 }
34
35 // BadPinNode is a node that has been marked as bad by Pin.Verify
36 type BadPinNode interface {
37 // Path is the path of the node
38 Path() path.ImmutablePath
39
40 // Err is the reason why the node has been marked as bad
41 Err() error
42 }
43
44 // PinAPI specifies the interface to pining
45 type PinAPI interface {
46 // Add creates new pin, be default recursive - pinning the whole referenced
47 // tree
48 Add(context.Context, path.Path, ...options.PinAddOption) error
49
50 // Ls returns this node's pinned objects on the provided channel. The
51 // channel is closed when there are no more pins and an error is returned.
52 Ls(context.Context, chan<- Pin, ...options.PinLsOption) error
53
54 // IsPinned returns whether or not the given cid is pinned
55 // and an explanation of why its pinned
56 IsPinned(context.Context, path.Path, ...options.PinIsPinnedOption) (string, bool, error)
57
58 // Rm removes pin for object specified by the path
59 Rm(context.Context, path.Path, ...options.PinRmOption) error
60
61 // Update changes one pin to another, skipping checks for matching paths in
62 // the old tree
63 Update(ctx context.Context, from path.Path, to path.Path, opts ...options.PinUpdateOption) error
64
65 // Verify verifies the integrity of pinned objects
66 Verify(context.Context) (<-chan PinStatus, error)
67 }