All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.app.cash.sqldelight.db.QueryResult.kt Maven / Gradle / Ivy

The newest version!
package app.cash.sqldelight.db

sealed interface QueryResult {
  val value: T get() = throw IllegalStateException(
    """
      The driver used with SQLDelight is asynchronous, so SQLDelight should be configured for
      asynchronous usage:

      sqldelight {
        MyDatabase {
          generateAsync = true
        }
      }
    """.trimIndent(),
  )

  suspend fun await(): T

  data class Value(override val value: T) : QueryResult {
    override suspend fun await() = value
  }

  class AsyncValue(private inline val getter: suspend () -> T) : QueryResult {
    override suspend fun await() = getter()
  }

  /**
   * A [QueryResult] representation of a Kotlin [Unit].
   *
   * Equivalent to `QueryResult.Value(Unit)`.
   */
  object Unit : QueryResult {
    override val value: kotlin.Unit = kotlin.Unit

    override suspend fun await() {
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy