github.com/trim21/go-phpserialize@v0.0.22-0.20240301204449-2fca0319b3f0/internal/decoder/invalid.go (about) 1 package decoder 2 3 import ( 4 "reflect" 5 "unsafe" 6 7 "github.com/trim21/go-phpserialize/internal/errors" 8 "github.com/trim21/go-phpserialize/internal/runtime" 9 ) 10 11 type invalidDecoder struct { 12 typ *runtime.Type 13 kind reflect.Kind 14 structName string 15 fieldName string 16 } 17 18 func newInvalidDecoder(typ *runtime.Type, structName, fieldName string) *invalidDecoder { 19 return &invalidDecoder{ 20 typ: typ, 21 kind: typ.Kind(), 22 structName: structName, 23 fieldName: fieldName, 24 } 25 } 26 27 func (d *invalidDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.Pointer) (int64, error) { 28 return 0, &errors.UnmarshalTypeError{ 29 Value: "object", 30 Type: runtime.RType2Type(d.typ), 31 Offset: cursor, 32 Struct: d.structName, 33 Field: d.fieldName, 34 } 35 }