grpcMarshallerOf

Available in a dev version: 0․11․0-grpc-186

How to configure

inline fun <T : Any> grpcMarshallerOf(config: GrpcMarshallerConfig? = null): GrpcMarshaller<T>(source)

Retrieves the GrpcMarshaller for the specified type T.

This function resolves the marshaller associated with type T through the WithGrpcMarshaller annotation.

If a config is provided, the returned marshaller will use it as the default GrpcMarshallerConfig for all encode/decode operations unless explicitly overridden. If the provided GrpcMarshallerConfig fits the marshaller's requirements, depends on the marshaller implementation.

Example:

val chatMarshaller = grpcMarshallerOf<ChatEntry>()
val encoded = chatMarshaller.encode(chatEntry)
val decoded = chatMarshaller.decode(buffer)

Return

A GrpcMarshaller instance for type T.

Parameters

config

Optional default GrpcMarshallerConfig to use for encoding and decoding operations.

Type Parameters

T

The message type for which to retrieve the marshaller. Must be annotated with WithGrpcMarshaller.

See also


fun <T : Any> grpcMarshallerOf(messageType: KType, config: GrpcMarshallerConfig? = null): GrpcMarshaller<T>(source)

Retrieves the GrpcMarshaller for the specified messageType.

This function resolves the marshaller associated with the messageType through the WithGrpcMarshaller annotation. The given messageType must match the type argument T.

If a config is provided, the returned marshaller will use it as the default GrpcMarshallerConfig for all encode/decode operations unless explicitly overridden. If the provided GrpcMarshallerConfig fits the marshaller's requirements, depends on the marshaller implementation.

Example:

val chatMarshaller = grpcMarshallerOf<ChatEntry>(typeOf<ChatEntry>())
val encoded = chatMarshaller.encode(chatEntry)
val decoded = chatMarshaller.decode(buffer)

Return

A GrpcMarshaller instance for type T.

Parameters

messageType

The message type KType of T for which to retrieve the marshaller. Must be annotated with WithGrpcMarshaller.

config

Optional default GrpcMarshallerConfig to use for encoding and decoding operations.

Type Parameters

T

The message type for which to retrieve the marshaller. Must be annotated with WithGrpcMarshaller.

See also


fun <T : Any> grpcMarshallerOf(messageClass: KClass<T>, config: GrpcMarshallerConfig? = null): GrpcMarshaller<T>(source)

Retrieves the GrpcMarshaller for the specified messageClass.

This function resolves the marshaller associated with the messageClass through the WithGrpcMarshaller annotation.

If a config is provided, the returned marshaller will use it as the default GrpcMarshallerConfig for all encode/decode operations unless explicitly overridden. If the provided GrpcMarshallerConfig fits the marshaller's requirements, depends on the marshaller implementation.

Example:

val chatMarshaller = grpcMarshallerOf(ChatEntry::class)
val encoded = chatMarshaller.encode(chatEntry)
val decoded = chatMarshaller.decode(buffer)

Return

A GrpcMarshaller instance for the messageClass.

Parameters

messageClass

The message type class T for which to retrieve the marshaller. Must be annotated with WithGrpcMarshaller.

config

Optional default GrpcMarshallerConfig to use for encoding and decoding operations.

Type Parameters

T

The message type for which to retrieve the marshaller.

See also