Documentation
¶
Overview ¶
Package cborrpc defines the CBOR-RPC format used by the Python Coordinate daemon.
Index ¶
- func CreateParamList(funcv reflect.Value, params []interface{}) ([]reflect.Value, error)
- func DecodeBytesAsString(from, to reflect.Type, data interface{}) (interface{}, error)
- func Destringify(obj interface{}) (string, bool)
- func Detuplify(obj interface{}) ([]interface{}, bool)
- func SetExts(cbor *codec.CborHandle) error
- func SloppyDetuplify(obj interface{}) []interface{}
- type PythonTuple
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateParamList ¶
CreateParamList tries to match a CBOR-RPC parameter list to a specific callable's parameter list. funcv is the reflected method to eventually call, and params is the list of parameters from the CBOR-RPC request. On success, the return value is a list of parameter values that can be passed to funcv.Call().
func DecodeBytesAsString ¶
DecodeBytesAsString is a mapstructure decode hook that accepts a byte slice where a string is expected.
func Destringify ¶
Destringify tries to turn any object into a string. If it is a string or byte slice, returns the string and true; otherwise returns empty string and false.
func Detuplify ¶
func Detuplify(obj interface{}) ([]interface{}, bool)
Detuplify removes a tuple wrapper. If obj is a tuple, returns the contained slice. If obj is a slice, returns it. Otherwise returns failure.
func SetExts ¶
func SetExts(cbor *codec.CborHandle) error
SetExts sets up the CBOR codec to understand the other objects in this package.
func SloppyDetuplify ¶
func SloppyDetuplify(obj interface{}) []interface{}
SloppyDetuplify turns any object into a slice. If it is already a PythonTuple or a slice, returns the slice as Detuplify; otherwise packages up obj into a new slice. This never fails.
Types ¶
type PythonTuple ¶
type PythonTuple struct {
Items []interface{}
}
PythonTuple is a simple Go wrapper representing a Python tuple. This is a fixed-length, ordered, immutable sequence of arbitrary items.
type Request ¶
type Request struct { // Name of the RPC method to invoke. Method string // Sequential, non-unique identifier for this request. ID uint // List of arbitrary parameters. Params []interface{} }
Request defines the fields of a CBOR-RPC request.
type Response ¶
type Response struct { // Sequential, non-unique identifier for this response. This should // always match the identifier from the corresponding Request. ID uint // Arbitrary response object; should be nil on error. Result interface{} // Error message on failure; should be empty on success. Error string }
Response defines the fields of a CBOR-RPC response