package avro

import (
	
	

	
)

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()
}