-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A trimmed-down API #136
A trimmed-down API #136
Conversation
- Removed byte strings and ByteString related APIs - Moved some methods that were previously implemented as member functions to extensions, provided basic implementation - Get rid of hash functions and select API - Get rid of unsafe cursors - Removed a lot of commented out code - Enabled some previously disabled tests - Added tests covering line reading
May be then it will be sufficient to do something like this: public fun RawSource.buffered(): Source = when(this) {
is Source -> this
else -> RealSource(this)
} (same for sink) |
Always print data as hex, don't try decoding it as text.
@whyoleg I recommendation against a feature to prevent multiple buffer wrappers. We were occasionally tempted to do this for Okio! The runtime cost of redundant buffering is nearly zero. (This is a consequence of how data is moved and not copied between layers.) And it creates quite surprising behaviour consequences. For example it makes code that forgets to call ‘emit()’ or ‘flush()’ work sometimes when it shouldn’t. |
For me, it seems like both modes are legit - one may want to always wrap a |
98762c8
to
5171a28
Compare
@swankjesse after looking for a while on examples in kdoc of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for completion
@fzhinkin can you update preview documentation (https://github.com/fzhinkin/kotlinx-io-dokka-docs-preview) after all latest changes - it's much more easier to check all available public API there as members and extensions are there in one list and sorted by name ? |
@whyoleg done, thanks for reminding me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
Left a few minor comments, feel free to address them as you see fit
*/ | ||
fun cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seemed like this method was useful even without explicit asynchrony (and was, in fact, not related to coroutines-based cancellation); I might be mistaken though, anyway worth initiating the discussion
Reduced
kotlinx-io
API shape by removing all niche and specific APIs.Moved as many functions as possible to extensions, improved test coverage, and added documentation.
Docs generated for current branch are here: https://fzhinkin.github.io/kotlinx-io-dokka-docs-preview/
What changed compared to the previous preview version, in detail:
Sink::writeByte
andSink::writeShort
now acceptByte
andShort
instead ofInt
;Sink
,Source
, andBuffer
no longer implement ByteChannels on JVM; functions returning wrappers around instances of these classes and implementing ByteChannels were provided instead;DelicateIoApi
annotation, markedSink::buffer
,Sink::emitCompleteSegments
, andSource::buffer
with it;Kover
;Some issues were not addressed yet:
What's out of this change's scope and will be resolved later:
Closes #132