func (d decoder) unmarshalScalar(fd pref.FieldDescriptor) (pref.Value, error) {
	const b32 int = 32
	const b64 int = 64

	tok, err := d.Read()
	if err != nil {
		return pref.Value{}, err
	}

	kind := fd.Kind()
	switch kind {
	case pref.BoolKind:
		if tok.Kind() == json.Bool {
			return pref.ValueOfBool(tok.Bool()), nil
		}

	case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
		if v, ok := unmarshalInt(tok, b32); ok {
			return v, nil
		}

	case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
		if v, ok := unmarshalInt(tok, b64); ok {
			return v, nil
		}

	case pref.Uint32Kind, pref.Fixed32Kind:
		if v, ok := unmarshalUint(tok, b32); ok {
			return v, nil
		}

	case pref.Uint64Kind, pref.Fixed64Kind:
		if v, ok := unmarshalUint(tok, b64); ok {
			return v, nil
		}

	case pref.FloatKind:
		if v, ok := unmarshalFloat(tok, b32); ok {
			return v, nil
		}

	case pref.DoubleKind:
		if v, ok := unmarshalFloat(tok, b64); ok {
			return v, nil
		}

	case pref.StringKind:
		if tok.Kind() == json.String {
			return pref.ValueOfString(tok.ParsedString()), nil
		}

	case pref.BytesKind:
		if v, ok := unmarshalBytes(tok); ok {
			return v, nil
		}

	case pref.EnumKind:
		if v, ok := unmarshalEnum(tok, fd); ok {
			return v, nil
		}

	default:
		panic(fmt.Sprintf("unmarshalScalar: invalid scalar kind %v", kind))
	}

	return pref.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString())
}
// unmarshalScalar unmarshals to a scalar/enum protoreflect.Value specified by
// the given FieldDescriptor.
unmarshalScalar unmarshals to a scalar/enum protoreflect.Value specified by
the given FieldDescriptor.
// unmarshalScalar unmarshals to a scalar / enum protoreflect . Value specified by // the given FieldDescriptor .
func (d decoder) unmarshalScalar(fd pref.FieldDescriptor) (pref.Value, error) {
	const b32 int = 32
	const b64 int = 64
	tok, err := d.Read()
	if err != nil {
		return pref.Value{}, err
	}
	kind := fd.Kind()
	switch kind {
	case pref.BoolKind:
		if tok.Kind() == json.Bool {
			return pref.ValueOfBool(tok.Bool()), nil
		}
	case pref.Int32Kind, pref.Sint32Kind, pref.Sfixed32Kind:
		if v, ok := unmarshalInt(tok, b32); ok {
			return v, nil
		}
	case pref.Int64Kind, pref.Sint64Kind, pref.Sfixed64Kind:
		if v, ok := unmarshalInt(tok, b64); ok {
			return v, nil
		}
	case pref.Uint32Kind, pref.Fixed32Kind:
		if v, ok := unmarshalUint(tok, b32); ok {
			return v, nil
		}
	case pref.Uint64Kind, pref.Fixed64Kind:
		if v, ok := unmarshalUint(tok, b64); ok {
			return v, nil
		}
	case pref.FloatKind:
		if v, ok := unmarshalFloat(tok, b32); ok {
			return v, nil
		}
	case pref.DoubleKind:
		if v, ok := unmarshalFloat(tok, b64); ok {
			return v, nil
		}
	case pref.StringKind:
		if tok.Kind() == json.String {
			return pref.ValueOfString(tok.ParsedString()), nil
		}
	case pref.BytesKind:
		if v, ok := unmarshalBytes(tok); ok {
			return v, nil
		}
	case pref.EnumKind:
		if v, ok := unmarshalEnum(tok, fd); ok {
			return v, nil
		}
	default:
		panic(fmt.Sprintf("unmarshalScalar: invalid scalar kind %v", kind))
	}
	return pref.Value{}, d.newError(tok.Pos(), "invalid value for %v type: %v", kind, tok.RawString())
}
func ( d decoder ) unmarshalScalar ( fd pref . FieldDescriptor ) ( pref . Value , error ) { const b32 int = 32 const b64 int = 64 tok , err := d . Read ( ) if err != nil { return pref . Value { } , err } kind := fd . Kind ( ) switch kind { case pref . BoolKind : if tok . Kind ( ) == json . Bool { return pref . ValueOfBool ( tok . Bool ( ) ) , nil } case pref . Int32Kind , pref . Sint32Kind , pref . Sfixed32Kind : if v , ok := unmarshalInt ( tok , b32 ) ; ok { return v , nil } case pref . Int64Kind , pref . Sint64Kind , pref . Sfixed64Kind : if v , ok := unmarshalInt ( tok , b64 ) ; ok { return v , nil } case pref . Uint32Kind , pref . Fixed32Kind : if v , ok := unmarshalUint ( tok , b32 ) ; ok { return v , nil } case pref . Uint64Kind , pref . Fixed64Kind : if v , ok := unmarshalUint ( tok , b64 ) ; ok { return v , nil } case pref . FloatKind : if v , ok := unmarshalFloat ( tok , b32 ) ; ok { return v , nil } case pref . DoubleKind : if v , ok := unmarshalFloat ( tok , b64 ) ; ok { return v , nil } case pref . StringKind : if tok . Kind ( ) == json . String { return pref . ValueOfString ( tok . ParsedString ( ) ) , nil } case pref . BytesKind : if v , ok := unmarshalBytes ( tok ) ; ok { return v , nil } case pref . EnumKind : if v , ok := unmarshalEnum ( tok , fd ) ; ok { return v , nil } default : panic ( fmt . Sprintf ( " " , kind ) ) } return pref . Value { } , d . newError ( tok . Pos ( ) , " " , kind , tok . RawString ( ) ) }
unmarshalScalar unmarshals to a scalar/enum protoreflect.Value specified by
the given FieldDescriptor.
unmarshalScalar unmarshals to a scalar / enum protoreflect . Value specified by the given FieldDescriptor .