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

package email

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

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

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

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

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

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

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

func (x *EmailReq) fastReadField5(buf []byte, _type int8) (offset int, err error) {
	x.Content, offset, err = fastpb.ReadString(buf, _type)
	return offset, err
}

func (x *EmailResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
	switch number {
	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)
}

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

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

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

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

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

func (x *EmailReq) fastWriteField5(buf []byte) (offset int) {
	if x.Content == "" {
		return offset
	}
	offset += fastpb.WriteString(buf[offset:], 5, x.GetContent())
	return offset
}

func (x *EmailResp) FastWrite(buf []byte) (offset int) {
	if x == nil {
		return offset
	}
	return offset
}

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

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

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

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

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

func (x *EmailReq) sizeField5() (n int) {
	if x.Content == "" {
		return n
	}
	n += fastpb.SizeString(5, x.GetContent())
	return n
}

func (x *EmailResp) Size() (n int) {
	if x == nil {
		return n
	}
	return n
}

var fieldIDToName_EmailReq = map[int32]string{
	1: "From",
	2: "To",
	3: "ContentType",
	4: "Subject",
	5: "Content",
}

var fieldIDToName_EmailResp = map[int32]string{}
