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

package fastpb_gen

import (
	fmt "fmt"
	fastpb "github.com/cloudwego/fastpb"
)

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

func (x *Base) 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 6:
		offset, err = x.fastReadField6(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_Base[number], err)
}

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

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

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

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

func (x *Base) fastReadField6(buf []byte, _type int8) (offset int, err error) {
	if x.Extra == nil {
		x.Extra = make(map[string]string)
	}
	var key string
	var value string
	offset, err = fastpb.ReadMapEntry(buf, _type,
		func(buf []byte, _type int8) (offset int, err error) {
			key, offset, err = fastpb.ReadString(buf, _type)
			return offset, err
		},
		func(buf []byte, _type int8) (offset int, err error) {
			value, offset, err = fastpb.ReadString(buf, _type)
			return offset, err
		})
	if err != nil {
		return offset, err
	}
	x.Extra[key] = value
	return offset, nil
}

func (x *BaseResp) 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
		}
	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_BaseResp[number], err)
}

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

func (x *BaseResp) fastReadField2(buf []byte, _type int8) (offset int, err error) {
	x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type)
	return offset, err
}

func (x *BaseResp) fastReadField3(buf []byte, _type int8) (offset int, err error) {
	if x.Extra == nil {
		x.Extra = make(map[string]string)
	}
	var key string
	var value string
	offset, err = fastpb.ReadMapEntry(buf, _type,
		func(buf []byte, _type int8) (offset int, err error) {
			key, offset, err = fastpb.ReadString(buf, _type)
			return offset, err
		},
		func(buf []byte, _type int8) (offset int, err error) {
			value, offset, err = fastpb.ReadString(buf, _type)
			return offset, err
		})
	if err != nil {
		return offset, err
	}
	x.Extra[key] = value
	return offset, nil
}

func (x *Base) 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.fastWriteField6(buf[offset:])
	return offset
}

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

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

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

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

func (x *Base) fastWriteField6(buf []byte) (offset int) {
	if x.Extra == nil {
		return offset
	}
	for k, v := range x.Extra {
		offset += fastpb.WriteMapEntry(buf[offset:], 6,
			func(buf []byte, numTagOrKey, numIdxOrVal int32) int {
				offset := 0
				offset += fastpb.WriteString(buf[offset:], numTagOrKey, k)
				offset += fastpb.WriteString(buf[offset:], numIdxOrVal, v)
				return offset
			})
	}
	return offset
}

func (x *BaseResp) 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:])
	return offset
}

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

func (x *BaseResp) fastWriteField2(buf []byte) (offset int) {
	if x.StatusCode == 0 {
		return offset
	}
	offset += fastpb.WriteInt32(buf[offset:], 2, x.StatusCode)
	return offset
}

func (x *BaseResp) fastWriteField3(buf []byte) (offset int) {
	if x.Extra == nil {
		return offset
	}
	for k, v := range x.Extra {
		offset += fastpb.WriteMapEntry(buf[offset:], 3,
			func(buf []byte, numTagOrKey, numIdxOrVal int32) int {
				offset := 0
				offset += fastpb.WriteString(buf[offset:], numTagOrKey, k)
				offset += fastpb.WriteString(buf[offset:], numIdxOrVal, v)
				return offset
			})
	}
	return offset
}

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

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

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

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

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

func (x *Base) sizeField6() (n int) {
	if x.Extra == nil {
		return n
	}
	for k, v := range x.Extra {
		n += fastpb.SizeMapEntry(6,
			func(numTagOrKey, numIdxOrVal int32) int {
				n := 0
				n += fastpb.SizeString(numTagOrKey, k)
				n += fastpb.SizeString(numIdxOrVal, v)
				return n
			})
	}
	return n
}

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

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

func (x *BaseResp) sizeField2() (n int) {
	if x.StatusCode == 0 {
		return n
	}
	n += fastpb.SizeInt32(2, x.StatusCode)
	return n
}

func (x *BaseResp) sizeField3() (n int) {
	if x.Extra == nil {
		return n
	}
	for k, v := range x.Extra {
		n += fastpb.SizeMapEntry(3,
			func(numTagOrKey, numIdxOrVal int32) int {
				n := 0
				n += fastpb.SizeString(numTagOrKey, k)
				n += fastpb.SizeString(numIdxOrVal, v)
				return n
			})
	}
	return n
}

var fieldIDToName_Base = map[int32]string{
	1: "LogID",
	2: "Caller",
	3: "Addr",
	4: "Client",
	6: "Extra",
}

var fieldIDToName_BaseResp = map[int32]string{
	1: "StatusMessage",
	2: "StatusCode",
	3: "Extra",
}
