func WithForceStructured(ctx context.Context) context.Context {
	return context.WithValue(context.WithValue(ctx, preferredEventEncoding, EncodingStructured), skipDirectBinaryEncoding, true)
}
WithForceStructured forces structured encoding during the encoding process
package binding
import (
	"context"
	"github.com/cloudevents/sdk-go/v2/event"
)
type eventEncodingKey int
const (
	skipDirectStructuredEncoding eventEncodingKey = iota
	skipDirectBinaryEncoding
	preferredEventEncoding
)
func DirectWrite(
	ctx context.Context,
	message MessageReader,
	structuredWriter StructuredWriter,
	binaryWriter BinaryWriter,
	transformers ...Transformer,
) (Encoding, error) {
	if structuredWriter != nil && len(transformers) == 0 && !GetOrDefaultFromCtx(ctx, skipDirectStructuredEncoding, false).(bool) {
		if err := message.ReadStructured(ctx, structuredWriter); err == nil {
			return EncodingStructured, nil
		} else if err != ErrNotStructured {
			return EncodingStructured, err
		}
	}
	if binaryWriter != nil && !GetOrDefaultFromCtx(ctx, skipDirectBinaryEncoding, false).(bool) && message.ReadEncoding() == EncodingBinary {
		return EncodingBinary, writeBinaryWithTransformer(ctx, message, binaryWriter, transformers)
	}
	return EncodingUnknown, ErrUnknownEncoding
}
func Write(
	ctx context.Context,
	message MessageReader,
	structuredWriter StructuredWriter,
	binaryWriter BinaryWriter,
	transformers ...Transformer,
) (Encoding, error) {
	enc := message.ReadEncoding()
	var err error
	if enc != EncodingEvent {
		enc, err = DirectWrite(ctx, message, structuredWriter, binaryWriter, transformers...)
		if enc != EncodingUnknown {
			return enc, err
		}
	}
	var e *event.Event
	e, err = ToEvent(ctx, message, transformers...)
	if err != nil {
		return enc, err
	}
	message = (*EventMessage)(e)
	if GetOrDefaultFromCtx(ctx, preferredEventEncoding, EncodingBinary).(Encoding) == EncodingStructured {
		if structuredWriter != nil {
			return EncodingStructured, message.ReadStructured(ctx, structuredWriter)
		}
		if binaryWriter != nil {
			return EncodingBinary, writeBinary(ctx, message, binaryWriter)
		}
	} else {
		if binaryWriter != nil {
			return EncodingBinary, writeBinary(ctx, message, binaryWriter)
		}
		if structuredWriter != nil {
			return EncodingStructured, message.ReadStructured(ctx, structuredWriter)
		}
	}
	return EncodingUnknown, ErrUnknownEncoding
}
func WithSkipDirectStructuredEncoding(ctx context.Context, skip bool) context.Context {
	return context.WithValue(ctx, skipDirectStructuredEncoding, skip)
}
func WithSkipDirectBinaryEncoding(ctx context.Context, skip bool) context.Context {
	return context.WithValue(ctx, skipDirectBinaryEncoding, skip)
}
func WithPreferredEventEncoding(ctx context.Context, enc Encoding) context.Context {
	return context.WithValue(ctx, preferredEventEncoding, enc)
}