// Code generated by capnpc-go. DO NOT EDIT.

package jsonrpc

import (
	capnp "capnproto.org/go/capnp/v3"
	text "capnproto.org/go/capnp/v3/encoding/text"
	schemas "capnproto.org/go/capnp/v3/schemas"
	json "capnproto.org/go/capnp/v3/std/capnp/compat/json"
	strconv "strconv"
)

type RpcMessage capnp.Struct
type RpcMessage_Which uint16

const (
	RpcMessage_Which_none   RpcMessage_Which = 0
	RpcMessage_Which_params RpcMessage_Which = 1
	RpcMessage_Which_result RpcMessage_Which = 2
	RpcMessage_Which_error  RpcMessage_Which = 3
)

func (w RpcMessage_Which) String() string {
	const s = "noneparamsresulterror"
	switch w {
	case RpcMessage_Which_none:
		return s[0:4]
	case RpcMessage_Which_params:
		return s[4:10]
	case RpcMessage_Which_result:
		return s[10:16]
	case RpcMessage_Which_error:
		return s[16:21]

	}
	return "RpcMessage_Which(" + strconv.FormatUint(uint64(w), 10) + ")"
}

// RpcMessage_TypeID is the unique identifier for the type RpcMessage.
const RpcMessage_TypeID = 0xd3a68cd48aa056ca

func NewRpcMessage(s *capnp.Segment) (RpcMessage, error) {
	st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 4})
	return RpcMessage(st), err
}

func NewRootRpcMessage(s *capnp.Segment) (RpcMessage, error) {
	st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 4})
	return RpcMessage(st), err
}

func ReadRootRpcMessage(msg *capnp.Message) (RpcMessage, error) {
	root, err := msg.Root()
	return RpcMessage(root.Struct()), err
}

func (s RpcMessage) String() string {
	str, _ := text.Marshal(0xd3a68cd48aa056ca, capnp.Struct(s))
	return str
}

func (s RpcMessage) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr {
	return capnp.Struct(s).EncodeAsPtr(seg)
}

func (RpcMessage) DecodeFromPtr(p capnp.Ptr) RpcMessage {
	return RpcMessage(capnp.Struct{}.DecodeFromPtr(p))
}

func (s RpcMessage) ToPtr() capnp.Ptr {
	return capnp.Struct(s).ToPtr()
}

func (s RpcMessage) Which() RpcMessage_Which {
	return RpcMessage_Which(capnp.Struct(s).Uint16(0))
}
func (s RpcMessage) IsValid() bool {
	return capnp.Struct(s).IsValid()
}

func (s RpcMessage) Message() *capnp.Message {
	return capnp.Struct(s).Message()
}

func (s RpcMessage) Segment() *capnp.Segment {
	return capnp.Struct(s).Segment()
}
func (s RpcMessage) Jsonrpc() (string, error) {
	p, err := capnp.Struct(s).Ptr(0)
	return p.Text(), err
}

func (s RpcMessage) HasJsonrpc() bool {
	return capnp.Struct(s).HasPtr(0)
}

func (s RpcMessage) JsonrpcBytes() ([]byte, error) {
	p, err := capnp.Struct(s).Ptr(0)
	return p.TextBytes(), err
}

func (s RpcMessage) SetJsonrpc(v string) error {
	return capnp.Struct(s).SetText(0, v)
}

func (s RpcMessage) Id() (json.Value, error) {
	p, err := capnp.Struct(s).Ptr(1)
	return json.Value(p.Struct()), err
}

func (s RpcMessage) HasId() bool {
	return capnp.Struct(s).HasPtr(1)
}

func (s RpcMessage) SetId(v json.Value) error {
	return capnp.Struct(s).SetPtr(1, capnp.Struct(v).ToPtr())
}

// NewId sets the id field to a newly
// allocated json.Value struct, preferring placement in s's segment.
func (s RpcMessage) NewId() (json.Value, error) {
	ss, err := json.NewValue(capnp.Struct(s).Segment())
	if err != nil {
		return json.Value{}, err
	}
	err = capnp.Struct(s).SetPtr(1, capnp.Struct(ss).ToPtr())
	return ss, err
}

func (s RpcMessage) Method() (string, error) {
	p, err := capnp.Struct(s).Ptr(2)
	return p.Text(), err
}

func (s RpcMessage) HasMethod() bool {
	return capnp.Struct(s).HasPtr(2)
}

func (s RpcMessage) MethodBytes() ([]byte, error) {
	p, err := capnp.Struct(s).Ptr(2)
	return p.TextBytes(), err
}

