Skip to main content

Class: DefaultPayloadConverterWithProtobufs

protobufs.DefaultPayloadConverterWithProtobufs

Tries to convert values to Payloads using the PayloadConverterWithEncodings provided to the constructor, in the order provided.

Converts Payloads to values based on the Payload.metadata.encoding field, which matches the PayloadConverterWithEncoding.encodingType of the converter that created the Payload.

Hierarchy​

Constructors​

constructor​

• new DefaultPayloadConverterWithProtobufs(«destructured»): DefaultPayloadConverterWithProtobufs

Parameters​

NameType
«destructured»DefaultPayloadConverterWithProtobufsOptions

Returns​

DefaultPayloadConverterWithProtobufs

Overrides​

CompositePayloadConverter.constructor

Properties​

converterByEncoding​

• Readonly converterByEncoding: Map<string, PayloadConverterWithEncoding>

Inherited from​

CompositePayloadConverter.converterByEncoding


converters​

• Readonly converters: PayloadConverterWithEncoding[]

Inherited from​

CompositePayloadConverter.converters

Methods​

fromPayload​

▸ fromPayload<T>(payload, context?, hint?): T

Run PayloadConverterWithEncoding.fromPayload based on the encoding metadata of the Payload.

Type parameters​

Name
T

Parameters​

NameType
payloadIPayload
context?SerializationContext
hint?ConverterHint<T>

Returns​

T

Inherited from​

CompositePayloadConverter.fromPayload


toPayload​

▸ toPayload<T>(value, context?, hint?): IPayload

Tries to run .toPayload(value) on each converter in the order provided at construction. Returns the first successful result, throws ValueError if there is no converter that can handle the value.

Type parameters​

Name
T

Parameters​

NameType
valueT
context?SerializationContext
hint?ConverterHint<T>

Returns​

IPayload

Inherited from​

CompositePayloadConverter.toPayload