mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 21:07:45 +08:00
coreapi: use defined functions for pin type option
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@2e3f9758c8 This commit was moved from ipfs/boxo@8a0f402959
This commit is contained in:
parent
5e48849167
commit
8fea8513e3
@ -61,10 +61,38 @@ func PinUpdateOptions(opts ...PinUpdateOption) (*PinUpdateSettings, error) {
|
||||
return options, nil
|
||||
}
|
||||
|
||||
type pinOpts struct{}
|
||||
type pinType struct{}
|
||||
|
||||
type pinOpts struct {
|
||||
Type pinType
|
||||
}
|
||||
|
||||
var Pin pinOpts
|
||||
|
||||
// All is an option for Pin.Ls which will make it return all pins. It is
|
||||
// the default
|
||||
func (_ pinType) All() PinLsOption {
|
||||
return Pin.pinType("all")
|
||||
}
|
||||
|
||||
// Recursive is an option for Pin.Ls which will make it only return recursive
|
||||
// pins
|
||||
func (_ pinType) Recursive() PinLsOption {
|
||||
return Pin.pinType("recursive")
|
||||
}
|
||||
|
||||
// Direct is an option for Pin.Ls which will make it only return direct (non
|
||||
// recursive) pins
|
||||
func (_ pinType) Direct() PinLsOption {
|
||||
return Pin.pinType("direct")
|
||||
}
|
||||
|
||||
// Indirect is an option for Pin.Ls which will make it only return indirect pins
|
||||
// (objects referenced by other recursively pinned objects)
|
||||
func (_ pinType) Indirect() PinLsOption {
|
||||
return Pin.pinType("indirect")
|
||||
}
|
||||
|
||||
// Recursive is an option for Pin.Add which specifies whether to pin an entire
|
||||
// object tree or just one object. Default: true
|
||||
func (_ pinOpts) Recursive(recucsive bool) PinAddOption {
|
||||
@ -83,7 +111,7 @@ func (_ pinOpts) Recursive(recucsive bool) PinAddOption {
|
||||
// * "indirect" - indirectly pinned objects (referenced by recursively pinned
|
||||
// objects)
|
||||
// * "all" - all pinned objects (default)
|
||||
func (_ pinOpts) Type(t string) PinLsOption {
|
||||
func (_ pinOpts) pinType(t string) PinLsOption {
|
||||
return func(settings *PinLsSettings) error {
|
||||
settings.Type = t
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user