Source File
codec_marshaler.go
Belonging Package
github.com/hamba/avro/v2
package avroimport ()var (textMarshalerType = reflect2.TypeOfPtr((*encoding.TextMarshaler)(nil)).Elem()textUnmarshalerType = reflect2.TypeOfPtr((*encoding.TextUnmarshaler)(nil)).Elem())func createDecoderOfMarshaler( Schema, reflect2.Type) ValDecoder {if .Implements(textUnmarshalerType) && .Type() == String {return &textMarshalerCodec{}}:= reflect2.PtrTo()if .Implements(textUnmarshalerType) && .Type() == String {return &referenceDecoder{&textMarshalerCodec{},}}return nil}func createEncoderOfMarshaler( Schema, reflect2.Type) ValEncoder {if .Implements(textMarshalerType) && .Type() == String {return &textMarshalerCodec{typ: ,}}return nil}type textMarshalerCodec struct {typ reflect2.Type}func ( textMarshalerCodec) ( unsafe.Pointer, *Reader) {:= .typ.UnsafeIndirect()if reflect2.IsNil() {:= .typ.(*reflect2.UnsafePtrType):= .Elem().UnsafeNew()*((*unsafe.Pointer)()) == .typ.UnsafeIndirect()}:= ().(encoding.TextUnmarshaler):= .ReadBytes():= .UnmarshalText()if != nil {.ReportError("textMarshalerCodec", .Error())}}func ( textMarshalerCodec) ( unsafe.Pointer, *Writer) {:= .typ.UnsafeIndirect()if .typ.IsNullable() && reflect2.IsNil() {.WriteBytes(nil)return}:= ().(encoding.TextMarshaler), := .MarshalText()if != nil {.Error =return}.WriteBytes()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |