withStdInOut

expect inline suspend fun withStdInOut(ksrpcEnvironment: KsrpcEnvironment<String>, withConnection: (Connection<String>) -> Unit)

Create a Connection that communicates over the std in/out streams of this process.

Samples

val env = ksrpcEnvironment { }
val service = object : GreetingService {
    override suspend fun greet(name: String): String = "Hello, $name!"
}

// withStdInOut creates a bidirectional Connection over stdin/stdout.
// This is useful for CLI tools that communicate via pipes.
withStdInOut(env) { connection ->
    connection.registerDefault(service.serialized(env))
    // Connection stays open until the process ends or the connection closes.
}
actual inline suspend fun withStdInOut(ksrpcEnvironment: KsrpcEnvironment<String>, withConnection: (Connection<String>) -> Unit)

Create a Connection that communicates over the std in/out streams of this process.

actual inline suspend fun withStdInOut(ksrpcEnvironment: KsrpcEnvironment<String>, withConnection: (Connection<String>) -> Unit)

Create a Connection that communicates over the std in/out streams of this process.

Samples

val env = ksrpcEnvironment { }
val service = object : GreetingService {
    override suspend fun greet(name: String): String = "Hello, $name!"
}

// withStdInOut creates a bidirectional Connection over stdin/stdout.
// This is useful for CLI tools that communicate via pipes.
withStdInOut(env) { connection ->
    connection.registerDefault(service.serialized(env))
    // Connection stays open until the process ends or the connection closes.
}
actual inline suspend fun withStdInOut(ksrpcEnvironment: KsrpcEnvironment<String>, withConnection: (Connection<String>) -> Unit)

Create a Connection that communicates over the std in/out streams of this process.

Samples

val env = ksrpcEnvironment { }
val service = object : GreetingService {
    override suspend fun greet(name: String): String = "Hello, $name!"
}

// withStdInOut creates a bidirectional Connection over stdin/stdout.
// This is useful for CLI tools that communicate via pipes.
withStdInOut(env) { connection ->
    connection.registerDefault(service.serialized(env))
    // Connection stays open until the process ends or the connection closes.
}
actual inline suspend fun withStdInOut(ksrpcEnvironment: KsrpcEnvironment<String>, withConnection: (Connection<String>) -> Unit)

Create a Connection that communicates over the std in/out streams of this process.