2019-06-29 09:19:06 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/libp2p/go-libp2p-core/peer"
|
|
|
|
)
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// Struct implements API passing calls to user-provided function values.
|
2019-06-29 09:19:06 +00:00
|
|
|
type Struct struct {
|
2019-07-01 20:00:22 +00:00
|
|
|
Internal struct {
|
|
|
|
ID func(context.Context) (peer.ID, error)
|
2019-06-29 09:19:06 +00:00
|
|
|
Version func(context.Context) (Version, error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// ID implements API.ID
|
2019-06-29 09:19:06 +00:00
|
|
|
func (c *Struct) ID(ctx context.Context) (peer.ID, error) {
|
|
|
|
return c.Internal.ID(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-02 13:05:43 +00:00
|
|
|
// Version implements API.Version
|
2019-06-29 09:19:06 +00:00
|
|
|
func (c *Struct) Version(ctx context.Context) (Version, error) {
|
|
|
|
return c.Internal.Version(ctx)
|
|
|
|
}
|
|
|
|
|
2019-07-01 20:00:22 +00:00
|
|
|
var _ API = &Struct{}
|