---
source: crates/alef-backend-kotlin/tests/jni_emitter_test.rs
expression: client_content
---
// Generated by alef. Do not edit by hand.
@file:Suppress(
    "ktlint:standard:max-line-length",
    "ktlint:standard:trailing-comma-on-declaration-site",
    "ktlint:standard:trailing-comma-on-call-site",
    "ktlint:standard:annotation",
    "MaxLineLength",
    "TooManyFunctions",
    "LongParameterList",
    "LongMethod",
)

package dev.sample_crate

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

@Suppress("TooManyFunctions")
class DefaultClient internal constructor(internal val handle: Long) : AutoCloseable {
    companion object {
        private val MAPPER = com.fasterxml.jackson.databind.ObjectMapper()
            .registerModule(com.fasterxml.jackson.datatype.jdk8.Jdk8Module())
            .findAndRegisterModules()
            .setPropertyNamingStrategy(com.fasterxml.jackson.databind.PropertyNamingStrategies.SNAKE_CASE)
    }

    suspend fun speech(request: SpeechRequest): ByteArray {
        return withContext(Dispatchers.IO) { DemoBridge.nativeDefaultClientSpeech(handle, MAPPER.writeValueAsString(request)) }
    }

    override fun close() { DemoBridge.nativeFreeDefaultClient(handle) }
}
