ResultTransformer
Transformer emitted by the ksrpc compiler plugin for @KsMethod functions whose return type is kotlin.Result<O> (issue #133).
Result<O> is purely a client/server ergonomic transform over the existing O-method protocol — kotlin.Result itself is never serialized (it has no kotlinx serializer). On the wire a Result<O> method is byte-for-byte identical to a plain O method:
Server: a returned Result.success serializes the inner
Oexactly as a plainOmethod would (via inner); a returned Result.failure is encoded through the SAME@KsError/RpcMethod.encodeError path as a thrown exception, soResult.failure(e)is indistinguishable on the wire fromthrow e.Client: an error response decodes to Result.failure (NOT thrown); a success response decodes to Result.success. A
Result-returning stub never throws except for cancellation.Cancellation: CancellationException is never folded into the
Result— it propagates on both sides to preserve structured concurrency.
This type is @KsrpcInternal — user code does not reference it directly; the compiler plugin emits constructor calls to it in codegen.
Functions
Server-side boundary hook (issue #133). Invoked by RpcMethod.call with the value returned by the handler. The default implementation simply delegates to transform; transformers that need to observe the failure channel (e.g. ResultTransformer for Result<O> return types) override this to fold a returned failure into the wire-level error frame via encodeError.
Client-side boundary hook (issue #133). Invoked by RpcMethod.callChannel with the raw wire response (which may be a CallData.Error). The default implementation throws the decoded error — preserving today's behaviour — and otherwise delegates to untransform. ResultTransformer overrides this to wrap the outcome in a kotlin.Result instead of throwing.