package runtime

import (
	
	

	
)

// ProtoMarshaller is a Marshaller which marshals/unmarshals into/from serialize proto bytes
type ProtoMarshaller struct{}

// ContentType always returns "application/octet-stream".
func (*ProtoMarshaller) ( interface{}) string {
	return "application/octet-stream"
}

// Marshal marshals "value" into Proto
func (*ProtoMarshaller) ( interface{}) ([]byte, error) {
	,  := .(proto.Message)
	if ! {
		return nil, errors.New("unable to marshal non proto field")
	}
	return proto.Marshal()
}

// Unmarshal unmarshals proto "data" into "value"
func (*ProtoMarshaller) ( []byte,  interface{}) error {
	,  := .(proto.Message)
	if ! {
		return errors.New("unable to unmarshal non proto field")
	}
	return proto.Unmarshal(, )
}

// NewDecoder returns a Decoder which reads proto stream from "reader".
func ( *ProtoMarshaller) ( io.Reader) Decoder {
	return DecoderFunc(func( interface{}) error {
		,  := io.ReadAll()
		if  != nil {
			return 
		}
		return .Unmarshal(, )
	})
}

// NewEncoder returns an Encoder which writes proto stream into "writer".
func ( *ProtoMarshaller) ( io.Writer) Encoder {
	return EncoderFunc(func( interface{}) error {
		,  := .Marshal()
		if  != nil {
			return 
		}
		if ,  := .Write();  != nil {
			return 
		}

		return nil
	})
}