48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package dinet
|
|
|
|
import (
|
|
"time"
|
|
|
|
"src.dualinventive.com/go/dinet/rpc"
|
|
)
|
|
|
|
// DeviceCallbacks is a struct that implements the DeviceInfo interface. You can change realtime the callbacks.
|
|
// Useful for unit testing
|
|
type DeviceCallbacks struct {
|
|
DevUID string
|
|
DevType rpc.DeviceType
|
|
CBVersions func() (rpc.VersionMap, rpc.ErrorCode)
|
|
CBTimeout func() time.Duration
|
|
CBTransport func() (interface{}, rpc.ErrorCode)
|
|
}
|
|
|
|
// UID returns the public field DevUID
|
|
func (t *DeviceCallbacks) UID() string {
|
|
return t.DevUID
|
|
}
|
|
|
|
// Type returns the public field DevType
|
|
func (t *DeviceCallbacks) Type() rpc.DeviceType {
|
|
return t.DevType
|
|
}
|
|
|
|
// Versions calls the public callback CBVersions
|
|
func (t *DeviceCallbacks) Versions() (rpc.VersionMap, rpc.ErrorCode) {
|
|
return t.CBVersions()
|
|
}
|
|
|
|
// TimeoutDuration calls the public callback CBTimeout
|
|
func (t *DeviceCallbacks) TimeoutDuration() time.Duration {
|
|
return t.CBTimeout()
|
|
}
|
|
|
|
// Transport calls the public callback CBTransport
|
|
func (t *DeviceCallbacks) Transport() (interface{}, rpc.ErrorCode) {
|
|
return t.CBTransport()
|
|
}
|
|
|
|
// Close doesn't do anything
|
|
func (t *DeviceCallbacks) Close() error {
|
|
return nil
|
|
}
|