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

package tunnelrpc

import (
	capnp "zombiezen.com/go/capnproto2"
	text "zombiezen.com/go/capnproto2/encoding/text"
	schemas "zombiezen.com/go/capnproto2/schemas"
)

type ConnectRequest struct{ capnp.Struct }

// ConnectRequest_TypeID is the unique identifier for the type ConnectRequest.
const ConnectRequest_TypeID = 0xc47116a1045e4061

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

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

func ReadRootConnectRequest(msg *capnp.Message) (ConnectRequest, error) {
	root, err := msg.RootPtr()
	return ConnectRequest{root.Struct()}, err
}

func (s ConnectRequest) String() string {
	str, _ := text.Marshal(0xc47116a1045e4061, s.Struct)
	return str
}

func (s ConnectRequest) Dest() (string, error) {
	p, err := s.Struct.Ptr(0)
	return p.Text(), err
}

func (s ConnectRequest) HasDest() bool {
	p, err := s.Struct.Ptr(0)
	return p.IsValid() || err != nil
}

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

func (s ConnectRequest) SetDest(v string) error {
	return s.Struct.SetText(0, v)
}

func (s ConnectRequest) Type() ConnectionType {
	return ConnectionType(s.Struct.Uint16(0))
}

func (s ConnectRequest) SetType(v ConnectionType) {
	s.Struct.SetUint16(0, uint16(v))
}

func (s ConnectRequest) Metadata() (Metadata_List, error) {
	p, err := s.Struct.Ptr(1)
	return Metadata_List{List: p.List()}, err
}

func (s ConnectRequest) HasMetadata() bool {
	p, err := s.Struct.Ptr(1)
	return p.IsValid() || err != nil
}

func (s ConnectRequest) SetMetadata(v Metadata_List) error {
	return s.Struct.SetPtr(1, v.List.ToPtr())
}

// NewMetadata sets the metadata field to a newly
// allocated Metadata_List, preferring placement in s's segment.
func (s ConnectRequest) NewMetadata(n int32) (Metadata_List, error) {
	l, err := NewMetadata_List(s.Struct.Segment(), n)
	if err != nil {
		return Metadata_List{}, err
	}
	err = s.Struct.SetPtr(1, l.List.ToPtr())
	return l, err
}

// ConnectRequest_List is a list of ConnectRequest.
type ConnectRequest_List struct{ capnp.List }

// NewConnectRequest creates a new list of ConnectRequest.
func NewConnectRequest_List(s *capnp.Segment, sz int32) (ConnectRequest_List, error) {
	l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 8, PointerCount: 2}, sz)
	return ConnectRequest_List{l}, err
}

func (s ConnectRequest_List) At(i int) ConnectRequest { return ConnectRequest{s.List.Struct(i)} }

func (s ConnectRequest_List) Set(i int, v ConnectRequest) error { return s.List.SetStruct(i, v.Struct) }

func (s ConnectRequest_List) String() string {
	str, _ := text.MarshalList(0xc47116a1045e4061, s.List)
	return str
}

// ConnectRequest_Promise is a wrapper for a ConnectRequest promised by a client call.
type ConnectRequest_Promise struct{ *capnp.Pipeline }

func (p ConnectRequest_Promise) Struct() (ConnectRequest, error) {
	s, err := p.Pipeline.Struct()
	return ConnectRequest{s}, err
}

type ConnectionType uint16

// ConnectionType_TypeID is the unique identifier for the type ConnectionType.
const ConnectionType_TypeID = 0xc52e1bac26d379c8

// Values of ConnectionType.
const (
	ConnectionType_http      ConnectionType = 0
	ConnectionType_websocket ConnectionType = 1
	ConnectionType_tcp       ConnectionType = 2
)

// String returns the enum's constant name.
func (c ConnectionType) String() string {
	switch c {
	case ConnectionType_http:
		return "http"
	case ConnectionType_websocket:
		return "websocket"
	case ConnectionType_tcp:
		return "tcp"

	default:
		return ""
	}
}

// ConnectionTypeFromString returns the enum value with a name,
// or the zero value if there's no such value.
func ConnectionTypeFromString(c string) ConnectionType {
	switch c {
	case "http":
		return ConnectionType_http
	case "websocket":
		return ConnectionType_websocket
	case "tcp":
		return ConnectionType_tcp

	default:
		return 0
	}
}

type ConnectionType_List struct{ capnp.List }

func NewConnectionType_List(s *capnp.Segment, sz int32) (ConnectionType_List, error) {
	l, err := capnp.NewUInt16List(s, sz)
	return ConnectionType_List{l.List}, err
}

func (l ConnectionType_List) At(i int) ConnectionType {
	ul := capnp.UInt16List{List: l.List}
	return ConnectionType(ul.At(i))
}

func (l ConnectionType_List) Set(i int, v ConnectionType) {
	ul := capnp.UInt16List{List: l.List}
	ul.Set(i, uint16(v))
}

type Metadata struct{ capnp.Struct }

// Metadata_TypeID is the unique identifier for the type Metadata.
const Metadata_TypeID = 0xe1446b97bfd1cd37

func NewMetadata(s *capnp.Segment) (Metadata, error) {
	st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
	return Metadata{st}, err
}

func NewRootMetadata(s *capnp.Segment) (Metadata, error) {
	st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
	return Metadata{st}, err
}

func ReadRootMetadata(msg *capnp.Message) (Metadata, error) {
	root, err := msg.RootPtr()
	return Metadata{root.Struct()}, err
}

func (s Metadata) String() string {
	str, _ := text.Marshal(0xe1446b97bfd1cd37, s.Struct)
	return str
}

func (s Metadata) Key() (string, error) {
	p, err := s.Struct.Ptr(0)
	return p.Text(), err
}

func (s Metadata) HasKey() bool {
	p, err := s.Struct.Ptr(0)
	return p.IsValid() || err != nil
}

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

func (s Metadata) SetKey(v string) error {
	return s.Struct.SetText(0, v)
}

func (s Metadata) Val() (string, error) {
	p, err := s.Struct.Ptr(1)
	return p.Text(), err
}

func (s Metadata) HasVal() bool {
	p, err := s.Struct.Ptr(1)
	return p.IsValid() || err != nil
}

func (s Metadata) ValBytes() ([]byte, error) {
	p, err := s.Struct.Ptr(1)
	return p.TextBytes(), err
}

func (s Metadata) SetVal(v string) error {
	return s.Struct.SetText(1, v)
}

// Metadata_List is a list of Metadata.
type Metadata_List struct{ capnp.List }

// NewMetadata creates a new list of Metadata.
func NewMetadata_List(s *capnp.Segment, sz int32) (Metadata_List, error) {
	l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
	return Metadata_List{l}, err
}

func (s Metadata_List) At(i int) Metadata { return Metadata{s.List.Struct(i)} }

func (s Metadata_List) Set(i int, v Metadata) error { return s.List.SetStruct(i, v.Struct) }

func (s Metadata_List) String() string {
	str, _ := text.MarshalList(0xe1446b97bfd1cd37, s.List)
	return str
}

// Metadata_Promise is a wrapper for a Metadata promised by a client call.
type Metadata_Promise struct{ *capnp.Pipeline }

func (p Metadata_Promise) Struct() (Metadata, error) {
	s, err := p.Pipeline.Struct()
	return Metadata{s}, err
}

type ConnectResponse struct{ capnp.Struct }

// ConnectResponse_TypeID is the unique identifier for the type ConnectResponse.
const ConnectResponse_TypeID = 0xb1032ec91cef8727

func NewConnectResponse(s *capnp.Segment) (ConnectResponse, error) {
	st, err := capnp.NewStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
	return ConnectResponse{st}, err
}

func NewRootConnectResponse(s *capnp.Segment) (ConnectResponse, error) {
	st, err := capnp.NewRootStruct(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2})
	return ConnectResponse{st}, err
}

func ReadRootConnectResponse(msg *capnp.Message) (ConnectResponse, error) {
	root, err := msg.RootPtr()
	return ConnectResponse{root.Struct()}, err
}

func (s ConnectResponse) String() string {
	str, _ := text.Marshal(0xb1032ec91cef8727, s.Struct)
	return str
}

func (s ConnectResponse) Error() (string, error) {
	p, err := s.Struct.Ptr(0)
	return p.Text(), err
}

func (s ConnectResponse) HasError() bool {
	p, err := s.Struct.Ptr(0)
	return p.IsValid() || err != nil
}

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

func (s ConnectResponse) SetError(v string) error {
	return s.Struct.SetText(0, v)
}

func (s ConnectResponse) Metadata() (Metadata_List, error) {
	p, err := s.Struct.Ptr(1)
	return Metadata_List{List: p.List()}, err
}

func (s ConnectResponse) HasMetadata() bool {
	p, err := s.Struct.Ptr(1)
	return p.IsValid() || err != nil
}

func (s ConnectResponse) SetMetadata(v Metadata_List) error {
	return s.Struct.SetPtr(1, v.List.ToPtr())
}

// NewMetadata sets the metadata field to a newly
// allocated Metadata_List, preferring placement in s's segment.
func (s ConnectResponse) NewMetadata(n int32) (Metadata_List, error) {
	l, err := NewMetadata_List(s.Struct.Segment(), n)
	if err != nil {
		return Metadata_List{}, err
	}
	err = s.Struct.SetPtr(1, l.List.ToPtr())
	return l, err
}

// ConnectResponse_List is a list of ConnectResponse.
type ConnectResponse_List struct{ capnp.List }

// NewConnectResponse creates a new list of ConnectResponse.
func NewConnectResponse_List(s *capnp.Segment, sz int32) (ConnectResponse_List, error) {
	l, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 2}, sz)
	return ConnectResponse_List{l}, err
}

func (s ConnectResponse_List) At(i int) ConnectResponse { return ConnectResponse{s.List.Struct(i)} }

func (s ConnectResponse_List) Set(i int, v ConnectResponse) error {
	return s.List.SetStruct(i, v.Struct)
}

func (s ConnectResponse_List) String() string {
	str, _ := text.MarshalList(0xb1032ec91cef8727, s.List)
	return str
}

// ConnectResponse_Promise is a wrapper for a ConnectResponse promised by a client call.
type ConnectResponse_Promise struct{ *capnp.Pipeline }

func (p ConnectResponse_Promise) Struct() (ConnectResponse, error) {
	s, err := p.Pipeline.Struct()
	return ConnectResponse{s}, err
}

const schema_b29021ef7421cc32 = "x\xda\xac\x91Ak\x13A\x1c\xc5\xdf\x9bI\\\x85\xe8" +
	"fH\x15DCi\x11\xb5\xc5\x06\x9b\x08\x82\xa7\x80\x15" +
	"TZ\xcc\x14\xcf\x96\xedv\xb05\xed\xee$;\xb5\xe4" +
	"\x13x\xf5&\x1e=\x0a\x8a\xe8\x17\xf0\xa2\xa0\xa0\x88\x88" +
	"\x1f\xc0\x83\x07O\xfd\x04\xb22\x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xd07\xa3r\xfb\xe0q" +
	"\xb4]\xce\xff\x02\x00\x00\xff\xff\x14\xd5\xb6\xda"

func init() {
	schemas.Register(schema_b29021ef7421cc32,
		0xb1032ec91cef8727,
		0xc47116a1045e4061,
		0xc52e1bac26d379c8,
		0xe1446b97bfd1cd37)
}