func (s RpcMessage) SetMethod(v string) error {
	return capnp.Struct(s).SetText(2, v)
}

func (s RpcMessage) SetNone() {
	capnp.Struct(s).SetUint16(0, 0)

}

func (s RpcMessage) Params() (json.Value, error) {
	if capnp.Struct(s).Uint16(0) != 1 {
		panic("Which() != params")
	}
	p, err := capnp.Struct(s).Ptr(3)
	return json.Value(p.Struct()), err
}

func (s RpcMessage) HasParams() bool {
	if capnp.Struct(s).Uint16(0) != 1 {
		return false
	}
	return capnp.Struct(s).HasPtr(3)
}

func (s RpcMessage) SetParams(v json.Value) error {
	capnp.Struct(s).SetUint16(0, 1)
	return capnp.Struct(s).SetPtr(3, capnp.Struct(v).ToPtr())
}

// NewParams sets the params field to a newly
// allocated json.Value struct, preferring placement in s's segment.
func (s RpcMessage) NewParams() (json.Value, error) {
	capnp.Struct(s).SetUint16(0, 1)
	ss, err := json.NewValue(capnp.Struct(s).Segment())
	if err != nil {
		return json.Value{}, err
	}
	err = capnp.Struct(s).SetPtr(3, capnp.Struct(ss).ToPtr())
	return ss, err
}

func (s RpcMessage) Result() (json.Value, error) {
	if capnp.Struct(s).Uint16(0) != 2 {
		panic("Which() != result")
	}
	p, err := capnp.Struct(s).Ptr(3)
	return json.Value(p.Struct()), err
}

func (s RpcMessage) HasResult() bool {
	if capnp.Struct(s).Uint16(0) != 2 {
		return false
	}
	return capnp.Struct(s).HasPtr(3)
}

func (s RpcMessage) SetResult(v json.Value) error {
	capnp.Struct(s).SetUint16(0, 2)
	return capnp.Struct(s).SetPtr(3, capnp.Struct(v).ToPtr())
}

// NewResult sets the result field to a newly
// allocated json.Value struct, preferring placement in s's segment.
func (s RpcMessage) NewResult() (json.Value, error) {
	capnp.Struct(s).SetUint16(0, 2)
	ss, err := json.NewValue(capnp.Struct(s).Segment())
	if err != nil {
		return json.Value{}, err
	}
	err = capnp.Struct(s).SetPtr(3, capnp.Struct(ss).ToPtr())
	return ss, err
}

func (s RpcMessage) Error() (RpcMessage_Error, error) {
	if capnp.Struct(s).Uint16(0) != 3 {
		panic("Which() != error")
	}
	p, err := capnp.Struct(s).Ptr(3)
	return RpcMessage_Error(p.Struct()), err
}

func (s RpcMessage) HasError() bool {
	if capnp.Struct(s).Uint16(0) != 3 {
		return false
	}
	return capnp.Struct(s).HasPtr(3)
}

func (s RpcMessage) SetError(v RpcMessage_Error) error {
	capnp.Struct(s).SetUint16(0, 3)
	return capnp.Struct(s).SetPtr(3, capnp.Struct(v).ToPtr())
}

// NewError sets the error field to a newly
// allocated RpcMessage_Error struct, preferring placement in s's segment.
func (s RpcMessage) NewError() (RpcMessage_Error, error) {
	capnp.Struct(s).SetUint16(0, 3)
	ss, err := NewRpcMessage_Error(capnp.Struct(s).Segment())
	if err != nil {
		return RpcMessage_Error{}, err
	}
	err = capnp.Struct(s).SetPtr(3, capnp.Struct(ss).ToPtr())
	return ss, err
}

// RpcMessage_List is a list of RpcMessage.
type RpcMessage_List = capnp.StructList[RpcMessage]

// NewRpcMessage creates a new list of RpcMessage.
func NewRpcMessage_List(s *capnp.Segment, sz int32) (RpcMessage_List, error) {
	l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 4}, sz)
	return capnp.StructList[RpcMessage](l), err
}

// RpcMessage_Future is a wrapper for a RpcMessage promised by a client call.
type RpcMessage_Future struct{ *capnp.Future }

