// Code generated by Fastpb v0.0.2. DO NOT EDIT.

package checkout

import (
	fmt "fmt"
	order "github.com/BeroKiTeer/MyGoMall/common/kitex_gen/order"
	fastpb "github.com/cloudwego/fastpb"
)

var (
	_ = fmt.Errorf
	_ = fastpb.Skip
)

func (x *CheckoutReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
	switch number {
	case 1:
		offset, err = x.fastReadField1(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 2:
		offset, err = x.fastReadField2(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 3:
		offset, err = x.fastReadField3(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 4:
		offset, err = x.fastReadField4(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 5:
		offset, err = x.fastReadField5(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 6:
		offset, err = x.fastReadField6(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 7:
		offset, err = x.fastReadField7(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	default:
		offset, err = fastpb.Skip(buf, _type, number)
		if err != nil {
			goto SkipFieldError
		}
	}
	return offset, nil
SkipFieldError:
	return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
ReadFieldError:
	return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_CheckoutReq[number], err)
}

func (x *CheckoutReq) fastReadField1(buf []byte, _type int8) (offset int, err error) {
	x.UserId, offset, err = fastpb.ReadUint32(buf, _type)
	return offset, err
}

func (x *CheckoutReq) fastReadField2(buf []byte, _type int8) (offset int, err error) {
	x.Firstname, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *CheckoutReq) fastReadField3(buf []byte, _type int8) (offset int, err error) {
	x.Lastname, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *CheckoutReq) fastReadField4(buf []byte, _type int8) (offset int, err error) {
	x.Email, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *CheckoutReq) fastReadField5(buf []byte, _type int8) (offset int, err error) {
	var v order.Address
	offset, err = fastpb.ReadMessage(buf, _type, &v)
	if err != nil {
		return offset, err
	}
	x.Address = &v
	return offset, nil
}

func (x *CheckoutReq) fastReadField6(buf []byte, _type int8) (offset int, err error) {
	var v order.OrderItem
	offset, err = fastpb.ReadMessage(buf, _type, &v)
	if err != nil {
		return offset, err
	}
	x.Items = append(x.Items, &v)
	return offset, nil
}

func (x *CheckoutReq) fastReadField7(buf []byte, _type int8) (offset int, err error) {
	x.PaymentMethod, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *CheckoutResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
	switch number {
	case 1:
		offset, err = x.fastReadField1(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	case 2:
		offset, err = x.fastReadField2(buf, _type)
		if err != nil {
			goto ReadFieldError
		}
	default:
		offset, err = fastpb.Skip(buf, _type, number)
		if err != nil {
			goto SkipFieldError
		}
	}
	return offset, nil
SkipFieldError:
	return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
ReadFieldError:
	return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_CheckoutResp[number], err)
}

func (x *CheckoutResp) fastReadField1(buf []byte, _type int8) (offset int, err error) {
	x.OrderId, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *CheckoutResp) fastReadField2(buf []byte, _type int8) (offset int, err error) {
	x.Amount, offset, err = fastpb.ReadInt64(buf, _type)
	return offset, err
}

func (x *CheckoutReq) FastWrite(buf []byte) (offset int) {
	if x == nil {
		return offset
	}
	offset += x.fastWriteField1(buf[offset:])
	offset += x.fastWriteField2(buf[offset:])
	offset += x.fastWriteField3(buf[offset:])
	offset += x.fastWriteField4(buf[offset:])
	offset += x.fastWriteField5(buf[offset:])
	offset += x.fastWriteField6(buf[offset:])
	offset += x.fastWriteField7(buf[offset:])
	return offset
}

func (x *CheckoutReq) fastWriteField1(buf []byte) (offset int) {
	if x.UserId == 0 {
		return offset
	}
	offset += fastpb.WriteUint32(buf[offset:], 1, x.GetUserId())
	return offset
}

func (x *CheckoutReq) fastWriteField2(buf []byte) (offset int) {
	if x.Firstname == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 2, x.GetFirstname())
	return offset
}

func (x *CheckoutReq) fastWriteField3(buf []byte) (offset int) {
	if x.Lastname == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 3, x.GetLastname())
	return offset
}

func (x *CheckoutReq) fastWriteField4(buf []byte) (offset int) {
	if x.Email == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 4, x.GetEmail())
	return offset
}

func (x *CheckoutReq) fastWriteField5(buf []byte) (offset int) {
	if x.Address == nil {
		return offset
	}
	offset += fastpb.WriteMessage(buf[offset:], 5, x.GetAddress())
	return offset
}

func (x *CheckoutReq) fastWriteField6(buf []byte) (offset int) {
	if x.Items == nil {
		return offset
	}
	for i := range x.GetItems() {
		offset += fastpb.WriteMessage(buf[offset:], 6, x.GetItems()[i])
	}
	return offset
}

func (x *CheckoutReq) fastWriteField7(buf []byte) (offset int) {
	if x.PaymentMethod == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 7, x.GetPaymentMethod())
	return offset
}

func (x *CheckoutResp) FastWrite(buf []byte) (offset int) {
	if x == nil {
		return offset
	}
	offset += x.fastWriteField1(buf[offset:])
	offset += x.fastWriteField2(buf[offset:])
	return offset
}

func (x *CheckoutResp) fastWriteField1(buf []byte) (offset int) {
	if x.OrderId == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 1, x.GetOrderId())
	return offset
}

func (x *CheckoutResp) fastWriteField2(buf []byte) (offset int) {
	if x.Amount == 0 {
		return offset
	}
	offset += fastpb.WriteInt64(buf[offset:], 2, x.GetAmount())
	return offset
}

func (x *CheckoutReq) Size() (n int) {
	if x == nil {
		return n
	}
	n += x.sizeField1()
	n += x.sizeField2()
	n += x.sizeField3()
	n += x.sizeField4()
	n += x.sizeField5()
	n += x.sizeField6()
	n += x.sizeField7()
	return n
}

func (x *CheckoutReq) sizeField1() (n int) {
	if x.UserId == 0 {
		return n
	}
	n += fastpb.SizeUint32(1, x.GetUserId())
	return n
}

func (x *CheckoutReq) sizeField2() (n int) {
	if x.Firstname == "" {
		return n
	}
	n += fastpb.SizeString(2, x.GetFirstname())
	return n
}

func (x *CheckoutReq) sizeField3() (n int) {
	if x.Lastname == "" {
		return n
	}
	n += fastpb.SizeString(3, x.GetLastname())
	return n
}

func (x *CheckoutReq) sizeField4() (n int) {
	if x.Email == "" {
		return n
	}
	n += fastpb.SizeString(4, x.GetEmail())
	return n
}

func (x *CheckoutReq) sizeField5() (n int) {
	if x.Address == nil {
		return n
	}
	n += fastpb.SizeMessage(5, x.GetAddress())
	return n
}

func (x *CheckoutReq) sizeField6() (n int) {
	if x.Items == nil {
		return n
	}
	for i := range x.GetItems() {
		n += fastpb.SizeMessage(6, x.GetItems()[i])
	}
	return n
}

func (x *CheckoutReq) sizeField7() (n int) {
	if x.PaymentMethod == "" {
		return n
	}
	n += fastpb.SizeString(7, x.GetPaymentMethod())
	return n
}

func (x *CheckoutResp) Size() (n int) {
	if x == nil {
		return n
	}
	n += x.sizeField1()
	n += x.sizeField2()
	return n
}

func (x *CheckoutResp) sizeField1() (n int) {
	if x.OrderId == "" {
		return n
	}
	n += fastpb.SizeString(1, x.GetOrderId())
	return n
}

func (x *CheckoutResp) sizeField2() (n int) {
	if x.Amount == 0 {
		return n
	}
	n += fastpb.SizeInt64(2, x.GetAmount())
	return n
}

var fieldIDToName_CheckoutReq = map[int32]string{
	1: "UserId",
	2: "Firstname",
	3: "Lastname",
	4: "Email",
	5: "Address",
	6: "Items",
	7: "PaymentMethod",
}

var fieldIDToName_CheckoutResp = map[int32]string{
	1: "OrderId",
	2: "Amount",
}

var _ = order.File_order_proto
