1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 11:52:21 +08:00
Files
kubo/namesys/interface.go
Juan Batiz-Benet 2944360f5c New NameSystem interface
type NameSystem interface {
      Resolver
      Publisher
    }

should say it all.

cc @whyrusleeping
2014-10-08 04:14:52 -07:00

44 lines
1.2 KiB
Go

package namesys
import (
"errors"
ci "github.com/jbenet/go-ipfs/crypto"
)
// ErrResolveFailed signals an error when attempting to resolve.
var ErrResolveFailed = errors.New("could not resolve name.")
// ErrPublishFailed signals an error when attempting to publish.
var ErrPublishFailed = errors.New("could not publish name.")
// Namesys represents a cohesive name publishing and resolving system.
//
// Publishing a name is the process of establishing a mapping, a key-value
// pair, according to naming rules and databases.
//
// Resolving a name is the process of looking up the value associated with the
// key (name).
type NameSystem interface {
Resolver
Publisher
}
// Resolver is an object capable of resolving names.
type Resolver interface {
// Resolve looks up a name, and returns the value previously published.
Resolve(name string) (value string, err error)
// CanResolve checks whether this Resolver can resolve a name
CanResolve(name string) bool
}
// Publisher is an object capable of publishing particular names.
type Publisher interface {
// Publish establishes a name-value mapping.
// TODO make this not PrivKey specific.
Publish(name ci.PrivKey, value string) error
}