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

org.jetbrains.kotlinx.jupyter.repl.evalResults.kt Maven / Gradle / Ivy

There is a newer version: 0.12.0-356
Show newest version
package org.jetbrains.kotlinx.jupyter.repl

import org.jetbrains.kotlinx.jupyter.OkResponseWithMessage
import org.jetbrains.kotlinx.jupyter.Response
import org.jetbrains.kotlinx.jupyter.api.FieldValue
import org.jetbrains.kotlinx.jupyter.api.Notebook
import org.jetbrains.kotlinx.jupyter.compiler.util.EvaluatedSnippetMetadata
import org.jetbrains.kotlinx.jupyter.toDisplayResult

data class InternalEvalResult(
    val result: FieldValue,
    val scriptInstance: Any,
)

data class EvalResult(
    val resultValue: Any?,
    val metadata: EvaluatedSnippetMetadata = EvaluatedSnippetMetadata.EMPTY
)

data class EvalResultEx(
    val rawValue: Any?,
    val renderedValue: Any?,
    val scriptInstance: Any,
    val resultFieldName: String?,
    val metadata: EvaluatedSnippetMetadata,
)

fun rawToResponse(value: Any?, notebook: Notebook, metadata: EvaluatedSnippetMetadata = EvaluatedSnippetMetadata.EMPTY): Response {
    return OkResponseWithMessage(value.toDisplayResult(notebook), metadata)
}

fun EvalResult.toResponse(notebook: Notebook): Response {
    return rawToResponse(resultValue, notebook, metadata)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy