Package-level declarations

Contains Core definitions of for configuring and constructing ksrpc services and stubs.

Contains Core definitions of for configuring and constructing ksrpc services and stubs.

Contains Core definitions of for configuring and constructing ksrpc services and stubs.

Contains Core definitions of for configuring and constructing ksrpc services and stubs.

Contains Core definitions of for configuring and constructing ksrpc services and stubs.

Types

Link copied to clipboard

Shared abstract base for transformers whose wire representation is a sub-service reference (a channel id registered on the host, resolved to a client stub on the peer). The base holds the register / lookup machinery operating on the service-facing type T; concrete subclasses adapt a (possibly different) user-facing type O to T via toService / fromService.

Link copied to clipboard

Marker for transformers whose wire representation is CallData.Binary / RpcBinaryData, regardless of the user-facing type they adapt. Consumers (e.g. introspection, diagnostics) should treat any implementor as "binary payload" rather than enumerating individual adapter objects.

Link copied to clipboard
Link copied to clipboard
fun interface ErrorListener

Interface used for handling any errors that occur during hosting.

Link copied to clipboard
interface KsrpcEnvironment<T>

Global configuration for KSRPC channels and services.

Link copied to clipboard
open class KsrpcException(val code: Int, val message: String, val data: Any? = null, cause: Throwable? = null) : RuntimeException

Base class for exceptions thrown by the ksrpc runtime.

Link copied to clipboard
interface Logger
Link copied to clipboard
sealed class MetadataValue

A typed wrapper for an argument captured into a MethodMetadata.

Link copied to clipboard
data class MethodMetadata(val annotationFqName: String, val arguments: List<Pair<String, MetadataValue>>)

A captured sibling annotation on a @KsMethod function.

Link copied to clipboard

Thrown when an endpoint cannot be found. Could happen from version mismatch or other programmer errors.

Link copied to clipboard

Wrapper around exceptions thrown in remote calls.

Link copied to clipboard
class RpcMethod<T : RpcService, I, O>(val endpoint: String, val inputTransform: Transformer<I>, val outputTransform: Transformer<O>, method: ServiceExecutor, val metadata: List<MethodMetadata>)

A wrapper around calling into or from stubs/serialization.

Link copied to clipboard
interface RpcObject<T : RpcService>

Interface for generated companions of RpcService.

Link copied to clipboard

Supertype of the generated companion for generic @KsService interfaces. Lets callers materialize an RpcObject for a concrete instantiation of the service when they only have KTypes (for example, reflective/introspection code or sub-service transformers).

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
expect annotation class RpcObjectKey(val rpcObject: KClass<*>)
@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class RpcObjectKey(val rpcObject: KClass<*>)

Used to find RpcObject of services in js implementations.

@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class RpcObjectKey(val rpcObject: KClass<*>)
@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class RpcObjectKey(val rpcObject: KClass<*>)

Used to find RpcObject of services in native implementations.

@Target(allowedTargets = [AnnotationTarget.CLASS])
actual annotation class RpcObjectKey(val rpcObject: KClass<*>)

Used to find RpcObject of services in js implementations.

Link copied to clipboard
class SerializerTransformer<I>(val serializer: KSerializer<I>) : Transformer<I>
Link copied to clipboard
Link copied to clipboard

Used for implementations of SuspendCloseable that need observers attached to be notified when SuspendCloseable.close is called.

Link copied to clipboard
interface Transformer<T>
Link copied to clipboard

Opt-in fallback for services that want to handle incoming RPC calls targeting method names that are not registered on the service.

Properties

Link copied to clipboard
Link copied to clipboard

Returns the timeout in milliseconds configured via @KsTimeout on the source method, or null if no timeout annotation was present.

Functions

Link copied to clipboard
fun ksrpcEnvironment(stringFormat: StringFormat = Json, builder: KsrpcEnvironmentBuilder<String>.() -> Unit): KsrpcEnvironment<String>
Link copied to clipboard

Convenience method for easily creating a copy of KsrpcEnvironment with a local error listener.

Link copied to clipboard

Creates a copy of the KsrpcEnvironment provided and allows changes to it before returning it. This method does NOT modify the original KsrpcEnvironment.

Link copied to clipboard
fun resolveSerializerOrThrow(type: KType, serviceName: String): KSerializer<Any?>

Resolve a KSerializer for type via kotlinx.serialization.serializer, converting any SerializationException into an IllegalArgumentException that names the offending service and type. Used by generated RpcObjectFactory.create bodies.

Link copied to clipboard
expect inline fun <T : RpcService> rpcObject(): RpcObject<T>

Helper to get RpcObject for a given RpcService

actual inline fun <T : RpcService> rpcObject(): RpcObject<T>
actual inline fun <T : RpcService> rpcObject(): RpcObject<T>

Resolve the RpcObject for T.

actual inline fun <T : RpcService> rpcObject(): RpcObject<T>
actual inline fun <T : RpcService> rpcObject(): RpcObject<T>
Link copied to clipboard

Convert a T into a SerializedService for hosting.

Link copied to clipboard

Build an RpcException carrying the stack captured in this RpcFailure.

Link copied to clipboard
inline fun <T : RpcService, S> SerializedService<S>.toStub(): T

Convert a SerializedService to a T for use as a client.

Link copied to clipboard
inline suspend fun <T : SuspendCloseable, R> T.use(usage: (T) -> R): R

Helper that runs usage then invokes SuspendCloseable.close in the finally block.