func (f RpcMessage_Future) Struct() (RpcMessage, error) {
	p, err := f.Future.Ptr()
	return RpcMessage(p.Struct()), err
}
func (p RpcMessage_Future) Id() json.Value_Future {
	return json.Value_Future{Future: p.Future.Field(1, nil)}
}
func (p RpcMessage_Future) Params() json.Value_Future {
	return json.Value_Future{Future: p.Future.Field(3, nil)}
}
func (p RpcMessage_Future) Result() json.Value_Future {
	return json.Value_Future{Future: p.Future.Field(3, nil)}
}
func (p RpcMessage_Future) Error() RpcMessage_Error_Future {
	return RpcMessage_Error_Future{Future: p.Future.Field(3, nil)}
}

type RpcMessage_Error capnp.Struct

// RpcMessage_Error_TypeID is the unique identifier for the type RpcMessage_Error.
const RpcMessage_Error_TypeID = 0xd0dd80fa25c37644

func NewRpcMessage_Error(s *capnp.Segment) (RpcMessage_Error, error) {
	st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2})
	return RpcMessage_Error(st), err
}

func NewRootRpcMessage_Error(s *capnp.Segment) (RpcMessage_Error, error) {
	st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2})
	return RpcMessage_Error(st), err
}

func ReadRootRpcMessage_Error(msg *capnp.Message) (RpcMessage_Error, error) {
	root, err := msg.Root()
	return RpcMessage_Error(root.Struct()), err
}

func (s RpcMessage_Error) String() string {
	str, _ := text.Marshal(0xd0dd80fa25c37644, capnp.Struct(s))
	return str
}

func (s RpcMessage_Error) EncodeAsPtr(seg *capnp.Segment) capnp.Ptr {
	return capnp.Struct(s).EncodeAsPtr(seg)
}

func (RpcMessage_Error) DecodeFromPtr(p capnp.Ptr) RpcMessage_Error {
	return RpcMessage_Error(capnp.Struct{}.DecodeFromPtr(p))
}

func (s RpcMessage_Error) ToPtr() capnp.Ptr {
	return capnp.Struct(s).ToPtr()
}
func (s RpcMessage_Error) IsValid() bool {
	return capnp.Struct(s).IsValid()
}

func (s RpcMessage_Error) Message() *capnp.Message {
	return capnp.Struct(s).Message()
}

func (s RpcMessage_Error) Segment() *capnp.Segment {
	return capnp.Struct(s).Segment()
}
func (s RpcMessage_Error) Code() int32 {
	return int32(capnp.Struct(s).Uint32(0))
}

func (s RpcMessage_Error) SetCode(v int32) {
	capnp.Struct(s).SetUint32(0, uint32(v))
}

func (s RpcMessage_Error) MessageValue() (string, error) {
	p, err := capnp.Struct(s).Ptr(0)
	return p.Text(), err
}

func (s RpcMessage_Error) HasMessageValue() bool {
	return capnp.Struct(s).HasPtr(0)
}

func (s RpcMessage_Error) MessageValueBytes() ([]byte, error) {
	p, err := capnp.Struct(s).Ptr(0)
	return p.TextBytes(), err
}

func (s RpcMessage_Error) SetMessageValue(v string) error {
	return capnp.Struct(s).SetText(0, v)
}

func (s RpcMessage_Error) Data() (json.Value, error) {
	p, err := capnp.Struct(s).Ptr(1)
	return json.Value(p.Struct()), err
}

func (s RpcMessage_Error) HasData() bool {
	return capnp.Struct(s).HasPtr(1)
}

func (s RpcMessage_Error) SetData(v json.Value) error {
	return capnp.Struct(s).SetPtr(1, capnp.Struct(v).ToPtr())
}

// NewData sets the data field to a newly
// allocated json.Value struct, preferring placement in s's segment.
func (s RpcMessage_Error) NewData() (json.Value, error) {
	ss, err := json.NewValue(capnp.Struct(s).Segment())
	if err != nil {
		return json.Value{}, err
	}
	err = capnp.Struct(s).SetPtr(1, capnp.Struct(ss).ToPtr())
	return ss, err
}

// RpcMessage_Error_List is a list of RpcMessage_Error.
type RpcMessage_Error_List = capnp.StructList[RpcMessage_Error]

// NewRpcMessage_Error creates a new list of RpcMessage_Error.
func NewRpcMessage_Error_List(s *capnp.Segment, sz int32) (RpcMessage_Error_List, error) {
	l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz)
	return capnp.StructList[RpcMessage_Error](l), err
}

// RpcMessage_Error_Future is a wrapper for a RpcMessage_Error promised by a client call.
type RpcMessage_Error_Future struct{ *capnp.Future }

