RpcMethod
A wrapper around calling into or from stubs/serialization.
The optional metadata list carries sibling-annotation metadata captured by the ksrpc compiler plugin from annotations on the source method that are themselves annotated @KsMethodMetadata. Transport layers can read it to customize how a call is serialized.
The optional errorMappings list carries @KsError(code, type) bindings captured by the compiler plugin on the source method. Each entry pairs a wire-level integer code with the @Serializable payload type and its KSerializer. Runtime routing (see forwardErrorMap / reverseErrorMap) uses these to translate between thrown exception data and wire-level error envelopes.
The optional contextBindings list carries @KsContext-meta-annotated bindings captured by the compiler plugin from the source method and its enclosing @KsService interface. Each entry holds a KsContextBinding singleton used to propagate per-call coroutine-context values across the wire. See KsContextMapping for details.
Constructors
Properties
Forward lookup built from RpcMethod.errorMappings: code → mapping. Used by the client-side error-decoder to resolve an incoming wire-level code back to the captured KSerializer for deserializing the payload. Entries from later @KsError annotations that share a code overwrite earlier ones; duplicate codes on a single method are a programming error that transport validation can surface.
Reverse lookup built from RpcMethod.errorMappings: data::class → mapping. Used by the server-side error-encoder to resolve the thrown data::class back to its bound code + captured KSerializer. Later entries overwrite earlier ones for the same type.
Returns the timeout in milliseconds configured via @KsTimeout on the source method, or null if no timeout annotation was present.
Functions
Client-side: convert a CallData.Error into a Throwable using this method's forwardErrorMap. When CallData.Error.errorCode matches a @KsError binding and CallData.Error.errorData decodes successfully with the bound serializer, the deserialized typed Throwable itself is returned (and re-thrown by callChannel) — callers catch (e: MyError) typed.
Server-side: convert a thrown exception into a CallData.Error using this method's reverseErrorMap. The thrown class IS the wire payload's class — when the throwable's runtime class is assignable to a @KsError-bound type, the bound code + serializer are used and the throwable itself is encoded into the wire format S for inclusion in the error frame. There is no KsrpcException wrapper involved on the server side; users throw MyTypedError(...) directly.
Look up the captured sibling-annotation metadata with the given fully qualified annotation name, or null if the method was not annotated with such a sibling annotation.