05nelsonm / encoding

A Kotlin Multiplatform library for configurable, streamable, efficient and extensible Encoding/Decoding with support for base16/32/64.
Apache License 2.0
33 stars 5 forks source link

Add ability to buffer output of `newEncoderFeed` and `newDecoderFeed` #133

Closed 05nelsonm closed 4 months ago

05nelsonm commented 1 year ago

e.g.

val sb = StringBuilder()

Base32.Default.newEncoderFeed(CharBufferOutFeed { buf, len ->
    sb.appendRange(buf, 0, len)
}).use { feed ->
    // ...
}
Base32.Default.newBufferedDecoderFeed(ByteBufferOutFeed(size = 8096) { buf, len ->
    // ...
}).use { feed ->
    // ..
}

Need to think about how this will play with the LineBreakOutFeed

05nelsonm commented 4 months ago

Closing. Primary reason for utilizing a Feed in the first place is to direct the output to the desired medium (file, http request, etc.). If a buffer is needed with a feed, caller can easily setup their own.