func (f RpcMessage_Error_Future) Struct() (RpcMessage_Error, error) {
	p, err := f.Future.Ptr()
	return RpcMessage_Error(p.Struct()), err
}
func (p RpcMessage_Error_Future) Data() json.Value_Future {
	return json.Value_Future{Future: p.Future.Field(1, nil)}
}

const schema_d04299800d6725ba = "x\xdal\x90\xc1k\x13A\x1c\x85\xdf\x9b\x99\xb4\x1eR" +
	"\xd2m\x02\xa5\xa5%\xf1\x90Ki\xa3m/R\x90\xd6" +
	"`\x0e\x05\x05\xa7\x85\x82\xa8\xe0\x92,1%\xc9.\xb3" +
	"\x89\xf4PhA\xbc\x88\xe2\xd9\x9b x\xd5\x83\x82\x15" +
	"\x05\xab\x9e<\x15\x15=\xf5\x7fP\xf0`C\xea\xcat" +
	"m*\xd6\xdb\xf2\xde\xdb\xf9\xf1}\xa7\xafrAM\x0f" +
	"|U\x10\xfaL\xa2/:\x7f\xf3]\xbe\xb3\xb9\xbb\x03" +
	"=JF\x1fV\x1e\xde\xf9|\xf7\xf1'$D?0" +
	"\xab\x85`\xfa\x9a\xfdL_\x16O\xf0W\xafSd\xf4" +
	"2_\x1d\xd8|P\xdcAI\xf5+ =\"?\xa6" +
	"\xf3r\x18\x98\x9d\x92\xf7\x89\xdb\xd1j\xe87\xa7LP" +
	"\x96\x85\xb2\x1b4\x83\xb9\xa5\xa0|\xd1\x0bC\xb7\xea\x15" +
	"J\xc6\xf8\x06\x97H\x9d\x94\x0aP\x04\x9c\xd2\x04\xa0\x17" +
	"$\xf5\x05A2C\x9b-\x16\x9d\xc5\xac\xaeK\xea5" +
	"AG0C\x018m\xbb\x0c$\xf5\xba`\xaa\xecW" +
	"<*\x08*p\xa3\x11\xbf\xaf\x15E\xf4\xfd\xde\xa9\xe1" +
	"\xa1\xeb[o\xa1\x95\xe0\xb9\x0c\x99\x04\x1c\xaeF\x7f6" +
	"+H\xb9\xf5\xb6\x070\x09\xc1$\x98\xaa\xb8-\x97\x83" +
	"\xd1\xad\xdd\x91\xbd\xd2Z\xe7\x11@\x0e\x82=\x0c\xf1/" +
	"\x06\xed\x1d\x1e9t8\x93=\x00\xd3c=\xa8\xe7E" +
	"@?\x95\xd4\xaf\x04\x9dC\xaa\xadQ@?\x93\xd4o" +
	",\x94\x88\xa1^\xcf\x01\xfa\x85\xa4~/8 \xa3(" +
	"C\x098\xdb\x13\xcevV\x7f\x93\xd4]\xc1q\xf5+" +
	"\x92\x19*\xc0\xd9\xb3\xeb\x1f\x92K\x14\x1cO\xec\xdb8" +
	"\x018\xfb6\xfe)\xb9\xacl\xde\xd7\xb5y\x1f\x90&" +
	"g\x00\xdd\x95\\>A\xc1\x0d\x8bd\x82\xf2!\xb9\xac" +
	"U\x8es\xcf7\xbc\xd6\x0d\xbf\xd2\xb3\xd3\xf4\x9b\xb1\xd7" +
	"\xb3\xeb\x85\xb1/\xd9+\x9d\xd8k\xee\xc0\xeb4\x87\x18" +
	"\x9dl\xd4\xc2\xb0\xd6\xac\xca\\\xe0\x1a\xb7\x11N\xe6\x8c" +
	"\x17\xb6\xeb\xad\xc9\x9cor\x9e1>\x0d\xfa\xe7\xe3\xee" +
	"?\xf7\xe2\xf1\xf1\"k\x7f5\x1c<\x12\x1d\xe7\xbf\x03" +
	"\x00\x00\xff\xff\x8c'\xbah"

func RegisterSchema(reg *schemas.Registry) {
	reg.Register(&schemas.Schema{
		String: schema_d04299800d6725ba,
		Nodes: []uint64{
			0xd0dd80fa25c37644,
			0xd3a68cd48aa056ca,
		},
		Compressed: true,
	})
}
