// Code generated by bebopc-go; DO NOT EDIT.

package generated

import (
	"github.com/200sc/bebop"
	"github.com/200sc/bebop/iohelp"
	"io"
)

type EnumU8 uint8

const (
	EnumU8_EnumU81 EnumU8 = 1
	EnumU8_EnumU82 EnumU8 = 2
)

type EnumByte byte

const (
	EnumByte_EnumByte1 EnumByte = 1
	EnumByte_EnumByte2 EnumByte = 2
)

type EnumU16 uint16

const (
	EnumU16_EnumU161 EnumU16 = 1
	EnumU16_EnumU162 EnumU16 = 2
)

type EnumU32 uint32

const (
	EnumU32_EnumU321 EnumU32 = 1
	EnumU32_EnumU322 EnumU32 = 2
)

type EnumU64 uint64

const (
	EnumU64_EnumU641 EnumU64 = 1
	EnumU64_EnumU642 EnumU64 = 2
)

type Enum16 int16

const (
	Enum16_Enum161 Enum16 = 1
	Enum16_Enum162 Enum16 = 2
)

type Enum32 int32

const (
	Enum32_Enum321 Enum32 = 1
	Enum32_Enum322 Enum32 = 2
)

type Enum64 int64

const (
	Enum64_Enum641 Enum64 = 1
	Enum64_Enum642 Enum64 = 2
)

var _ bebop.Record = &UsesAllEnums{}

type UsesAllEnums struct {
	One EnumU8
	Two EnumU16
	Three EnumU32
	Four EnumU64
	Five Enum16
	Six Enum32
	Seven Enum64
}

func (bbp *UsesAllEnums) MarshalBebopTo(buf []byte) int {
	at := 0
	iohelp.WriteUint8Bytes(buf[at:], uint8(bbp.One))
	at += 1
	iohelp.WriteUint16Bytes(buf[at:], uint16(bbp.Two))
	at += 2
	iohelp.WriteUint32Bytes(buf[at:], uint32(bbp.Three))
	at += 4
	iohelp.WriteUint64Bytes(buf[at:], uint64(bbp.Four))
	at += 8
	iohelp.WriteInt16Bytes(buf[at:], int16(bbp.Five))
	at += 2
	iohelp.WriteInt32Bytes(buf[at:], int32(bbp.Six))
	at += 4
	iohelp.WriteInt64Bytes(buf[at:], int64(bbp.Seven))
	at += 8
	return at
}

func (bbp *UsesAllEnums) UnmarshalBebop(buf []byte) (err error) {
	at := 0
	bbp.One = EnumU8(iohelp.ReadUint8Bytes(buf[at:]))
	at += 1
	bbp.Two = EnumU16(iohelp.ReadUint16Bytes(buf[at:]))
	at += 2
	bbp.Three = EnumU32(iohelp.ReadUint32Bytes(buf[at:]))
	at += 4
	bbp.Four = EnumU64(iohelp.ReadUint64Bytes(buf[at:]))
	at += 8
	bbp.Five = Enum16(iohelp.ReadInt16Bytes(buf[at:]))
	at += 2
	bbp.Six = Enum32(iohelp.ReadInt32Bytes(buf[at:]))
	at += 4
	bbp.Seven = Enum64(iohelp.ReadInt64Bytes(buf[at:]))
	at += 8
	return nil
}

func (bbp *UsesAllEnums) MustUnmarshalBebop(buf []byte) {
	at := 0
	bbp.One = EnumU8(iohelp.ReadUint8Bytes(buf[at:]))
	at += 1
	bbp.Two = EnumU16(iohelp.ReadUint16Bytes(buf[at:]))
	at += 2
	bbp.Three = EnumU32(iohelp.ReadUint32Bytes(buf[at:]))
	at += 4
	bbp.Four = EnumU64(iohelp.ReadUint64Bytes(buf[at:]))
	at += 8
	bbp.Five = Enum16(iohelp.ReadInt16Bytes(buf[at:]))
	at += 2
	bbp.Six = Enum32(iohelp.ReadInt32Bytes(buf[at:]))
	at += 4
	bbp.Seven = Enum64(iohelp.ReadInt64Bytes(buf[at:]))
	at += 8
}

func (bbp *UsesAllEnums) EncodeBebop(iow io.Writer) (err error) {
	w := iohelp.NewErrorWriter(iow)
	iohelp.WriteUint8(w, uint8(bbp.One))
	iohelp.WriteUint16(w, uint16(bbp.Two))
	iohelp.WriteUint32(w, uint32(bbp.Three))
	iohelp.WriteUint64(w, uint64(bbp.Four))
	iohelp.WriteInt16(w, int16(bbp.Five))
	iohelp.WriteInt32(w, int32(bbp.Six))
	iohelp.WriteInt64(w, int64(bbp.Seven))
	return w.Err
}

func (bbp *UsesAllEnums) DecodeBebop(ior io.Reader) (err error) {
	r := iohelp.NewErrorReader(ior)
	bbp.One = EnumU8(iohelp.ReadUint8(r))
	bbp.Two = EnumU16(iohelp.ReadUint16(r))
	bbp.Three = EnumU32(iohelp.ReadUint32(r))
	bbp.Four = EnumU64(iohelp.ReadUint64(r))
	bbp.Five = Enum16(iohelp.ReadInt16(r))
	bbp.Six = Enum32(iohelp.ReadInt32(r))
	bbp.Seven = Enum64(iohelp.ReadInt64(r))
	return r.Err
}

func (bbp *UsesAllEnums) Size() int {
	bodyLen := 0
	bodyLen += 1
	bodyLen += 2
	bodyLen += 4
	bodyLen += 8
	bodyLen += 2
	bodyLen += 4
	bodyLen += 8
	return bodyLen
}

func (bbp *UsesAllEnums) MarshalBebop() []byte {
	buf := make([]byte, bbp.Size())
	bbp.MarshalBebopTo(buf)
	return buf
}

func MakeUsesAllEnums(r *iohelp.ErrorReader) (UsesAllEnums, error) {
	v := UsesAllEnums{}
	err := v.DecodeBebop(r)
	return v, err
}

func MakeUsesAllEnumsFromBytes(buf []byte) (UsesAllEnums, error) {
	v := UsesAllEnums{}
	err := v.UnmarshalBebop(buf)
	return v, err
}

func MustMakeUsesAllEnumsFromBytes(buf []byte) UsesAllEnums {
	v := UsesAllEnums{}
	v.MustUnmarshalBebop(buf)
	return v
}

