add loadModule

This commit is contained in:
InsanusMokrassar 2020-02-13 16:32:30 +06:00
parent e6b4912835
commit a5bcddae6e
3 changed files with 19 additions and 0 deletions

View File

@ -3,6 +3,7 @@
## 0.1.2
* All reflection support methods are internal
* Added `lodModule` functions for more useful working with modules loading
## 0.1.1

View File

@ -0,0 +1,7 @@
package com.insanusmokrassar.sdi
import kotlinx.serialization.ImplicitReflectionSerializer
import kotlinx.serialization.json.Json
@ImplicitReflectionSerializer
fun loadModule(json: String): Module = Json.nonstrict.parse(Module.serializer(), json)

View File

@ -0,0 +1,11 @@
package com.insanusmokrassar.sdi
import kotlinx.io.InputStream
import kotlinx.serialization.ImplicitReflectionSerializer
import java.io.File
@ImplicitReflectionSerializer
fun loadModule(stream: InputStream) = loadModule(stream.reader().readText())
@ImplicitReflectionSerializer
fun loadModule(file: File) = loadModule(file.inputStream())