org.jetbrains.kotlinx.jupyter.repl.evalResults.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-jupyter-kernel Show documentation
Show all versions of kotlin-jupyter-kernel Show documentation
Kotlin Jupyter kernel published as artifact
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