-
Notifications
You must be signed in to change notification settings - Fork 68
Description
On JVM target there is a strange (at the first glance) decision to make
Source.asInputStream(): InputStream
with InputStream.asSource(): RawSource
and
Sink.asOutputStream(): OutputStream
with OutputStream.asSink(): RawSink
Hence such simple and intuitive pipelines:
import kotlinx.io.Buffer
import kotlinx.io.Source
import kotlinx.io.asInputStream
import kotlinx.io.asOutputStream
import kotlinx.io.asSink
import kotlinx.io.asSource
fun main() {
Buffer().asInputStream().asSource().asInputStream()
Buffer().asOutputStream().asSink().asOutputStream()
}
are impossible (broken at the last chain link) with current API.
(Of cause I don't need to make such chains, but I care about API consistency and about ability to convert in/from InputStream easily)
I think it might be good to consider:
option 1)
refactor Source.asInputStream() -> RawSource.asInputStream()
refactor Sink.asOutputStream() -> RawSink.asOutputStream()
oprion 2)
rename InputStream.asSource(): RawSource -> InputStream.asRawSource(): RawSource
rename OutputStream.asSink(): RawSink -> OutputStream.asRawSink(): RawSink
add OutputStream.asSink(): Sink
add InputStream.asSource(): Source