in interface/src/main/kotlin/org/jetbrains/intellij/Connection.kt [27:37]
fun read(): Pair<R?, String> {
val raw = reader.readLine()
requireNotNull(raw) { "Read stream is closed" }
if (!raw.startsWith(identificator)) return null to raw
val message = raw.removePrefix(identificator)
val match = readTemplate.matchEntire(message)
requireNotNull(match) { "Expected: $readTemplate but was: $message" }
val (type, string) = match!!.destructured
val data = String(decoder.decode(string))
return getReadType(type) to data
}