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

org.mattshoe.shoebox.kernl.runtime.DataResult.kt Maven / Gradle / Ivy

Go to download

Kernl: A Kotlin Symbol Processing (KSP) library for automatic repository generation.

The newest version!
package org.mattshoe.shoebox.kernl.runtime

/**
 * ### Encapsulates the result of a single non-invalidated data retrieval operation.
 *
 * Can be either [DataResult.Success] or [DataResult.Error]
 */
sealed interface ValidDataResult

/**
 * ### Encapsulates the result of a single unsuccessful data retrieval operation.
 *
 * Can be either [DataResult.Invalidated] or [DataResult.Error]
 */
sealed interface ErrorDataResult

/**
 * ### Encapsulates the result of a single data retrieval operation.
 *
 * Can be one of: [Success], [Error], [Invalidated].
 */
sealed interface DataResult {
    /**
     * Encapsulates the data of a successful data retrieval operation.
     */
    data class Success(val data: T): DataResult, ValidDataResult

    /**
     * Encapsulates an error encountered by a data retrieval operation.
     */
    data class Error(val error: Throwable): DataResult, ValidDataResult, ErrorDataResult

    /**
     * Representation of an invalidated cache. Meaning any previous data is invalid.
     */
    data class Invalidated(private val data: Unit = Unit): DataResult, ErrorDataResult
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy