cborrpc

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeParseError     = -32700
	CodeInvalidRequest = -32600
	CodeMethodNotFound = -32601
	CodeInvalidParams  = -32602
	CodeInternalError  = -32603
	CodeServerError    = -32000 // -32000 to -32099	Server error, Reserved for implementation-defined server-errors.
)
View Source
const (
	MIMEApplicationCBOR            = "application/cbor"
	MIMEApplicationCBORCharsetUTF8 = "application/cbor; charset=utf-8"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, rt http.RoundTripper, header http.Header) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *Req) *Res

func (*Client) Req

func (c *Client) Req(ctx context.Context, method string, params, result interface{}) *Res

type Err

type Err struct {
	Code    int         `cbor:"code"`
	Message string      `cbor:"message"`
	Data    interface{} `cbor:"data,omitempty"`
}

func (*Err) Error

func (err *Err) Error() string

type Req

type Req struct {
	Method string          `cbor:"method"`
	Params cbor.RawMessage `cbor:"params,omitempty"`
}

func DecodeReq

func DecodeReq(data []byte) (*Req, error)

func (*Req) DecodeParams

func (req *Req) DecodeParams(params interface{}) error

func (*Req) Error

func (req *Req) Error(err error) *Res

func (*Req) InvalidMethod

func (req *Req) InvalidMethod() *Res

func (*Req) InvalidParams

func (req *Req) InvalidParams(msg string) *Res

func (*Req) Result

func (req *Req) Result(result interface{}) *Res

func (*Req) ResultRaw

func (req *Req) ResultRaw(result cbor.RawMessage) *Res

func (*Req) String

func (req *Req) String() string

type Res

type Res struct {
	Error  *Err            `cbor:"error,omitempty"`
	Result cbor.RawMessage `cbor:"result,omitempty"`
}

func DecodeRes

func DecodeRes(data []byte) *Res

func (*Res) DecodeResult

func (res *Res) DecodeResult(result interface{}) error

func (*Res) String

func (res *Res) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL