package capnmsg

// AUTO GENERATED - DO NOT EDIT

import (
	C "github.com/glycerine/go-capnproto"
	"unsafe"
)

type Msg C.Struct

func NewMsg(s *C.Segment) Msg        { return Msg(s.NewStruct(24, 4)) }
func NewRootMsg(s *C.Segment) Msg    { return Msg(s.NewRootStruct(24, 4)) }
func AutoNewMsg(s *C.Segment) Msg    { return Msg(s.NewStructAR(24, 4)) }
func ReadRootMsg(s *C.Segment) Msg   { return Msg(s.Root(0).ToStruct()) }
func (s Msg) Kind() MsgKind          { return MsgKind(C.Struct(s).Get16(0)) }
func (s Msg) SetKind(v MsgKind)      { C.Struct(s).Set16(0, uint16(v)) }
func (s Msg) Time() uint64           { return C.Struct(s).Get64(8) }
func (s Msg) SetTime(v uint64)       { C.Struct(s).Set64(8, v) }
func (s Msg) Service() string        { return C.Struct(s).GetObject(0).ToText() }
func (s Msg) SetService(v string)    { C.Struct(s).SetObject(0, s.Segment.NewText(v)) }
func (s Msg) Machine() string        { return C.Struct(s).GetObject(1).ToText() }
func (s Msg) SetMachine(v string)    { C.Struct(s).SetObject(1, s.Segment.NewText(v)) }
func (s Msg) Pid() int32             { return int32(C.Struct(s).Get32(4)) }
func (s Msg) SetPid(v int32)         { C.Struct(s).Set32(4, uint32(v)) }
func (s Msg) Traceid() uint64        { return C.Struct(s).Get64(16) }
func (s Msg) SetTraceid(v uint64)    { C.Struct(s).Set64(16, v) }
func (s Msg) Subtraceid() string     { return C.Struct(s).GetObject(2).ToText() }
func (s Msg) SetSubtraceid(v string) { C.Struct(s).SetObject(2, s.Segment.NewText(v)) }
func (s Msg) Desc() MsgDesc_List     { return MsgDesc_List(C.Struct(s).GetObject(3)) }
func (s Msg) SetDesc(v MsgDesc_List) { C.Struct(s).SetObject(3, C.Object(v)) }

// capn.JSON_enabled == false so we stub MarshallJSON().
func (s Msg) MarshalJSON() (bs []byte, err error) { return }

type Msg_List C.PointerList

func NewMsgList(s *C.Segment, sz int) Msg_List { return Msg_List(s.NewCompositeList(24, 4, sz)) }
func (s Msg_List) Len() int                    { return C.PointerList(s).Len() }
func (s Msg_List) At(i int) Msg                { return Msg(C.PointerList(s).At(i).ToStruct()) }
func (s Msg_List) ToArray() []Msg              { return *(*[]Msg)(unsafe.Pointer(C.PointerList(s).ToArray())) }
func (s Msg_List) Set(i int, item Msg)         { C.PointerList(s).Set(i, C.Object(item)) }

type MsgKind uint16

const (
	MSGKIND_ADMIN     MsgKind = 0
	MSGKIND_CONNECT   MsgKind = 1
	MSGKIND_EVENT     MsgKind = 2
	MSGKIND_TRANSTART MsgKind = 3
	MSGKIND_TRANEND   MsgKind = 4
	MSGKIND_CALLSTART MsgKind = 5
	MSGKIND_CALLEND   MsgKind = 6
)

func (c MsgKind) String() string {
	switch c {
	case MSGKIND_ADMIN:
		return "admin"
	case MSGKIND_CONNECT:
		return "connect"
	case MSGKIND_EVENT:
		return "event"
	case MSGKIND_TRANSTART:
		return "tranStart"
	case MSGKIND_TRANEND:
		return "tranEnd"
	case MSGKIND_CALLSTART:
		return "callStart"
	case MSGKIND_CALLEND:
		return "callEnd"
	default:
		return ""
	}
}

func MsgKindFromString(c string) MsgKind {
	switch c {
	case "admin":
		return MSGKIND_ADMIN
	case "connect":
		return MSGKIND_CONNECT
	case "event":
		return MSGKIND_EVENT
	case "tranStart":
		return MSGKIND_TRANSTART
	case "tranEnd":
		return MSGKIND_TRANEND
	case "callStart":
		return MSGKIND_CALLSTART
	case "callEnd":
		return MSGKIND_CALLEND
	default:
		return 0
	}
}

type MsgKind_List C.PointerList

func NewMsgKindList(s *C.Segment, sz int) MsgKind_List { return MsgKind_List(s.NewUInt16List(sz)) }
func (s MsgKind_List) Len() int                        { return C.UInt16List(s).Len() }
func (s MsgKind_List) At(i int) MsgKind                { return MsgKind(C.UInt16List(s).At(i)) }
func (s MsgKind_List) ToArray() []MsgKind {
	return *(*[]MsgKind)(unsafe.Pointer(C.UInt16List(s).ToEnumArray()))
}

// capn.JSON_enabled == false so we stub MarshallJSON().
func (s MsgKind) MarshalJSON() (bs []byte, err error) { return }

type MsgDesc C.Struct

func NewMsgDesc(s *C.Segment) MsgDesc      { return MsgDesc(s.NewStruct(0, 2)) }
func NewRootMsgDesc(s *C.Segment) MsgDesc  { return MsgDesc(s.NewRootStruct(0, 2)) }
func AutoNewMsgDesc(s *C.Segment) MsgDesc  { return MsgDesc(s.NewStructAR(0, 2)) }
func ReadRootMsgDesc(s *C.Segment) MsgDesc { return MsgDesc(s.Root(0).ToStruct()) }
func (s MsgDesc) Key() string              { return C.Struct(s).GetObject(0).ToText() }
func (s MsgDesc) SetKey(v string)          { C.Struct(s).SetObject(0, s.Segment.NewText(v)) }
func (s MsgDesc) Val() string              { return C.Struct(s).GetObject(1).ToText() }
func (s MsgDesc) SetVal(v string)          { C.Struct(s).SetObject(1, s.Segment.NewText(v)) }

// capn.JSON_enabled == false so we stub MarshallJSON().
func (s MsgDesc) MarshalJSON() (bs []byte, err error) { return }

type MsgDesc_List C.PointerList

func NewMsgDescList(s *C.Segment, sz int) MsgDesc_List {
	return MsgDesc_List(s.NewCompositeList(0, 2, sz))
}
func (s MsgDesc_List) Len() int         { return C.PointerList(s).Len() }
func (s MsgDesc_List) At(i int) MsgDesc { return MsgDesc(C.PointerList(s).At(i).ToStruct()) }
func (s MsgDesc_List) ToArray() []MsgDesc {
	return *(*[]MsgDesc)(unsafe.Pointer(C.PointerList(s).ToArray()))
}
func (s MsgDesc_List) Set(i int, item MsgDesc) { C.PointerList(s).Set(i, C.Object(item)) }
