diff --git a/.gitignore b/.gitignore
index e3813e39f..78d47efa0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,24 +1,3 @@
-build
-bin
.idea
*.iml
-.gradle
*.swp
-.project
-
-.kotlin
-
-kotlinx-io-native/repo/
-
-!.idea/vcs.xml
-!.idea/dictionaries
-!.idea/dictionaries/*
-!.idea/codeStyles
-!.idea/codeStyles/*
-
-.gradletasknamecache
-.settings
-.classpath
-
-logs
-
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index d7e1d1533..000000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/CHANGELOG-0.1.X.md b/CHANGELOG-0.1.X.md
deleted file mode 100644
index c5bd635f7..000000000
--- a/CHANGELOG-0.1.X.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# 0.1.5
-> Published 12 Feb 2019
-
-- `AbstractOutput` is implementable, simplified API
-- Fixed ISO-8859-1 and other character encodings on native
-- Fixed segfault caused by a wrong character encoding specified
-- Introduced initial unsigned types support (#28)
-- Introduced initial POSIX synchronous support (#34):
- - added `Input(fileDescriptor)` and `Output(fileDescriptor)`
- - added `read`, `write`, `fread`, `fwrite`, `send`, `receive`, `sendto`, `recvfrom`
- with `IoBuffer` parameter
-- Introduced initial `PosixException` support
-- Strengthened internal API restrictions
-- Introduced `Input.copyTo(Output)` utility function
-- Introduced multiplatform `IOException`
-- Introduced `reverseByteOrder` for primitive numeric types
-- Fixed several memory management bugs
-- Eliminated accidentally used JDK8+ API (#35)
-- Fixed loosing trailing bytes in byte channel on native and JS (
- [ktor/787](https://github.com/ktorio/ktor/issues/787),
- [ktor/920](https://github.com/ktorio/ktor/issues/920)
- )
-- Improved `readDirect`/`writeDirect` functions on platforms.
-- Fixed non-local returns from `use {}` block.
-- Kotlin 1.3.21
-
-# 0.1.4
-> Published 23 Jan 2019
-
-- Fixed byteOrder switch for packets (#30)
-- Upgrade to Gradle 4.10 with new metadata
-- Kotlin 1.3.20
-
-# 0.1.3
-> Published 25 Dec 2018
-
-- Fixed wrong pom dependencies
-
-# 0.1.2
-> Published 24 Dec 2018
-
-- Fixed byte channel constructor from an array
-- Fixed endGap related errors (#23)
-- Introduced suspending consumeEachRemaining (#22)
-- Kotlin 1.3.11, kotlinx.coroutines 1.1.0
-- Fixed await returned wrong result in sequential implementation (#24)
-- `await` and `awaitAtLeast` contract clarified (#24)
-- Fixed blocking I/O adapter to use coroutine's event loop
-
-# 0.1.1
-> Published 4 Dec 2018
-
-- Fixed ability to implement DefaultPool in common
-- Fixed error "Unable to stop reading in state Writing"
-- Fixed tryPeek implementation to not consume byte
-- Introduced peekCharUtf8
-- Added a cpointer constructor to native IoBuffer so that IoBuffer can be used to read AND write on a memory chunk
-- Made ByteChannel pass original cause from the owner job
-- Fixed reading UTF-8 lines
-- Fixed empty chunk view creation
-- Utility functions takeWhile* improvements
-
-# 0.1.0
-> Published 15 Nov 2018
-Initial release, maven central
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index ec7b69e5c..000000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,156 +0,0 @@
-# CHANGELOG
-
-## 0.5.4
-> Published 17 September 2024
-
-### Features
-- Extended Unsafe API with a function allowing to iterate over all Buffer's segments [#383](https://github.com/Kotlin/kotlinx-io/pull/383)
-- Implemented `ByteString` conversion to/from `NSData` on Apple platforms [#384](https://github.com/Kotlin/kotlinx-io/pull/384)
-- Implemented extensions to read/write `ByteString` from to/from `ByteBuffer`, as well as representing
- `ByteString` as a read-only `ByteBuffer` on JVM [#387](https://github.com/Kotlin/kotlinx-io/pull/387)
-- Implemented `ByteString` factory accepting unsigned bytes [#390](https://github.com/Kotlin/kotlinx-io/pull/390)
-- Reimplemented various functions using Unsafe API [#337](https://github.com/Kotlin/kotlinx-io/pull/337)
-- Minor documentation improvements
-
-## 0.5.3
-> Published 19 August 2024
-
-### Features
-- Updated JS `braces` library to `3.0.3`
-- More unnecessary backing fields were eliminated [#374](https://github.com/Kotlin/kotlinx-io/pull/374)
-
-## 0.5.2
-> Published 15 August 2024
-
-### Features
-- Unsafe API method signatures were updated to return number of written/read bytes [#360](https://github.com/Kotlin/kotlinx-io/issues/360)
-
- Note that it's a breaking change as return type is a part of method signature.
- However, updated methods are all inline, so in general,
- projects depending on libraries that were compiled against the previous version
- should not experience binary incompatibility issues after adding a dependency on a never `kotlinx-io` version.
-
-- Added call-in-place contracts to Unsafe API methods [#361](https://github.com/Kotlin/kotlinx-io/issues/361)
-- Updated Gradle and some dependencies [#353](https://github.com/Kotlin/kotlinx-io/pull/353)
-- Improved build scripts [#371](https://github.com/Kotlin/kotlinx-io/pull/371)
-- Removed the `Buffer.buffer` backing field [#366](https://github.com/Kotlin/kotlinx-io/pull/366)
-
-## 0.5.1
-> Published 15 July 2024
-
-### Bugfixes
-- Fixed a bug in segment pool implementation affecting a second level pool uses.
-
-## 0.5.0
-> Published 12 July 2024
-
-### Features
-- Provided an API allowing direct access to Buffer and Segment internals [#135](https://github.com/Kotlin/kotlinx-io/issues/135), [#166](https://github.com/Kotlin/kotlinx-io/issues/166)
-
- The API is unsafe, delisted from public docs and requires explicit opt-in. It's recommended to
- avoid this API unless you're working on integration with other APIs (like, `java.nio` or
- `io_uring`, for example).
-
-- Improved the way segment pooling is working on JVM [#352](https://github.com/Kotlin/kotlinx-io/pull/352)
-
- Now sharing a segment won't make an original segment and all its copies recyclable.
- Instead, the last remaining copy will be placed back into the pool when recycled.
- Segments are no longer allocated or lost when taking or recycling a segment from pool
- under a high contention due to concurrent requests.
- Size of the segment pool on the JVM could now be statically configured by setting a system property
- `kotlinx.io.pool.size.bytes`.
-
-## 0.4.0
-> Published 6 June 2024
-
-### Features
-- Updated Kotlin to 2.0 [#327](https://github.com/Kotlin/kotlinx-io/pull/327)
-
-## 0.3.5
-> Published 17 May 2024
-
-### Features
-- Provided an extension function to write `CharSequence`s (`Sink.writeString`) [#318](https://github.com/Kotlin/kotlinx-io/pull/318)
-- Various minor improvements in build scripts and docs
-
-## 0.3.4
-> Published 8 May 2024
-
-### Features
-- Kotlin updated to 1.9.24 [#315](https://github.com/Kotlin/kotlinx-io/pull/315)
-- Supported `linuxArm32Hfp` target [#303](https://github.com/Kotlin/kotlinx-io/issues/303)
-- Enabled KLib ABI validation
-- Provided extension functions to read (`Source.readCodePointValue`) and write (`Sink.writeCodePointValue`)
- Unicode code point values [#307](https://github.com/Kotlin/kotlinx-io/issues/307)
-- Provided function to list directories (`FileSystem.list`) [#222](https://github.com/Kotlin/kotlinx-io/issues/222)
-
-## 0.3.3
-> Published 22 Apr 2024
-
-### Features
-- Reimplemented file metadata gathering without required reasoning APIs on Apple targets [#297](https://github.com/Kotlin/kotlinx-io/pull/297)
-
-### Bugfixes
-- For JS target, Webpack should no longer report missing nodejs modules during compilation [#285](https://github.com/Kotlin/kotlinx-io/pull/285)
-
-## 0.3.2
-> Published 18 Mar 2024
-
-### Features
-- Implemented basic filesystem support for Wasm WASI target [#257](https://github.com/Kotlin/kotlinx-io/pull/257)
-- Enabled native benchmarks by default [#263](https://github.com/Kotlin/kotlinx-io/pull/263)
-
-## 0.3.1
-> Published 2 Feb 2024
-
-### Features
-- Updated Kotlin to `1.9.22`
-- Enabled Wasm Wasi target [#236](https://github.com/Kotlin/kotlinx-io/pull/236) (Note that neither of Wasm targets has filesystem support yet)
-- Support path resolution [#228](https://github.com/Kotlin/kotlinx-io/pull/228)
-
-### Bugfixes
-- Fixed `Path::parent` behavior on Windows [#227](https://github.com/Kotlin/kotlinx-io/pull/227)
-- Aligned behavior of `FileSystem::sink` and `FileSystem::source` across all platforms [#252](https://github.com/Kotlin/kotlinx-io/pull/252)
-- Fixed handling of paths containing a whitespace character [#248](https://github.com/Kotlin/kotlinx-io/pull/248)
-
-## 0.3.0
-> Published 13 Sep 2023
-
-### Features
-- Enabled Wasm target [#164](https://github.com/Kotlin/kotlinx-io/issues/164)
-- Added Sink/Source integration with Apple's NSInputStream and NSOutputStream ([#174](https://github.com/Kotlin/kotlinx-io/pull/174))
-- Added extension functions integrating ByteString with Base64 and HexFormat APIs ([#149](https://github.com/Kotlin/kotlinx-io/issues/149))
-- Added extension functions to read and write floating point numbers ([#167](https://github.com/Kotlin/kotlinx-io/issues/167))
-- Extended filesystems support by adding functions to create and delete files and directories, check their existence,
- perform atomic move, and get file size ([#211](https://github.com/Kotlin/kotlinx-io/issues/211),
- [#214](https://github.com/Kotlin/kotlinx-io/issues/214)).
- Also extended Path's API to request Path's parent and to get file's name
- ([#206](https://github.com/Kotlin/kotlinx-io/issues/206), [#212](https://github.com/Kotlin/kotlinx-io/issues/212)).
-- Updated Kotlin version to 1.9.10
-
-### Bugfixes
-- Fixed undefined behavior in the ByteString's hashCode computation on native targets ([#190](https://github.com/Kotlin/kotlinx-io/issues/190))
-- Fixed compatibility issues with Android API 25 and below ([#202](https://github.com/Kotlin/kotlinx-io/issues/202))
-
-## 0.2.1
-> Published 11 Jul 2023
-
-The release includes a bug fix solving the issue with dependency management.
-
-### Bugfixes
-- Fixed the dependency type for `bytesting` module,
- it is no longer required to explicitly specify it when using `kotlinx-io-core`
- ([#169](https://github.com/Kotlin/kotlinx-io/issues/169)).
-
-## 0.2.0
-> Published 3 Jul 2023
-
-Initial release of the new `kotlinx-io` version implemented based on `Okio` library.
-
-### Features
-- A trimmed-down and reworked version of the core Okio API
- ([#132](https://github.com/Kotlin/kotlinx-io/issues/132), [#137](https://github.com/Kotlin/kotlinx-io/issues/137))
-- ByteString implementation ([#133](https://github.com/Kotlin/kotlinx-io/issues/133))
-
----
-Changelog for previous versions may be found in [CHANGELOG-0.1.X.md](CHANGELOG-0.1.X.md)
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
deleted file mode 100644
index 85ed20dba..000000000
--- a/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,4 +0,0 @@
-## Code of Conduct
-
-This project and the corresponding community is governed by the [JetBrains Open Source and Community Code of Conduct](https://confluence.jetbrains.com/display/ALL/JetBrains+Open+Source+and+Community+Code+of+Conduct). Please make sure you read it.
-
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 73f83958a..000000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# Contributing Guidelines
-
-One can contribute to the project by reporting issues or submitting changes via pull request.
-
-## Reporting issues
-
-Please use [GitHub issues](https://github.com/Kotlin/kotlinx-io/issues) for filing feature requests and bug reports.
-
-Questions about usage and general inquiries are better suited for StackOverflow or the #io channel in KotlinLang Slack.
-
-## Submitting changes
-
-Submit pull requests [here](https://github.com/Kotlin/kotlinx-io/pulls).
-However, please keep in mind that maintainers will have to support the resulting code of the project,
-so do familiarize yourself with the following guidelines.
-
-* All development (both new features and bug fixes) is performed in the `develop` branch.
- * The `master` branch contains the sources of the most recently released version.
- * Base your PRs against the `develop` branch.
- * The `develop` branch is pushed to the `master` branch during release.
- * Documentation in markdown files can be updated directly in the `master` branch,
- unless the documentation is in the source code, and the patch changes line numbers.
-* If you make any code changes:
- * Follow the [Kotlin Coding Conventions](https://kotlinlang.org/docs/reference/coding-conventions.html).
- * Use 4 spaces for indentation.
- * Use imports with '*'.
- * [Build the project](#building) to make sure it all works and passes the tests.
-* If you fix a bug:
- * Write the test that reproduces the bug.
- * Fixes without tests are accepted only in exceptional circumstances if it can be shown that writing the
- corresponding test is too hard or otherwise impractical.
- * Follow the style of writing tests that is used in this project:
- name test functions as `testXxx`. Don't use backticks in test names.
-* Comment on the existing issue if you want to work on it. Ensure that the issue not only describes a problem, but also describes a solution that has received positive feedback. Propose a solution if none has been suggested.
-
-## Building
-
-This library is built with Gradle.
-
-* Run `./gradlew build` to build. It also runs all the tests.
-* Run `./gradlew :check` to test the module you are looking at to speed
- things up during development.
-* Run `./gradlew :jvmTest` to perform only the fast JVM tests of a multiplatform module.
-
-You can import this project into IDEA, but you have to delegate build actions
-to Gradle (in Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle -> Build and run).
-
-### Updating the public API dump
-
-* Use the [Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator/blob/master/README.md) for updates to public API:
- * Run `./gradlew apiDump` to update API index files.
- * Commit the updated API indexes together with other changes.
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index f5208f2f2..000000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- https://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 32ae3ac4f..000000000
--- a/NOTICE
+++ /dev/null
@@ -1,8 +0,0 @@
- =========================================================================
- == NOTICE file corresponding to the section 4 d of ==
- == the Apache License, Version 2.0, ==
- == in this case for the kotlinx-io library. ==
- =========================================================================
-
- kotlinx-io library.
- Copyright 2017-2023 JetBrains s.r.o and respective authors and developers
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index bca1c2c7a..000000000
--- a/README.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# kotlinx-io
-
-[![Kotlin Alpha](https://kotl.in/badges/alpha.svg)](https://kotlinlang.org/docs/components-stability.html)
-[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
-[![GitHub license](https://img.shields.io/github/license/kotlin/kotlinx-io)](LICENSE)
-[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-io-core)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-io-core/)
-[![Kotlin](https://img.shields.io/badge/kotlin-2.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
-[![TeamCity build](https://img.shields.io/teamcity/build/s/KotlinTools_KotlinxIo_BuildAggregated.svg?server=http%3A%2F%2Fteamcity.jetbrains.com)](https://teamcity.jetbrains.com/viewType.html?buildTypeId=KotlinTools_KotlinxIo_BuildAggregated&guest=1)
-[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlin.github.io/kotlinx-io/)
-
-A multiplatform Kotlin library providing basic IO primitives. `kotlinx-io` is based on [Okio](https://github.com/square/okio) but does not preserve backward compatibility with it.
-
-## Overview
-**kotlinx-io** is built around `Buffer` - a mutable sequence of bytes.
-
-`Buffer` works like a queue, allowing to read data from its head or to write data to its tail.
-`Buffer` provides functions to read and write data of different built-in types, and to copy data to or from other `Buffer`s.
-Depending on the target platform, extension functions allowing data exchange with platform-specific types are also available.
-
-A `Buffer` consists of segments organized as a linked list: segments allow reducing memory allocations during the buffer's expansion and copy,
-with the latter achieved by delegating or sharing the ownership over the underlying buffer's segments with other buffers.
-
-**kotlinx-io** provides interfaces representing data sources and destinations - `Source` and `Sink`,
-and in addition to the *mutable* `Buffer` the library also provides an *immutable* sequence of bytes - `ByteString`.
-
-An experimental filesystem support is shipped under the `kotlinx.io.files` package,
-which includes the `FileSystem` interface and its default implementation - `SystemFileSystem`.
-
-`FileSystem` provides basic operations for working with files and directories, which are represented by yet another class under the same package - `Path`.
-
-There are two `kotlinx-io` modules:
-- [kotlinx-io-bytestring](./bytestring) - provides `ByteString`.
-- [kotlinx-io-core](./core) - provides IO primitives (`Buffer`, `Source`, `Sink`), filesystems support, depends on `kotlinx-io-bytestring`.
-
-## Using in your projects
-
-> Note that the library is experimental, and the API is subject to change.
-
-### Gradle
-
-Make sure that you have `mavenCentral()` in the list of repositories:
-```kotlin
-repositories {
- mavenCentral()
-}
-```
-
-Add the library to dependencies:
-```kotlin
-dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.5.4")
-}
-```
-
-In multiplatform projects, add a dependency to the `commonMain` source set dependencies:
-```kotlin
-kotlin {
- sourceSets {
- commonMain {
- dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-io-core:0.5.4")
- }
- }
- }
-}
-```
-
-### Maven
-
-Add the library to dependencies:
-```xml
-
- org.jetbrains.kotlinx
- kotlinx-io-core-jvm
- 0.5.4
-
-```
-
-### Android
-
-`kotlinx-io` is not tested on Android on a regular basis,
-but the library is compatible with Android 5.0+ (API level 21+).
-
-## Contributing
-
-Read the [Contributing Guidelines](CONTRIBUTING.md).
-
-## Code of Conduct
-This project and the corresponding community are governed by the [JetBrains Open Source and Community Code of Conduct](https://confluence.jetbrains.com/display/ALL/JetBrains+Open+Source+and+Community+Code+of+Conduct). Please make sure you read it.
-
-## License
-kotlinx-io is licensed under the [Apache 2.0 License](LICENSE).
-
-## Credits
-
-Thanks to everyone involved in the project.
-
-An honorable mention goes to the developers of [Okio](https://square.github.io/okio/)
-that served as the foundation for `kotlinx-io` and to [Jesse Wilson](https://github.com/swankjesse),
-for the help with `Okio` adaption, his suggestions, assistance and guidance with `kotlinx-io` development.
diff --git a/benchmarks/README.md b/benchmarks/README.md
deleted file mode 100644
index dc2917d35..000000000
--- a/benchmarks/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# kotlinx-io benchmarks
-
-The module consists of benchmarks aimed to track performance of kotlinx-io implementation.
-
-Currently, the suite includes benchmarks on:
-- the core Buffer API usage: read/write primitive types, arrays, UTF8 strings;
-- basic `peek` usage;
-- segment pooling performance.
-
-The suite doesn't include benchmarks for more complex APIs inherited from Okio as these APIs are subject to change.
-Such benchmarks will be added later along with corresponding changes in the library.
-
-### Quickstart
-
-For JVM:
-```
-./gradlew :kotlinx-io-benchmarks:jvmJar
-
-java -jar benchmarks/build/benchmarks/jvm/jars/kotlinx-io-benchmarks-jvm-jmh-0.6.0-SNAPSHOT-JMH.jar ReadStringBenchmark -f 1 -wi 5 -i 5 -tu us -w 1 -r 1
-```
\ No newline at end of file
diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts
deleted file mode 100644
index e888a74da..000000000
--- a/benchmarks/build.gradle.kts
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import kotlinx.benchmark.gradle.JvmBenchmarkTarget
-import org.jetbrains.kotlin.konan.target.HostManager
-import org.jetbrains.kotlin.konan.target.KonanTarget
-
-plugins {
- kotlin("multiplatform")
- alias(libs.plugins.kotlinx.benchmark.plugin)
- id("kotlinx-io-clean")
-}
-
-kotlin {
- jvmToolchain {
- languageVersion = JavaLanguageVersion.of(libs.versions.java.get())
- }
-
- jvm()
-
- sourceSets {
- commonMain {
- dependencies {
- implementation(project(":kotlinx-io-core"))
- implementation(libs.kotlinx.benchmark.runtime)
- }
- }
-
- named("jvmMain") {
- dependsOn(commonMain.get())
- }
- }
-}
-
-val nativeBenchmarksEnabled: String by project.parent!!
-
-if (nativeBenchmarksEnabled.toBoolean()) {
- kotlin {
- // TODO: consider supporting non-host native targets.
- if (HostManager.host === KonanTarget.MACOS_X64) macosX64("native")
- if (HostManager.host === KonanTarget.MACOS_ARM64) macosArm64("native")
- if (HostManager.hostIsLinux) linuxX64("native")
- if (HostManager.hostIsMingw) mingwX64("native")
-
- sourceSets {
- named("nativeMain") {
- dependsOn(commonMain.get())
- }
- }
- }
-}
-
-benchmark {
- targets {
- register("jvm") {
- this as JvmBenchmarkTarget
- jmhVersion = libs.versions.jmh.get()
- }
- if (nativeBenchmarksEnabled.toBoolean()) {
- register("native")
- }
- }
-}
diff --git a/benchmarks/src/commonMain/kotlin/BufferOps.kt b/benchmarks/src/commonMain/kotlin/BufferOps.kt
deleted file mode 100644
index d835cdfc5..000000000
--- a/benchmarks/src/commonMain/kotlin/BufferOps.kt
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.*
-import kotlinx.io.*
-import kotlinx.io.bytestring.ByteString
-import kotlin.random.Random
-
-@State(Scope.Benchmark)
-abstract class BufferRWBenchmarkBase {
- // Buffers are implemented as a list of segments, as soon as a segment is empty
- // it will be unlinked. By reading all previously written data, a segment will be
- // cleared and recycled, and the next time we will try to write data, a new segment
- // will be requested from the pool. Thus, without having any data in-flight, we will
- // benchmark not only read/write ops performance, but also segments allocation/reclamation.
- // Specific non-zero minGap's values don't significantly affect overall results, but it is
- // left as the parameter to allow fine-tuning in the future.
- @Param("128")
- var minGap: Int = 0
-
- protected val buffer = Buffer()
-
- protected open fun padding(): ByteArray = ByteArray(minGap)
-
- @Setup
- fun setupBuffers() {
- val padding = padding()
- buffer.write(padding)
- }
-
- @TearDown
- fun clearBuffers() {
- buffer.clear()
- }
-}
-
-@State(Scope.Benchmark)
-open class ByteBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Byte {
- buffer.writeByte(0x42)
- return buffer.readByte()
- }
-}
-
-@State(Scope.Benchmark)
-open class ShortBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Short {
- buffer.writeShort(42)
- return buffer.readShort()
- }
-}
-
-@State(Scope.Benchmark)
-open class IntBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Int {
- buffer.writeInt(42)
- return buffer.readInt()
- }
-}
-
-@State(Scope.Benchmark)
-open class LongBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Long {
- buffer.writeLong(42)
- return buffer.readLong()
- }
-}
-
-@State(Scope.Benchmark)
-open class ShortLeBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Short {
- buffer.writeShortLe(42)
- return buffer.readShortLe()
- }
-}
-
-@State(Scope.Benchmark)
-open class IntLeBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Int {
- buffer.writeIntLe(42)
- return buffer.readIntLe()
- }
-}
-
-@State(Scope.Benchmark)
-open class LongLeBenchmark : BufferRWBenchmarkBase() {
- @Benchmark
- fun benchmark(): Long {
- buffer.writeLongLe(42)
- return buffer.readLongLe()
- }
-}
-
-@State(Scope.Benchmark)
-open class DecimalLongBenchmark : BufferRWBenchmarkBase() {
- @Param("-9223372036854775806", "9223372036854775806", "1")
- var value = 0L
-
- override fun padding(): ByteArray {
- return with(Buffer()) {
- while (size < minGap) {
- writeDecimalLong(value)
- // use space as a delimiter between consecutive decimal values
- writeByte(' '.code.toByte())
- }
- readByteArray()
- }
- }
-
- @Benchmark
- fun benchmark(): Long {
- // use space as a delimiter between consecutive decimal values
- buffer.writeDecimalLong(value)
- buffer.writeByte(' '.code.toByte())
- val l = buffer.readDecimalLong()
- buffer.readByte() // consume the delimiter
- return l
- }
-}
-
-@State(Scope.Benchmark)
-open class HexadecimalLongBenchmark : BufferRWBenchmarkBase() {
- @Param("9223372036854775806", "1")
- var value = 0L
-
- override fun padding(): ByteArray {
- return with(Buffer()) {
- while (size < minGap) {
- writeHexadecimalUnsignedLong(value)
- writeByte(' '.code.toByte())
- }
- readByteArray()
- }
- }
-
- @Benchmark
- fun benchmark(): Long {
- buffer.writeHexadecimalUnsignedLong(value)
- buffer.writeByte(' '.code.toByte())
- val l = buffer.readHexadecimalUnsignedLong()
- buffer.readByte()
- return l
- }
-}
-
-// This benchmark is based on Okio benchmark:
-// https://raw.githubusercontent.com/square/okio/master/okio/jvm/jmh/src/jmh/java/com/squareup/okio/benchmarks/BufferUtf8Benchmark.java
-@State(Scope.Benchmark)
-open class Utf8StringBenchmark : BufferRWBenchmarkBase() {
- private val strings = mapOf(
- "ascii" to ("Um, I'll tell you the problem with the scientific power that you're using here, "
- + "it didn't require any discipline to attain it. You read what others had done and you "
- + "took the next step. You didn't earn the knowledge for yourselves, so you don't take any "
- + "responsibility for it. You stood on the shoulders of geniuses to accomplish something "
- + "as fast as you could, and before you even knew what you had, you patented it, and "
- + "packaged it, and slapped it on a plastic lunchbox, and now you're selling it, you wanna "
- + "sell it."),
- "utf8" to
- ("Սm, I'll 𝓽𝖾ll ᶌօ𝘂 ᴛℎ℮ 𝜚𝕣०bl𝖾m wі𝕥𝒽 𝘵𝘩𝐞 𝓼𝙘𝐢𝔢𝓷𝗍𝜄𝚏𝑖c 𝛠𝝾w𝚎𝑟 𝕥h⍺𝞃 𝛄𝓸𝘂'𝒓𝗲 υ𝖘𝓲𝗇ɡ 𝕙𝚎𝑟e, "
- + "𝛊𝓽 ⅆ𝕚𝐝𝝿'𝗍 𝔯𝙚𝙦ᴜ𝜾𝒓𝘦 𝔞𝘯𝐲 ԁ𝜄𝑠𝚌ι𝘱lι𝒏e 𝑡𝜎 𝕒𝚝𝖙𝓪і𝞹 𝔦𝚝. 𝒀ο𝗎 𝔯𝑒⍺𝖉 w𝐡𝝰𝔱 𝞂𝞽һ𝓮𝓇ƽ հ𝖺𝖉 ⅾ𝛐𝝅ⅇ 𝝰πԁ 𝔂ᴑᴜ 𝓉ﮨ၀𝚔 "
- + "т𝒽𝑒 𝗇𝕖ⅹ𝚝 𝔰𝒕е𝓅. 𝘠ⲟ𝖚 𝖉ⅰԁ𝝕'τ 𝙚𝚊r𝞹 𝘵Ꮒ𝖾 𝝒𝐧هwl𝑒𝖉ƍ𝙚 𝓯૦r 𝔂𝞼𝒖𝕣𝑠𝕖l𝙫𝖊𝓼, 𐑈о y𝘰𝒖 ⅆە𝗇't 𝜏α𝒌𝕖 𝛂𝟉ℽ "
- + "𝐫ⅇ𝗌ⲣ๐ϖ𝖘ꙇᖯ𝓲l𝓲𝒕𝘆 𝐟𝞼𝘳 𝚤𝑡. 𝛶𝛔𝔲 s𝕥σσ𝐝 ﮩ𝕟 𝒕𝗁𝔢 𝘴𝐡𝜎ᴜlⅾ𝓮𝔯𝚜 𝛐𝙛 ᶃ𝚎ᴨᎥս𝚜𝘦𝓈 𝓽𝞸 a𝒄𝚌𝞸mρl𝛊ꜱ𝐡 𝓈𝚘m𝚎𝞃𝔥⍳𝞹𝔤 𝐚𝗌 𝖋a𝐬𝒕 "
- + "αs γ𝛐𝕦 𝔠ﻫ𝛖lԁ, 𝚊π𝑑 Ь𝑒𝙛૦𝓇𝘦 𝓎٥𝖚 ⅇvℯ𝝅 𝜅ո𝒆w w𝗵𝒂𝘁 ᶌ੦𝗎 h𝐚𝗱, 𝜸ﮨ𝒖 𝓹𝝰𝔱𝖾𝗇𝓽𝔢ⅆ і𝕥, 𝚊𝜛𝓭 𝓹𝖺ⅽϰ𝘢ℊеᏧ 𝑖𝞃, "
- + "𝐚𝛑ꓒ 𝙨l𝔞р𝘱𝔢𝓭 ɩ𝗍 ہ𝛑 𝕒 pl𝛂ѕᴛ𝗂𝐜 l𝞄ℼ𝔠𝒽𝑏ﮪ⨯, 𝔞ϖ𝒹 n𝛔w 𝛾𝐨𝞄'𝗿𝔢 ꜱ℮ll𝙞nɡ ɩ𝘁, 𝙮𝕠𝛖 w𝑎ℼ𝚗𝛂 𝕤𝓮ll 𝙞𝓉."),
- // The first 't' is actually a '𝓽'
- "sparse" to ("Um, I'll 𝓽ell you the problem with the scientific power that you're using here, "
- + "it didn't require any discipline to attain it. You read what others had done and you "
- + "took the next step. You didn't earn the knowledge for yourselves, so you don't take any "
- + "responsibility for it. You stood on the shoulders of geniuses to accomplish something "
- + "as fast as you could, and before you even knew what you had, you patented it, and "
- + "packaged it, and slapped it on a plastic lunchbox, and now you're selling it, you wanna "
- + "sell it."),
- "2bytes" to "\u0080\u07ff",
- "3bytes" to "\u0800\ud7ff\ue000\uffff",
- "4bytes" to "\ud835\udeca",
- // high surrogate, 'a', low surrogate, and 'a'
- "bad" to "\ud800\u0061\udc00\u0061"
- )
-
- @Param("20", "2000", "200000")
- var length = 0
-
- @Param("ascii", "utf8", "sparse", "2bytes", "3bytes", "4bytes", "bad")
- var encoding: String = "ascii"
-
- private var string: String = ""
-
- private fun constructString(): String {
- val part = strings[encoding] ?: throw IllegalArgumentException("Unsupported encoding: $encoding")
- val builder = StringBuilder(length + 1000)
- while (builder.length < length) {
- builder.append(part)
- }
- builder.setLength(length)
- return builder.toString()
- }
-
- override fun padding(): ByteArray {
- val baseString = constructString()
- val baseStringByteArray = baseString.encodeToByteArray()
- if (baseStringByteArray.size >= minGap) {
- return baseStringByteArray
- }
- val builder = StringBuilder((minGap * 1.5).toInt())
- while (builder.length < minGap) {
- builder.append(baseString)
- }
- return builder.toString().encodeToByteArray()
- }
-
- @Setup
- fun setupString() {
- string = constructString()
- }
-
- @Benchmark
- fun benchmark(): String {
- val s = buffer.size
- buffer.writeString(string)
- return buffer.readString(buffer.size - s)
- }
-}
-
-@State(Scope.Benchmark)
-open class Utf8LineBenchmarkBase : BufferRWBenchmarkBase() {
- @Param("17")
- var length: Int = 0
-
- @Param("LF", "CRLF")
- var separator: String = ""
-
- protected var string: String = ""
-
- private fun lineSeparator(): String = when (separator) {
- "LF" -> "\n"
- "CRLF" -> "\r\n"
- else -> throw IllegalArgumentException("Unsupported line separator type: $separator")
- }
-
- private fun constructString(): String = ".".repeat(length) + lineSeparator()
-
- override fun padding(): ByteArray {
- val string = constructString()
- if (string.length >= minGap) {
- return string.encodeToByteArray()
- }
- val builder = StringBuilder((minGap * 1.5).toInt())
- while (builder.length < minGap) {
- builder.append(string)
- }
- return builder.toString().encodeToByteArray()
- }
-
- @Setup
- fun setupString() {
- string = constructString()
- }
-}
-
-@State(Scope.Benchmark)
-open class Utf8LineBenchmark : Utf8LineBenchmarkBase() {
- @Benchmark
- fun benchmark(): String? {
- buffer.writeString(string)
- return buffer.readLine()
- }
-}
-
-@State(Scope.Benchmark)
-open class Utf8LineStrictBenchmark : Utf8LineBenchmarkBase() {
- @Benchmark
- fun benchmark(): String {
- buffer.writeString(string)
- return buffer.readLineStrict()
- }
-}
-
-private const val VALUE_TO_FIND: Byte = 1
-
-@State(Scope.Benchmark)
-open class IndexOfBenchmark {
- @Param(
- "128:0:-1", // scan a short sequence at the beginning of a segment, target value is not there
- "128:0:7", // scan a short sequence at the beginning of a segment, target value in the beginning
- "128:0:100", // scan a short sequence at the beginning of a segment, target value at the end
- "128:" + (SEGMENT_SIZE_IN_BYTES - 64).toString() + ":100", // scan two consecutive segments
- (SEGMENT_SIZE_IN_BYTES * 3).toString() + ":0:-1" // scan multiple segments
- )
- var params: String = "0:0:-1";
-
- private val buffer = Buffer()
-
- @Setup
- fun setupBuffers() {
- val paramsParsed = params.split(':').map { it.toInt() }.toIntArray()
- check(paramsParsed.size == 3) {
- "Parameters format is: \"dataSize:paddingSize:valueIndex\", " +
- "where valueIndex could be -1 if there should be no target value."
- }
- val dataSize = paramsParsed[0]
- val paddingSize = paramsParsed[1]
- val valueOffset = paramsParsed[2]
- check(paddingSize >= 0 && dataSize >= 0)
- check(valueOffset == -1 || valueOffset < dataSize)
-
- val array = ByteArray(dataSize)
- if (valueOffset >= 0) array[valueOffset] = VALUE_TO_FIND
-
- val padding = ByteArray(paddingSize)
- with(buffer) {
- write(padding)
- write(array)
- skip(paddingSize.toLong())
- }
- }
-
- @Benchmark
- fun benchmark(): Long = buffer.indexOf(VALUE_TO_FIND)
-}
-
-const val OFFSET_TO_2ND_BYTE_IN_2ND_SEGMENT = (SEGMENT_SIZE_IN_BYTES + 1).toString()
-
-@State(Scope.Benchmark)
-open class BufferGetBenchmark {
- private val buffer = Buffer()
-
- @Param("0", OFFSET_TO_2ND_BYTE_IN_2ND_SEGMENT)
- var offset: Long = 0
-
- @Setup
- fun fillBuffer() {
- buffer.write(ByteArray(offset.toInt() + 1))
- }
-
- @Benchmark
- fun get() = buffer[offset]
-}
-
-@State(Scope.Benchmark)
-open class BufferReadWriteByteArray : BufferRWBenchmarkBase() {
- private var inputArray = ByteArray(0)
- private var outputArray = ByteArray(0)
-
- @Param("1", "1024", (SEGMENT_SIZE_IN_BYTES * 3).toString())
- var size: Int = 0
-
- @Setup
- fun allocateArrays() {
- inputArray = ByteArray(size)
- outputArray = ByteArray(size)
- }
-
- @Benchmark
- fun benchmark(blackhole: Blackhole) {
- buffer.write(inputArray)
- buffer.readTo(outputArray)
- blackhole.consume(outputArray)
- }
-}
-
-@State(Scope.Benchmark)
-open class BufferReadNewByteArray : BufferRWBenchmarkBase() {
- private var inputArray = ByteArray(0)
-
- @Param("1", "1024", (SEGMENT_SIZE_IN_BYTES * 3).toString())
- var size: Int = 0
-
- @Setup
- fun allocateArray() {
- inputArray = ByteArray(size)
- }
-
- @Benchmark
- fun benchmark(): ByteArray {
- buffer.write(inputArray)
- return buffer.readByteArray(size)
- }
-}
-
-@State(Scope.Benchmark)
-open class IndexOfByteString {
- @Param("1024:2", "8192:2", "10000:2", "10000:8")
- var params: String = ":"
-
- private var buffer = Buffer()
- private var byteString = ByteString()
-
- @Setup
- fun setup() {
- val paramsParsed = params.split(':').map { it.toInt() }.toIntArray()
- require(paramsParsed.size == 2)
-
- val bufferSize = paramsParsed[0]
- val bsSize = paramsParsed[1]
- byteString = ByteString(ByteArray(bsSize) { 0x42 })
-
- for (idx in 0 until bufferSize) {
- if (idx % bsSize == 0) {
- buffer.writeByte(0)
- } else {
- buffer.writeByte(0x42)
- }
- }
- }
-
- @Benchmark
- fun benchmark() = buffer.indexOf(byteString)
-}
-
-@State(Scope.Benchmark)
-open class Utf8CodePointsBenchmark : BufferRWBenchmarkBase() {
- private val codePointsCount = 128
-
- // Encoding names follow naming from Utf8StringBenchmark
- @Param("ascii", "utf8", "sparse", "2bytes", "3bytes", "4bytes", "bad")
- var encoding: String = "ascii"
-
- override fun padding(): ByteArray {
- return ByteArray(minGap) { '.'.code.toByte() }
- }
-
- private val codePoints = IntArray(codePointsCount)
- private var codePointIdx = 0
-
- @Setup
- fun fillCodePointsArray() {
- fun IntArray.fill(generator: () -> Int) {
- for (idx in this.indices) {
- this[idx] = generator()
- }
- }
-
- when (encoding) {
- "ascii" -> codePoints.fill { Random.nextInt(' '.code, '~'.code) }
- "utf8" -> codePoints.fill {
- var cp: Int
- do {
- cp = Random.nextInt(0, 0x10ffff)
- } while (cp in 0xd800 .. 0xdfff)
- cp
- }
- "sparse" -> {
- codePoints.fill { Random.nextInt(' '.code, '~'.code) }
- codePoints[42] = '⌛'.code
- }
- "2bytes" -> codePoints.fill { Random.nextInt(0x80, 0x800) }
- "3bytes" -> codePoints.fill {
- var cp: Int
- do {
- cp = Random.nextInt(0x800, 0x10000)
- } while (cp in 0xd800 .. 0xdfff)
- cp
- }
- "4bytes" -> codePoints.fill { Random.nextInt(0x10000, 0x10ffff) }
- "bad" -> codePoints.fill { Random.nextInt(0xd800, 0xdfff) }
- }
- }
-
-
- private fun nextCodePoint(): Int {
- val idx = codePointIdx
- val cp = codePoints[idx]
- codePointIdx = (idx + 1) % codePointsCount
- return cp
- }
-
- @Benchmark
- fun benchmark(): Int {
- buffer.writeCodePointValue(nextCodePoint())
- return buffer.readCodePointValue()
- }
-}
diff --git a/benchmarks/src/commonMain/kotlin/Constants.kt b/benchmarks/src/commonMain/kotlin/Constants.kt
deleted file mode 100644
index c384fb1c2..000000000
--- a/benchmarks/src/commonMain/kotlin/Constants.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-const val SEGMENT_SIZE_IN_BYTES: Int = 8192
diff --git a/benchmarks/src/commonMain/kotlin/PeekBenchmark.kt b/benchmarks/src/commonMain/kotlin/PeekBenchmark.kt
deleted file mode 100644
index 1041e20c3..000000000
--- a/benchmarks/src/commonMain/kotlin/PeekBenchmark.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.*
-import kotlinx.io.Buffer
-import kotlinx.io.Source
-
-const val OFFSET_TO_LAST_BYTE_IN_SEGMENT = (SEGMENT_SIZE_IN_BYTES - 1).toString()
-
-@State(Scope.Benchmark)
-abstract class PeekBenchmark {
- protected val buffer = Buffer()
-
- // Use OFFSET_TO_LAST_BYTE_IN_SEGMENT to hit a border between
- // consecutive segments in benchmarks accessing multibyte values.
- @Param("0", OFFSET_TO_LAST_BYTE_IN_SEGMENT)
- var offset: Int = 0
-
- @Setup
- fun fillBuffer() {
- buffer.write(ByteArray(offset + 128))
- }
-
- protected fun peek(): Source {
- val peekSource = buffer.peek()
- peekSource.skip(offset.toLong())
- return peekSource
- }
-}
-
-@State(Scope.Benchmark)
-open class PeekByteBenchmark : PeekBenchmark() {
- @Benchmark
- fun benchmark() = peek().readByte()
-}
-
-@State(Scope.Benchmark)
-open class PeekShortBenchmark : PeekBenchmark() {
- @Benchmark
- fun benchmark() = peek().readShort()
-}
-
-@State(Scope.Benchmark)
-open class PeekIntBenchmark : PeekBenchmark() {
- @Benchmark
- fun benchmark() = peek().readInt()
-}
-
-@State(Scope.Benchmark)
-open class PeekLongBenchmark : PeekBenchmark() {
- @Benchmark
- fun benchmark() = peek().readLong()
-}
diff --git a/benchmarks/src/commonMain/kotlin/ReadStringBenchmark.kt b/benchmarks/src/commonMain/kotlin/ReadStringBenchmark.kt
deleted file mode 100644
index 1b1d15b98..000000000
--- a/benchmarks/src/commonMain/kotlin/ReadStringBenchmark.kt
+++ /dev/null
@@ -1,42 +0,0 @@
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.Benchmark
-import kotlinx.benchmark.Param
-import kotlinx.benchmark.Scope
-import kotlinx.benchmark.Setup
-import kotlinx.benchmark.State
-import kotlinx.io.Buffer
-import kotlinx.io.Source
-import kotlinx.io.readCodePointValue
-import kotlinx.io.readString
-import kotlinx.io.writeCodePointValue
-import kotlinx.io.writeString
-import kotlin.random.Random
-
-
-@State(Scope.Benchmark)
-open class ReadStringBenchmark() {
-
- @Param("16", "64", "512") // Fits into a single segment, so the benchmark does not measure segment boundaries crossing
- var size: Int = 0
-
- val buffer: Buffer = Buffer()
-
- @Setup
- fun setup() {
- val string = buildString { repeat(size) { append(('a'..'z').random()) } }
- buffer.writeString(string)
- }
-
-
- @Benchmark
- fun bufferReadString(): String {
- return buffer.copy().readString()
- }
-
- @Benchmark
- fun sourceReadString(): String {
- val source: Source = buffer.copy()
- return source.readString()
- }
-}
diff --git a/benchmarks/src/commonMain/kotlin/SegmentPoolBenchmark.kt b/benchmarks/src/commonMain/kotlin/SegmentPoolBenchmark.kt
deleted file mode 100644
index a3158d822..000000000
--- a/benchmarks/src/commonMain/kotlin/SegmentPoolBenchmark.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.io.*
-import kotlinx.benchmark.*
-
-@State(Scope.Benchmark)
-open class SegmentPoolBenchmark {
- private val buffer = Buffer()
-
- @Benchmark
- fun acquireReleaseCycle() {
- // write will request a new segment
- buffer.writeByte(0)
- // clear will recycle an old segment
- buffer.clear()
- }
-}
diff --git a/benchmarks/src/commonMain/kotlin/bytestring/ByteStringOps.kt b/benchmarks/src/commonMain/kotlin/bytestring/ByteStringOps.kt
deleted file mode 100644
index 7279ec2d9..000000000
--- a/benchmarks/src/commonMain/kotlin/bytestring/ByteStringOps.kt
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring.benchmarks
-
-import kotlinx.benchmark.*
-import kotlinx.io.bytestring.*
-import kotlin.math.min
-
-const val TARGET_BYTE: Byte = 42
-
-@State(Scope.Benchmark)
-abstract class IndexOfByteBenchmarkBase {
- @Param("128:-1", "128:0", "128:127", "128:63")
- var params: String = ":"
-
- protected var byteString = ByteString()
-
- @Setup
- fun setupByteString() {
- val paramsParsed = params.split(':').map { it.toInt() }.toIntArray()
- require(paramsParsed.size == 2)
- val size = paramsParsed[0]
- val targetByteIndex = paramsParsed[1]
-
-
- require(targetByteIndex == -1 || targetByteIndex in 0 until size)
- val data = ByteArray(size)
- if (targetByteIndex >= 0) {
- data[targetByteIndex] = TARGET_BYTE
- }
- byteString = ByteString(data)
- }
-}
-
-@State(Scope.Benchmark)
-open class IndexOfByteBenchmark : IndexOfByteBenchmarkBase() {
- @Benchmark
- fun benchmark() = byteString.indexOf(TARGET_BYTE)
-}
-
-@State(Scope.Benchmark)
-open class LastIndexOfByteBenchmark : IndexOfByteBenchmarkBase() {
- @Benchmark
- fun benchmark() = byteString.lastIndexOf(TARGET_BYTE)
-}
-
-@State(Scope.Benchmark)
-abstract class IndexOfByteStringBase {
- @Param("128:8:-1", "128:129:0", "128:8:0", "128:8:120", "128:8:63")
- var params: String = "::"
-
- protected var byteString = ByteString()
-
- protected var targetByteString = ByteString()
-
- @Setup
- fun setupByteString() {
- val paramsParsed = params.split(':').map { it.toInt() }.toIntArray()
- require(paramsParsed.size == 3)
- val size = paramsParsed[0]
- val patternLength = paramsParsed[1]
- val targetValueOffset = paramsParsed[2]
-
- require(size > 0)
- require(targetValueOffset == -1 || targetValueOffset in 0 until size)
-
- val data = ByteArray(size)
- if (targetValueOffset != -1) {
- for (idx in targetValueOffset until min(size, targetValueOffset + patternLength)) {
- data[idx] = TARGET_BYTE
- }
- }
- byteString = ByteString(data)
-
- targetByteString = ByteString(ByteArray(patternLength) { TARGET_BYTE })
- }
-}
-
-@State(Scope.Benchmark)
-open class IndexOfByteStringBenchmark : IndexOfByteStringBase() {
- @Benchmark
- fun benchmark() = byteString.indexOf(targetByteString)
-}
-
-@State(Scope.Benchmark)
-open class LastIndexOfByteStringBenchmark : IndexOfByteStringBase() {
- @Benchmark
- fun benchmark() = byteString.lastIndexOf(targetByteString)
-}
-
-@State(Scope.Benchmark)
-abstract class IndexOfByteStringWithRepeatedMismatchBase {
- @Param("128:8:2", "128:8:7")
- var params: String = "::"
-
- protected var byteString = ByteString()
-
- protected var targetByteString = ByteString()
-
- @Setup
- fun setup() {
- val paramsParsed = params.split(':').map { it.toInt() }.toIntArray()
- require(paramsParsed.size == 3)
- val size = paramsParsed[0]
- val patternLength = paramsParsed[1]
- val stride = paramsParsed[2]
- require(size > 0)
- require(patternLength > 0)
- require(stride in 1 until patternLength)
-
- val data = ByteArray(size) { TARGET_BYTE }
- val pattern = ByteArray(patternLength) { TARGET_BYTE }
- for (idx in data.indices) {
- if (idx % stride == 0) {
- data[idx] = 0
- }
- }
- byteString = ByteString(data)
- targetByteString = ByteString(pattern)
- }
-}
-
-@State(Scope.Benchmark)
-open class IndexOfByteStringWithRepeatedMismatch : IndexOfByteStringWithRepeatedMismatchBase() {
- @Benchmark
- fun benchmark() = byteString.indexOf(targetByteString)
-}
-
-@State(Scope.Benchmark)
-open class LastIndexOfByteStringWithRepeatedMismatch : IndexOfByteStringWithRepeatedMismatchBase() {
- @Benchmark
- fun benchmark() = byteString.lastIndexOf(targetByteString)
-}
-
-@State(Scope.Benchmark)
-
-abstract class StartsWithBenchmarkBase {
- protected abstract fun getRawParams(): String
-
- protected var byteString = ByteString()
-
- protected var targetByteString = ByteString()
-
- @Setup
- fun setup() {
- val paramsParsed = getRawParams().split(':').map { it.toInt() }.toIntArray()
- require(paramsParsed.size == 3)
- val size = paramsParsed[0]
- val patternLength = paramsParsed[1]
- val mismatchOffset = paramsParsed[2]
- require(size > 0)
- require(patternLength > 0)
- require(mismatchOffset == -1 || mismatchOffset in (0 until size))
-
- val data = ByteArray(size)
- val prefix = ByteArray(patternLength)
- if (mismatchOffset != -1) {
- data[mismatchOffset] = TARGET_BYTE
- }
- byteString = ByteString(data)
- targetByteString = ByteString(prefix)
- }
-}
-
-@State(Scope.Benchmark)
-open class StartsWithBenchmark : StartsWithBenchmarkBase() {
- @Param("128:8:-1", "128:8:0", "128:8:7")
- var params: String = "::"
-
- override fun getRawParams(): String = params
-
- @Benchmark
- fun benchmark() = byteString.startsWith(targetByteString)
-}
-
-@State(Scope.Benchmark)
-open class EndsWithBenchmark : StartsWithBenchmarkBase() {
- @Param("128:8:-1", "128:8:127", "128:8:120")
- var params: String = "::"
-
- override fun getRawParams(): String = params
-
- @Benchmark
- fun benchmark() = byteString.endsWith(targetByteString)
-}
-
-@State(Scope.Benchmark)
-
-abstract class ByteStringComparisonBenchmarkBase {
- @Param("128")
- var length: Int = 0
-
- @Param("-1", "63")
- var mismatchOffset = 0
-
- protected var stringA = ByteString()
- protected var stringB = ByteString()
-
- @Setup
- fun setup() {
- require(length > 0)
- require(mismatchOffset == -1 || mismatchOffset in 0 until length)
-
- stringA = ByteString(ByteArray(length))
- stringB = ByteString(ByteArray(length).apply {
- if (mismatchOffset != -1) {
- this[mismatchOffset] = TARGET_BYTE
- }
- })
- }
-}
-
-@State(Scope.Benchmark)
-open class CompareBenchmark : ByteStringComparisonBenchmarkBase() {
- @Benchmark
- fun benchmark() = stringA.compareTo(stringB)
-}
-
-@State(Scope.Benchmark)
-open class EqualsBenchmark : ByteStringComparisonBenchmarkBase() {
- @Param("true", "false")
- var useHashCode: Boolean = false
-
- @Setup
- fun computeHashCodes() {
- if (useHashCode) {
- stringA.hashCode()
- stringB.hashCode()
- }
- }
-
- @Benchmark
- fun benchmark() = stringA == stringB
-}
-
-@State(Scope.Benchmark)
-open class ByteStringHashCode {
- @Param("8", "128")
- var size: Int = 0
-
- @Param("true", "false")
- var recomputeOnEveryCall: Boolean = false
-
- private var byteString = ByteString()
-
- @Setup
- fun setupByteString() {
- require(size > 0) { "Invalid byte string size: $size" }
- val ba = ByteArray(size)
- if (recomputeOnEveryCall) {
- ba[0] = -31
- check(ba.contentHashCode() == 0) { "Hash code is non zero" }
- } else {
- check(ba.contentHashCode() != 0) { "Hash code is zero" }
- }
-
-
- byteString = ByteString(ba)
- }
-
- @Benchmark
- fun benchmark(): Int = byteString.hashCode()
-}
diff --git a/benchmarks/src/jvmMain/kotlin/ByteBufferBenchmarks.kt b/benchmarks/src/jvmMain/kotlin/ByteBufferBenchmarks.kt
deleted file mode 100644
index 0d1ea310f..000000000
--- a/benchmarks/src/jvmMain/kotlin/ByteBufferBenchmarks.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.Benchmark
-import kotlinx.benchmark.Param
-import kotlinx.benchmark.Setup
-import kotlinx.io.readAtMostTo
-import kotlinx.io.write
-import java.nio.ByteBuffer
-
-open class ByteBufferReadWrite : BufferRWBenchmarkBase() {
- private var inputBuffer = ByteBuffer.allocate(0)
- private var outputBuffer = ByteBuffer.allocate(0)
-
- @Param("1", "1024", (SEGMENT_SIZE_IN_BYTES * 3).toString())
- var size: Int = 0
-
- @Setup
- fun allocateBuffers() {
- inputBuffer = ByteBuffer.allocate(size)
- inputBuffer.put(ByteArray(size))
- outputBuffer = ByteBuffer.allocate(size)
- }
-
- @Benchmark
- fun benchmark(): ByteBuffer {
- inputBuffer.rewind()
- outputBuffer.clear()
- buffer.write(inputBuffer)
- while (buffer.readAtMostTo(outputBuffer) > 0) {
- // do nothing
- }
- return outputBuffer
- }
-}
diff --git a/benchmarks/src/jvmMain/kotlin/SegmentPoolBenchmarkMT.kt b/benchmarks/src/jvmMain/kotlin/SegmentPoolBenchmarkMT.kt
deleted file mode 100644
index 54141db50..000000000
--- a/benchmarks/src/jvmMain/kotlin/SegmentPoolBenchmarkMT.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.*
-import kotlinx.io.*
-import org.openjdk.jmh.annotations.Group
-import org.openjdk.jmh.annotations.GroupThreads
-
-@State(Scope.Benchmark)
-open class SegmentPoolBenchmarkMT {
- private fun testCycle(): Buffer {
- val buffer = Buffer()
- buffer.writeByte(0)
- buffer.clear()
- return buffer
- }
-
- @Benchmark
- @Group("ra1")
- @GroupThreads(1)
- fun acquireReleaseCycle() = testCycle()
-
- @Benchmark
- @Group("ra2")
- @GroupThreads(2)
- fun acquireReleaseCycle2() = testCycle()
-
- @Benchmark
- @Group("ra4")
- @GroupThreads(4)
- fun acquireReleaseCycle4() = testCycle()
-}
diff --git a/benchmarks/src/jvmMain/kotlin/StreamBenchmarks.kt b/benchmarks/src/jvmMain/kotlin/StreamBenchmarks.kt
deleted file mode 100644
index 52b90045a..000000000
--- a/benchmarks/src/jvmMain/kotlin/StreamBenchmarks.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.benchmarks
-
-import kotlinx.benchmark.Benchmark
-import kotlinx.benchmark.Blackhole
-import kotlinx.benchmark.Param
-import kotlinx.benchmark.Setup
-import kotlinx.io.asInputStream
-import kotlinx.io.asOutputStream
-import kotlinx.io.readTo
-
-open class InputStreamByteRead : BufferRWBenchmarkBase() {
- private val stream = buffer.asInputStream()
-
- @Benchmark
- fun benchmark(): Int {
- buffer.writeByte(0)
- return stream.read()
- }
-}
-
-open class OutputStreamByteWrite : BufferRWBenchmarkBase() {
- private val stream = buffer.asOutputStream()
-
- @Benchmark
- fun benchmark(): Byte {
- stream.write(0)
- return buffer.readByte()
- }
-}
-
-abstract class StreamByteArrayBenchmarkBase : BufferRWBenchmarkBase() {
- protected var inputArray = ByteArray(0)
- protected var outputArray = ByteArray(0)
-
- @Param("1", "128", SEGMENT_SIZE_IN_BYTES.toString())
- var size: Int = 0
-
- @Setup
- fun setupArray() {
- inputArray = ByteArray(size)
- outputArray = ByteArray(size)
- }
-}
-
-open class InputStreamByteArrayRead : StreamByteArrayBenchmarkBase() {
- private val stream = buffer.asInputStream()
-
- @Benchmark
- fun benchmark(blackhole: Blackhole) {
- buffer.write(inputArray)
- var offset = 0
- while (offset < outputArray.size) {
- offset += stream.read(outputArray, offset, outputArray.size - offset)
- }
- blackhole.consume(outputArray)
- }
-}
-
-open class OutputStreamByteArrayWrite : StreamByteArrayBenchmarkBase() {
- private val stream = buffer.asOutputStream()
-
- @Benchmark
- fun benchmark(blackhole: Blackhole) {
- stream.write(outputArray)
- buffer.readTo(inputArray)
- blackhole.consume(inputArray)
- }
-}
diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts
deleted file mode 100644
index c26e65a27..000000000
--- a/build-logic/build.gradle.kts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-plugins {
- `kotlin-dsl`
-}
-
-repositories {
- mavenCentral()
-}
-
-dependencies {
- implementation(libs.kotlin.gradle.plugin)
- implementation(libs.dokka.gradle.plugin)
- implementation(libs.animalsniffer.gradle.plugin)
-}
-
-kotlin {
- jvmToolchain(JavaLanguageVersion.of(libs.versions.java.get()).asInt())
-}
diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts
deleted file mode 100644
index 4b401d8b7..000000000
--- a/build-logic/settings.gradle.kts
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-plugins {
- id("org.gradle.toolchains.foojay-resolver-convention") version ("0.8.0")
-}
-
-dependencyResolutionManagement {
- versionCatalogs {
- create("libs") {
- from(files("../gradle/libs.versions.toml"))
- }
- }
-}
diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-android-compat.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-android-compat.gradle.kts
deleted file mode 100644
index 948857618..000000000
--- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-android-compat.gradle.kts
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
-
-pluginManager.withPlugin("org.gradle.java-base") {
- apply(plugin = "ru.vyarus.animalsniffer")
-
- configure {
- sourceSets = listOf((project.extensions.getByName("sourceSets") as SourceSetContainer).getByName("main"))
- }
- val signature: Configuration by configurations
- dependencies {
- // Use the same API level as OkHttp
- signature("net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature")
- }
-}
diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-clean.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-clean.gradle.kts
deleted file mode 100644
index 65d319693..000000000
--- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-clean.gradle.kts
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-plugins {
- base
-}
-
-tasks.clean {
- // Workaround for https://youtrack.jetbrains.com/issue/KT-58303:
- // the `clean` task can't delete the expanded.lock file on Windows as it's still held by Gradle, failing the build
- setDelete(layout.buildDirectory.asFileTree.matching {
- exclude("tmp/.cache/expanded/expanded.lock")
- })
-}
-
diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts
deleted file mode 100644
index fc50ede2c..000000000
--- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-dokka.gradle.kts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-import org.jetbrains.dokka.gradle.DokkaTaskPartial
-import java.net.URL
-
-plugins {
- id("org.jetbrains.dokka")
-}
-
-tasks.withType().configureEach {
- dokkaSourceSets.configureEach {
- includes.from("Module.md")
-
- sourceLink {
- localDirectory = rootDir
- remoteUrl = URL("https://github.com/kotlin/kotlinx-io/tree/master")
- remoteLineSuffix = "#L"
- }
-
- // we don't want to advertise `unsafe` APIs in documentation
- perPackageOption {
- suppress = true
- matchingRegex = ".*unsafe.*"
- }
-
- // as in kotlinx-io-multiplatform.gradle.kts:configureSourceSet
- val platform = name.dropLast(4)
- samples.from(
- "common/test/samples",
- "$platform/test/samples"
- )
- }
-}
diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts
deleted file mode 100644
index 5ac3098b8..000000000
--- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
-import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
-import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
-import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
-import kotlin.jvm.optionals.getOrNull
-
-plugins {
- kotlin("multiplatform")
- id("kotlinx-io-clean")
-}
-
-kotlin {
- @OptIn(ExperimentalKotlinGradlePluginApi::class)
- compilerOptions {
- allWarningsAsErrors = true
- freeCompilerArgs.add("-Xexpect-actual-classes")
- }
-
- val versionCatalog: VersionCatalog = extensions.getByType().named("libs")
- jvmToolchain {
- val javaVersion = versionCatalog.findVersion("java").getOrNull()?.requiredVersion
- ?: throw GradleException("Version 'java' is not specified in the version catalog")
- languageVersion = JavaLanguageVersion.of(javaVersion)
- }
-
- jvm {
- withJava()
- testRuns["test"].executionTask.configure {
- useJUnitPlatform()
- }
- // can be replaced with just `compilerOptions { }` in Kotlin 2.0
- compilations.configureEach {
- compileTaskProvider.configure {
- compilerOptions {
- freeCompilerArgs.add("-Xjvm-default=all")
- }
- }
- }
- }
-
- js {
- browser {
- testTask {
- filter.setExcludePatterns("*SmokeFileTest*")
- }
- }
- }
-
- @OptIn(ExperimentalWasmDsl::class)
- wasmJs {
- nodejs()
- // Disabled because we can't exclude some tests: https://youtrack.jetbrains.com/issue/KT-58291
- // browser()
- }
-
- @OptIn(ExperimentalWasmDsl::class)
- wasmWasi {
- nodejs()
- }
-
- nativeTargets()
-
- sourceSets {
- commonTest.dependencies {
- implementation(kotlin("test"))
- }
- }
-
- explicitApi()
- sourceSets.configureEach {
- configureSourceSet()
- }
-
- @OptIn(ExperimentalKotlinGradlePluginApi::class)
- applyDefaultHierarchyTemplate {
- common {
- group("native") {
- group("nativeNonApple") {
- group("mingw")
- group("unix") {
- group("linux")
- group("androidNative")
- }
- }
-
- group("nativeNonAndroid") {
- group("apple")
- group("mingw")
- group("linux")
- }
- }
- group("nodeFilesystemShared") {
- withJs()
- withWasmJs()
- }
- group("wasm") {
- withWasmJs()
- withWasmWasi()
- }
- }
- }
-}
-
-fun KotlinSourceSet.configureSourceSet() {
- val srcDir = if (name.endsWith("Main")) "src" else "test"
- val platform = name.dropLast(4)
- kotlin.srcDir("$platform/$srcDir")
- if (name == "jvmMain") {
- resources.srcDir("$platform/resources")
- } else if (name == "jvmTest") {
- resources.srcDir("$platform/test-resources")
- }
- languageSettings {
- progressiveMode = true
- }
-}
-
-private fun KotlinMultiplatformExtension.nativeTargets() {
- iosX64()
- iosArm64()
- iosSimulatorArm64()
-
- tvosX64()
- tvosArm64()
- tvosSimulatorArm64()
-
- watchosArm32()
- watchosArm64()
- watchosX64()
- watchosSimulatorArm64()
- watchosDeviceArm64()
-
- androidNativeArm32()
- androidNativeArm64()
- androidNativeX64()
- androidNativeX86()
-
- linuxX64()
- linuxArm64()
- @Suppress("DEPRECATION") // https://github.com/Kotlin/kotlinx-io/issues/303
- linuxArm32Hfp()
-
- macosX64()
- macosArm64()
-
- mingwX64()
-}
diff --git a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-publish.gradle.kts b/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-publish.gradle.kts
deleted file mode 100644
index 6f6765dc8..000000000
--- a/build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-publish.gradle.kts
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-import org.gradle.jvm.tasks.Jar
-import java.net.URI
-
-plugins {
- `maven-publish`
- signing
-}
-
-publishing {
- repositories {
- configureMavenPublication(project)
- }
-
- val javadocJar = project.configureEmptyJavadocArtifact()
- publications.withType(MavenPublication::class).all {
- pom.configureMavenCentralMetadata(project)
- signPublicationIfKeyPresent(project, this)
- artifact(javadocJar)
- }
-
- tasks.withType().configureEach {
- dependsOn(tasks.withType())
- }
-}
-
-fun MavenPom.configureMavenCentralMetadata(project: Project) {
- name = project.name
- description = "IO support for Kotlin"
- url = "https://github.com/Kotlin/kotlinx-io"
-
- licenses {
- license {
- name = "The Apache Software License, Version 2.0"
- url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
- distribution = "repo"
- }
- }
-
- developers {
- developer {
- id = "JetBrains"
- name = "JetBrains Team"
- organization = "JetBrains"
- organizationUrl = "https://www.jetbrains.com"
- }
- }
-
- scm {
- url = "https://github.com/Kotlin/kotlinx-io"
- }
-}
-
-fun MavenPublication.mavenCentralArtifacts(project: Project, sources: SourceDirectorySet) {
- val sourcesJar by project.tasks.creating(Jar::class) {
- archiveClassifier = "sources"
- from(sources)
- }
- val javadocJar by project.tasks.creating(Jar::class) {
- archiveClassifier = "javadoc"
- // contents are deliberately left empty
- }
- artifact(sourcesJar)
- artifact(javadocJar)
-}
-
-
-fun mavenRepositoryUri(): URI {
- val repositoryId: String? = System.getenv("libs.repository.id")
- return if (repositoryId == null) {
- URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
- } else {
- URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId")
- }
-}
-
-fun RepositoryHandler.configureMavenPublication( project: Project) {
- maven {
- url = mavenRepositoryUri()
- credentials {
- username = project.getSensitiveProperty("libs.sonatype.user")
- password = project.getSensitiveProperty("libs.sonatype.password")
- }
- }
-
- // Something that's easy to "clean" for development not mavenLocal
- maven(project.rootProject.layout.buildDirectory.dir("repo")) {
- name = "buildRepo"
- }
-}
-
-fun Project.configureEmptyJavadocArtifact(): Jar {
- val javadocJar by project.tasks.creating(Jar::class) {
- archiveClassifier = "javadoc"
- // contents are deliberately left empty
- }
- return javadocJar
-}
-
-fun signPublicationIfKeyPresent(project: Project, publication: MavenPublication) {
- val keyId = project.getSensitiveProperty("libs.sign.key.id")
- val signingKey = project.getSensitiveProperty("libs.sign.key.private")
- val signingKeyPassphrase = project.getSensitiveProperty("libs.sign.passphrase")
- if (!signingKey.isNullOrBlank()) {
- project.extensions.configure("signing") {
- useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase)
- sign(publication)
-
- // Temporary workaround, see https://github.com/gradle/gradle/issues/26091#issuecomment-1722947958
- tasks.withType().configureEach {
- val signingTasks = tasks.withType()
- mustRunAfter(signingTasks)
- }
- }
- }
-}
-
-fun Project.getSensitiveProperty(name: String): String? {
- return project.findProperty(name) as? String ?: System.getenv(name)
-}
diff --git a/build.gradle.kts b/build.gradle.kts
deleted file mode 100644
index 8d99e3da8..000000000
--- a/build.gradle.kts
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2017-2023 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
- */
-
-import kotlinx.kover.gradle.plugin.dsl.CoverageUnit
-import kotlinx.validation.ExperimentalBCVApi
-
-plugins {
- id("kotlinx-io-publish") apply false
-
- alias(libs.plugins.kover)
- alias(libs.plugins.bcv)
- alias(libs.plugins.dokka)
-}
-
-allprojects {
- properties["DeployVersion"]?.let { version = it }
- repositories {
- mavenCentral()
- }
-}
-
-@OptIn(ExperimentalBCVApi::class)
-apiValidation {
- ignoredProjects.addAll(listOf(
- "kotlinx-io-benchmarks",
- "kotlinx-io-smoke-tests"
- ))
- klib.enabled = true
-}
-
-dependencies {
- kover(project(":kotlinx-io-core"))
- kover(project(":kotlinx-io-bytestring"))
-}
-
-kover {
- reports {
- verify {
- rule {
- minBound(95, CoverageUnit.LINE)
-
- // we allow lower branch coverage, because not all checks in the internal code lead to errors
- minBound(80, CoverageUnit.BRANCH)
- }
- }
- }
-}
diff --git a/bytestring/Module.md b/bytestring/Module.md
deleted file mode 100644
index 9a3193763..000000000
--- a/bytestring/Module.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Module kotlinx-io-bytestring
-
-The module provides the [ByteString] - an immutable sequence of bytes, and extensions facilitating work with it.
diff --git a/bytestring/api/kotlinx-io-bytestring.api b/bytestring/api/kotlinx-io-bytestring.api
deleted file mode 100644
index bf0f9f77b..000000000
--- a/bytestring/api/kotlinx-io-bytestring.api
+++ /dev/null
@@ -1,122 +0,0 @@
-public final class kotlinx/io/bytestring/Base64Kt {
- public static final fun decode (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;II)[B
- public static synthetic fun decode$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)[B
- public static final fun decodeIntoByteArray (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;[BIII)I
- public static synthetic fun decodeIntoByteArray$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;[BIIIILjava/lang/Object;)I
- public static final fun decodeToByteString (Lkotlin/io/encoding/Base64;Ljava/lang/CharSequence;II)Lkotlinx/io/bytestring/ByteString;
- public static final fun decodeToByteString (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;II)Lkotlinx/io/bytestring/ByteString;
- public static final fun decodeToByteString (Lkotlin/io/encoding/Base64;[BII)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun decodeToByteString$default (Lkotlin/io/encoding/Base64;Ljava/lang/CharSequence;IIILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun decodeToByteString$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun decodeToByteString$default (Lkotlin/io/encoding/Base64;[BIIILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public static final fun encode (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;II)Ljava/lang/String;
- public static synthetic fun encode$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)Ljava/lang/String;
- public static final fun encodeIntoByteArray (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;[BIII)I
- public static synthetic fun encodeIntoByteArray$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;[BIIIILjava/lang/Object;)I
- public static final fun encodeToAppendable (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;Ljava/lang/Appendable;II)Ljava/lang/Appendable;
- public static synthetic fun encodeToAppendable$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;Ljava/lang/Appendable;IIILjava/lang/Object;)Ljava/lang/Appendable;
- public static final fun encodeToByteArray (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;II)[B
- public static synthetic fun encodeToByteArray$default (Lkotlin/io/encoding/Base64;Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)[B
-}
-
-public final class kotlinx/io/bytestring/ByteString : java/lang/Comparable {
- public static final field Companion Lkotlinx/io/bytestring/ByteString$Companion;
- public fun ([BII)V
- public synthetic fun ([BIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
- public synthetic fun ([BLjava/lang/Object;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
- public synthetic fun compareTo (Ljava/lang/Object;)I
- public fun compareTo (Lkotlinx/io/bytestring/ByteString;)I
- public final fun copyInto ([BIII)V
- public static synthetic fun copyInto$default (Lkotlinx/io/bytestring/ByteString;[BIIIILjava/lang/Object;)V
- public fun equals (Ljava/lang/Object;)Z
- public final fun get (I)B
- public final fun getBackingArrayReference ()[B
- public final fun getSize ()I
- public fun hashCode ()I
- public final fun substring (II)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun substring$default (Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public final fun toByteArray (II)[B
- public static synthetic fun toByteArray$default (Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)[B
- public fun toString ()Ljava/lang/String;
-}
-
-public final class kotlinx/io/bytestring/ByteString$Companion {
-}
-
-public final class kotlinx/io/bytestring/ByteStringBuilder {
- public fun ()V
- public fun (I)V
- public synthetic fun (IILkotlin/jvm/internal/DefaultConstructorMarker;)V
- public final fun append (B)V
- public final fun append ([BII)V
- public static synthetic fun append$default (Lkotlinx/io/bytestring/ByteStringBuilder;[BIIILjava/lang/Object;)V
- public final fun getCapacity ()I
- public final fun getSize ()I
- public final fun toByteString ()Lkotlinx/io/bytestring/ByteString;
-}
-
-public final class kotlinx/io/bytestring/ByteStringBuilderKt {
- public static final fun append (Lkotlinx/io/bytestring/ByteStringBuilder;Lkotlinx/io/bytestring/ByteString;)V
- public static final fun append (Lkotlinx/io/bytestring/ByteStringBuilder;[B)V
- public static final fun append-EK-6454 (Lkotlinx/io/bytestring/ByteStringBuilder;B)V
- public static final fun buildByteString (ILkotlin/jvm/functions/Function1;)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun buildByteString$default (ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
-}
-
-public final class kotlinx/io/bytestring/ByteStringJvmExtKt {
- public static final fun asReadOnlyByteBuffer (Lkotlinx/io/bytestring/ByteString;)Ljava/nio/ByteBuffer;
- public static final fun decodeToString (Lkotlinx/io/bytestring/ByteString;Ljava/nio/charset/Charset;)Ljava/lang/String;
- public static final fun encodeToByteString (Ljava/lang/String;Ljava/nio/charset/Charset;)Lkotlinx/io/bytestring/ByteString;
- public static final fun getByteString (Ljava/nio/ByteBuffer;I)Lkotlinx/io/bytestring/ByteString;
- public static final fun getByteString (Ljava/nio/ByteBuffer;II)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun getByteString$default (Ljava/nio/ByteBuffer;IILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public static final fun putByteString (Ljava/nio/ByteBuffer;ILkotlinx/io/bytestring/ByteString;)V
- public static final fun putByteString (Ljava/nio/ByteBuffer;Lkotlinx/io/bytestring/ByteString;)V
-}
-
-public final class kotlinx/io/bytestring/ByteStringKt {
- public static final fun ByteString ()Lkotlinx/io/bytestring/ByteString;
- public static final fun ByteString ([B)Lkotlinx/io/bytestring/ByteString;
- public static final fun ByteString-GBYM_sE ([B)Lkotlinx/io/bytestring/ByteString;
- public static final fun contentEquals (Lkotlinx/io/bytestring/ByteString;[B)Z
- public static final fun decodeToString (Lkotlinx/io/bytestring/ByteString;)Ljava/lang/String;
- public static final fun encodeToByteString (Ljava/lang/String;)Lkotlinx/io/bytestring/ByteString;
- public static final fun endsWith (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;)Z
- public static final fun endsWith (Lkotlinx/io/bytestring/ByteString;[B)Z
- public static final fun getIndices (Lkotlinx/io/bytestring/ByteString;)Lkotlin/ranges/IntRange;
- public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;BI)I
- public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;I)I
- public static final fun indexOf (Lkotlinx/io/bytestring/ByteString;[BI)I
- public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;BIILjava/lang/Object;)I
- public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;IILjava/lang/Object;)I
- public static synthetic fun indexOf$default (Lkotlinx/io/bytestring/ByteString;[BIILjava/lang/Object;)I
- public static final fun isEmpty (Lkotlinx/io/bytestring/ByteString;)Z
- public static final fun isNotEmpty (Lkotlinx/io/bytestring/ByteString;)Z
- public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;BI)I
- public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;I)I
- public static final fun lastIndexOf (Lkotlinx/io/bytestring/ByteString;[BI)I
- public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;BIILjava/lang/Object;)I
- public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;IILjava/lang/Object;)I
- public static synthetic fun lastIndexOf$default (Lkotlinx/io/bytestring/ByteString;[BIILjava/lang/Object;)I
- public static final fun startsWith (Lkotlinx/io/bytestring/ByteString;Lkotlinx/io/bytestring/ByteString;)Z
- public static final fun startsWith (Lkotlinx/io/bytestring/ByteString;[B)Z
-}
-
-public final class kotlinx/io/bytestring/HexKt {
- public static final fun hexToByteString (Ljava/lang/String;Lkotlin/text/HexFormat;)Lkotlinx/io/bytestring/ByteString;
- public static synthetic fun hexToByteString$default (Ljava/lang/String;Lkotlin/text/HexFormat;ILjava/lang/Object;)Lkotlinx/io/bytestring/ByteString;
- public static final fun toHexString (Lkotlinx/io/bytestring/ByteString;IILkotlin/text/HexFormat;)Ljava/lang/String;
- public static final fun toHexString (Lkotlinx/io/bytestring/ByteString;Lkotlin/text/HexFormat;)Ljava/lang/String;
- public static synthetic fun toHexString$default (Lkotlinx/io/bytestring/ByteString;IILkotlin/text/HexFormat;ILjava/lang/Object;)Ljava/lang/String;
- public static synthetic fun toHexString$default (Lkotlinx/io/bytestring/ByteString;Lkotlin/text/HexFormat;ILjava/lang/Object;)Ljava/lang/String;
-}
-
-public abstract interface annotation class kotlinx/io/bytestring/unsafe/UnsafeByteStringApi : java/lang/annotation/Annotation {
-}
-
-public final class kotlinx/io/bytestring/unsafe/UnsafeByteStringOperations {
- public static final field INSTANCE Lkotlinx/io/bytestring/unsafe/UnsafeByteStringOperations;
- public final fun withByteArrayUnsafe (Lkotlinx/io/bytestring/ByteString;Lkotlin/jvm/functions/Function1;)V
- public final fun wrapUnsafe ([B)Lkotlinx/io/bytestring/ByteString;
-}
-
diff --git a/bytestring/api/kotlinx-io-bytestring.klib.api b/bytestring/api/kotlinx-io-bytestring.klib.api
deleted file mode 100644
index 0f090e717..000000000
--- a/bytestring/api/kotlinx-io-bytestring.klib.api
+++ /dev/null
@@ -1,93 +0,0 @@
-// Klib ABI Dump
-// Targets: [androidNativeArm32, androidNativeArm64, androidNativeX64, androidNativeX86, iosArm64, iosSimulatorArm64, iosX64, js, linuxArm32Hfp, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
-// Alias: apple => [iosArm64, iosSimulatorArm64, iosX64, macosArm64, macosX64, tvosArm64, tvosSimulatorArm64, tvosX64, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
-// Rendering settings:
-// - Signature version: 2
-// - Show manifest properties: true
-// - Show declarations: true
-
-// Library unique name:
-open annotation class kotlinx.io.bytestring.unsafe/UnsafeByteStringApi : kotlin/Annotation { // kotlinx.io.bytestring.unsafe/UnsafeByteStringApi|null[0]
- constructor () // kotlinx.io.bytestring.unsafe/UnsafeByteStringApi.|(){}[0]
-}
-
-final class kotlinx.io.bytestring/ByteString : kotlin/Comparable { // kotlinx.io.bytestring/ByteString|null[0]
- constructor (kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...) // kotlinx.io.bytestring/ByteString.|(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
-
- final val size // kotlinx.io.bytestring/ByteString.size|{}size[0]
- final fun (): kotlin/Int // kotlinx.io.bytestring/ByteString.size.|(){}[0]
-
- final fun compareTo(kotlinx.io.bytestring/ByteString): kotlin/Int // kotlinx.io.bytestring/ByteString.compareTo|compareTo(kotlinx.io.bytestring.ByteString){}[0]
- final fun copyInto(kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ..., kotlin/Int = ...) // kotlinx.io.bytestring/ByteString.copyInto|copyInto(kotlin.ByteArray;kotlin.Int;kotlin.Int;kotlin.Int){}[0]
- final fun equals(kotlin/Any?): kotlin/Boolean // kotlinx.io.bytestring/ByteString.equals|equals(kotlin.Any?){}[0]
- final fun get(kotlin/Int): kotlin/Byte // kotlinx.io.bytestring/ByteString.get|get(kotlin.Int){}[0]
- final fun getBackingArrayReference(): kotlin/ByteArray // kotlinx.io.bytestring/ByteString.getBackingArrayReference|getBackingArrayReference(){}[0]
- final fun hashCode(): kotlin/Int // kotlinx.io.bytestring/ByteString.hashCode|hashCode(){}[0]
- final fun substring(kotlin/Int, kotlin/Int = ...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/ByteString.substring|substring(kotlin.Int;kotlin.Int){}[0]
- final fun toByteArray(kotlin/Int = ..., kotlin/Int = ...): kotlin/ByteArray // kotlinx.io.bytestring/ByteString.toByteArray|toByteArray(kotlin.Int;kotlin.Int){}[0]
- final fun toString(): kotlin/String // kotlinx.io.bytestring/ByteString.toString|toString(){}[0]
-
- final object Companion // kotlinx.io.bytestring/ByteString.Companion|null[0]
-}
-
-final class kotlinx.io.bytestring/ByteStringBuilder { // kotlinx.io.bytestring/ByteStringBuilder|null[0]
- constructor (kotlin/Int = ...) // kotlinx.io.bytestring/ByteStringBuilder.|(kotlin.Int){}[0]
-
- final val capacity // kotlinx.io.bytestring/ByteStringBuilder.capacity|{}capacity[0]
- final fun (): kotlin/Int // kotlinx.io.bytestring/ByteStringBuilder.capacity.|(){}[0]
- final val size // kotlinx.io.bytestring/ByteStringBuilder.size|{}size[0]
- final fun (): kotlin/Int // kotlinx.io.bytestring/ByteStringBuilder.size.|(){}[0]
-
- final fun append(kotlin/Byte) // kotlinx.io.bytestring/ByteStringBuilder.append|append(kotlin.Byte){}[0]
- final fun append(kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...) // kotlinx.io.bytestring/ByteStringBuilder.append|append(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- final fun toByteString(): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/ByteStringBuilder.toByteString|toByteString(){}[0]
-}
-
-final object kotlinx.io.bytestring.unsafe/UnsafeByteStringOperations { // kotlinx.io.bytestring.unsafe/UnsafeByteStringOperations|null[0]
- final fun wrapUnsafe(kotlin/ByteArray): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring.unsafe/UnsafeByteStringOperations.wrapUnsafe|wrapUnsafe(kotlin.ByteArray){}[0]
- final inline fun withByteArrayUnsafe(kotlinx.io.bytestring/ByteString, kotlin/Function1) // kotlinx.io.bytestring.unsafe/UnsafeByteStringOperations.withByteArrayUnsafe|withByteArrayUnsafe(kotlinx.io.bytestring.ByteString;kotlin.Function1){}[0]
-}
-
-final val kotlinx.io.bytestring/indices // kotlinx.io.bytestring/indices|@kotlinx.io.bytestring.ByteString{}indices[0]
- final fun (kotlinx.io.bytestring/ByteString).(): kotlin.ranges/IntRange // kotlinx.io.bytestring/indices.|@kotlinx.io.bytestring.ByteString(){}[0]
-
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/decode(kotlinx.io.bytestring/ByteString, kotlin/Int = ..., kotlin/Int = ...): kotlin/ByteArray // kotlinx.io.bytestring/decode|decode@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/decodeIntoByteArray(kotlinx.io.bytestring/ByteString, kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ..., kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/decodeIntoByteArray|decodeIntoByteArray@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.ByteArray;kotlin.Int;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/decodeToByteString(kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/decodeToByteString|decodeToByteString@kotlin.io.encoding.Base64(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/decodeToByteString(kotlin/CharSequence, kotlin/Int = ..., kotlin/Int = ...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/decodeToByteString|decodeToByteString@kotlin.io.encoding.Base64(kotlin.CharSequence;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/decodeToByteString(kotlinx.io.bytestring/ByteString, kotlin/Int = ..., kotlin/Int = ...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/decodeToByteString|decodeToByteString@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/encode(kotlinx.io.bytestring/ByteString, kotlin/Int = ..., kotlin/Int = ...): kotlin/String // kotlinx.io.bytestring/encode|encode@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/encodeIntoByteArray(kotlinx.io.bytestring/ByteString, kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ..., kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/encodeIntoByteArray|encodeIntoByteArray@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.ByteArray;kotlin.Int;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin.io.encoding/Base64).kotlinx.io.bytestring/encodeToByteArray(kotlinx.io.bytestring/ByteString, kotlin/Int = ..., kotlin/Int = ...): kotlin/ByteArray // kotlinx.io.bytestring/encodeToByteArray|encodeToByteArray@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;kotlin.Int;kotlin.Int){}[0]
-final fun (kotlin/String).kotlinx.io.bytestring/encodeToByteString(): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/encodeToByteString|encodeToByteString@kotlin.String(){}[0]
-final fun (kotlin/String).kotlinx.io.bytestring/hexToByteString(kotlin.text/HexFormat = ...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/hexToByteString|hexToByteString@kotlin.String(kotlin.text.HexFormat){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/contentEquals(kotlin/ByteArray): kotlin/Boolean // kotlinx.io.bytestring/contentEquals|contentEquals@kotlinx.io.bytestring.ByteString(kotlin.ByteArray){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/decodeToString(): kotlin/String // kotlinx.io.bytestring/decodeToString|decodeToString@kotlinx.io.bytestring.ByteString(){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/endsWith(kotlin/ByteArray): kotlin/Boolean // kotlinx.io.bytestring/endsWith|endsWith@kotlinx.io.bytestring.ByteString(kotlin.ByteArray){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/endsWith(kotlinx.io.bytestring/ByteString): kotlin/Boolean // kotlinx.io.bytestring/endsWith|endsWith@kotlinx.io.bytestring.ByteString(kotlinx.io.bytestring.ByteString){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/indexOf(kotlin/Byte, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/indexOf|indexOf@kotlinx.io.bytestring.ByteString(kotlin.Byte;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/indexOf(kotlin/ByteArray, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/indexOf|indexOf@kotlinx.io.bytestring.ByteString(kotlin.ByteArray;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/indexOf(kotlinx.io.bytestring/ByteString, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/indexOf|indexOf@kotlinx.io.bytestring.ByteString(kotlinx.io.bytestring.ByteString;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/isEmpty(): kotlin/Boolean // kotlinx.io.bytestring/isEmpty|isEmpty@kotlinx.io.bytestring.ByteString(){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/isNotEmpty(): kotlin/Boolean // kotlinx.io.bytestring/isNotEmpty|isNotEmpty@kotlinx.io.bytestring.ByteString(){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/lastIndexOf(kotlin/Byte, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/lastIndexOf|lastIndexOf@kotlinx.io.bytestring.ByteString(kotlin.Byte;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/lastIndexOf(kotlin/ByteArray, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/lastIndexOf|lastIndexOf@kotlinx.io.bytestring.ByteString(kotlin.ByteArray;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/lastIndexOf(kotlinx.io.bytestring/ByteString, kotlin/Int = ...): kotlin/Int // kotlinx.io.bytestring/lastIndexOf|lastIndexOf@kotlinx.io.bytestring.ByteString(kotlinx.io.bytestring.ByteString;kotlin.Int){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/startsWith(kotlin/ByteArray): kotlin/Boolean // kotlinx.io.bytestring/startsWith|startsWith@kotlinx.io.bytestring.ByteString(kotlin.ByteArray){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/startsWith(kotlinx.io.bytestring/ByteString): kotlin/Boolean // kotlinx.io.bytestring/startsWith|startsWith@kotlinx.io.bytestring.ByteString(kotlinx.io.bytestring.ByteString){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/toHexString(kotlin.text/HexFormat = ...): kotlin/String // kotlinx.io.bytestring/toHexString|toHexString@kotlinx.io.bytestring.ByteString(kotlin.text.HexFormat){}[0]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/toHexString(kotlin/Int = ..., kotlin/Int = ..., kotlin.text/HexFormat = ...): kotlin/String // kotlinx.io.bytestring/toHexString|toHexString@kotlinx.io.bytestring.ByteString(kotlin.Int;kotlin.Int;kotlin.text.HexFormat){}[0]
-final fun (kotlinx.io.bytestring/ByteStringBuilder).kotlinx.io.bytestring/append(kotlin/ByteArray...) // kotlinx.io.bytestring/append|append@kotlinx.io.bytestring.ByteStringBuilder(kotlin.ByteArray...){}[0]
-final fun (kotlinx.io.bytestring/ByteStringBuilder).kotlinx.io.bytestring/append(kotlin/UByte) // kotlinx.io.bytestring/append|append@kotlinx.io.bytestring.ByteStringBuilder(kotlin.UByte){}[0]
-final fun (kotlinx.io.bytestring/ByteStringBuilder).kotlinx.io.bytestring/append(kotlinx.io.bytestring/ByteString) // kotlinx.io.bytestring/append|append@kotlinx.io.bytestring.ByteStringBuilder(kotlinx.io.bytestring.ByteString){}[0]
-final fun <#A: kotlin.text/Appendable> (kotlin.io.encoding/Base64).kotlinx.io.bytestring/encodeToAppendable(kotlinx.io.bytestring/ByteString, #A, kotlin/Int = ..., kotlin/Int = ...): #A // kotlinx.io.bytestring/encodeToAppendable|encodeToAppendable@kotlin.io.encoding.Base64(kotlinx.io.bytestring.ByteString;0:0;kotlin.Int;kotlin.Int){0§}[0]
-final fun kotlinx.io.bytestring/ByteString(): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/ByteString|ByteString(){}[0]
-final fun kotlinx.io.bytestring/ByteString(kotlin/ByteArray...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/ByteString|ByteString(kotlin.ByteArray...){}[0]
-final fun kotlinx.io.bytestring/ByteString(kotlin/UByteArray...): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/ByteString|ByteString(kotlin.UByteArray...){}[0]
-final inline fun kotlinx.io.bytestring/buildByteString(kotlin/Int = ..., kotlin/Function1): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/buildByteString|buildByteString(kotlin.Int;kotlin.Function1){}[0]
-
-// Targets: [apple]
-final fun (kotlinx.io.bytestring/ByteString).kotlinx.io.bytestring/toNSData(): platform.Foundation/NSData // kotlinx.io.bytestring/toNSData|toNSData@kotlinx.io.bytestring.ByteString(){}[0]
-
-// Targets: [apple]
-final fun (platform.Foundation/NSData).kotlinx.io.bytestring/toByteString(): kotlinx.io.bytestring/ByteString // kotlinx.io.bytestring/toByteString|toByteString@platform.Foundation.NSData(){}[0]
diff --git a/bytestring/apple/src/ByteStringApple.kt b/bytestring/apple/src/ByteStringApple.kt
deleted file mode 100644
index 786a4ba8a..000000000
--- a/bytestring/apple/src/ByteStringApple.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlinx.cinterop.*
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringApi
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringOperations
-import platform.Foundation.NSData
-import platform.Foundation.create
-
-/**
- * Returns a new [NSData] instance initialized with bytes copied from [this] ByteString.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamplesApple.nsDataConversion
- */
-@OptIn(UnsafeNumber::class, BetaInteropApi::class, ExperimentalForeignApi::class)
-public fun ByteString.toNSData(): NSData {
- if (isEmpty()) {
- return NSData()
- }
- val data = getBackingArrayReference()
- return data.usePinned {
- NSData.create(bytes = it.addressOf(0), length = data.size.convert())
- }
-}
-
-/**
- * Returns a new [ByteString] holding data copied from [this] NSData.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamplesApple.nsDataConversion
- */
-@OptIn(ExperimentalForeignApi::class, UnsafeNumber::class, UnsafeByteStringApi::class)
-public fun NSData.toByteString(): ByteString {
- val l = length.toLong()
- if (l == 0L) {
- return ByteString.EMPTY
- }
- if (l > Int.MAX_VALUE) {
- throw IllegalArgumentException("NSData content is to long to read as byte array: $l")
- }
- return UnsafeByteStringOperations.wrapUnsafe(
- bytes!!.readBytes(l.toInt())
- )
-}
diff --git a/bytestring/apple/test/ByteStringAppleTest.kt b/bytestring/apple/test/ByteStringAppleTest.kt
deleted file mode 100644
index 702bbf5a2..000000000
--- a/bytestring/apple/test/ByteStringAppleTest.kt
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlinx.cinterop.*
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringApi
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringOperations
-import platform.Foundation.NSData
-import platform.Foundation.create
-import platform.posix.memset
-import kotlin.io.encoding.Base64
-import kotlin.io.encoding.ExperimentalEncodingApi
-import kotlin.test.*
-
-@OptIn(UnsafeNumber::class)
-class ByteStringAppleTest {
- @OptIn(ExperimentalForeignApi::class)
- @Test
- fun toNSData() {
- val emptyData = ByteString().toNSData()
- assertEquals(0u, emptyData.length)
-
- val copy = ByteString(0, 1, 2, 3, 4, 5).toNSData()
- assertContentEquals(byteArrayOf(0, 1, 2, 3, 4, 5), copy.bytes!!.readBytes(copy.length.convert()))
- }
-
- @OptIn(BetaInteropApi::class, ExperimentalEncodingApi::class)
- @Test
- fun fromNSData() {
- assertTrue(NSData().toByteString().isEmpty())
- val src = NSData.create(
- base64EncodedString = Base64.Default.encode(byteArrayOf(0, 1, 2, 3, 4, 5)),
- options = 0u
- )!!
- val copy = src.toByteString()
- assertContentEquals(byteArrayOf(0, 1, 2, 3, 4, 5), copy.toByteArray())
- }
-
- @OptIn(UnsafeByteStringApi::class, ExperimentalForeignApi::class)
- @Test
- fun toNSDataDataIntegrity() {
- val mutableArray = byteArrayOf(0, 0, 0, 0, 0, 0)
- // Don't try that at home, kids!
- val cursedString = UnsafeByteStringOperations.wrapUnsafe(mutableArray)
- val nsData = cursedString.toNSData()
-
- mutableArray.fill(42)
- // NSData should hold a copy
- assertContentEquals(ByteArray(6), nsData.bytes!!.readBytes(6))
- }
-
- @OptIn(ExperimentalForeignApi::class, BetaInteropApi::class)
- @Test
- fun fromNSDataIntegrity() = memScoped {
- val length = 6
- val data = allocArray(length)
- memset(data, 0, length.convert())
-
- val cursedData = NSData.create(
- bytesNoCopy = data, length = length.convert(),
- freeWhenDone = false
- )
-
- val byteString = cursedData.toByteString()
- memset(data, 42, length.convert())
-
- assertContentEquals(ByteArray(length), byteString.toByteArray())
- }
-}
diff --git a/bytestring/apple/test/samples/samplesApple.kt b/bytestring/apple/test/samples/samplesApple.kt
deleted file mode 100644
index c2d6432bb..000000000
--- a/bytestring/apple/test/samples/samplesApple.kt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-package kotlinx.io.bytestring.samples
-
-import kotlinx.cinterop.ExperimentalForeignApi
-import kotlinx.cinterop.UnsafeNumber
-import kotlinx.io.bytestring.*
-import platform.Foundation.*
-import kotlin.test.*
-
-class ByteStringSamplesApple {
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalStdlibApi::class)
- @Test
- fun nsDataConversion() {
- val originalByteString: ByteString = "Compress me, please!".encodeToByteString()
-
- val compressedNSData: NSData = originalByteString.toNSData().compressedDataUsingAlgorithm(
- algorithm = NSDataCompressionAlgorithmZlib,
- error = null
- )!!
-
- val compressedByteString: ByteString = compressedNSData.toByteString()
- assertEquals("73cecf2d284a2d2e56c84dd55128c8494d2c4e550400", compressedByteString.toHexString())
- // If there's no zlib-flate on your path, you can test it using:
- // zlib.decompress(binascii.unhexlify("73cecf2d284a2d2e56c84dd55128c8494d2c4e550400"), -15)
- }
-}
diff --git a/bytestring/build.gradle.kts b/bytestring/build.gradle.kts
deleted file mode 100644
index 77af1c57c..000000000
--- a/bytestring/build.gradle.kts
+++ /dev/null
@@ -1,26 +0,0 @@
-plugins {
- id("kotlinx-io-multiplatform")
- id("kotlinx-io-publish")
- id("kotlinx-io-dokka")
- id("kotlinx-io-android-compat")
- alias(libs.plugins.kover)
-}
-
-kotlin {
- js {
- nodejs {
- testTask {
- useMocha {
- timeout = "30s"
- }
- }
- }
- browser {
- testTask {
- useMocha {
- timeout = "30s"
- }
- }
- }
- }
-}
diff --git a/bytestring/common/src/-Platform.kt b/bytestring/common/src/-Platform.kt
deleted file mode 100644
index dfaae6840..000000000
--- a/bytestring/common/src/-Platform.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
-* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
-* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
-*/
-package kotlinx.io.bytestring
-
-/**
- * Annotation indicating that the marked property is the subject of benign data race.
- * LLVM does not support this notion, so on K/N platforms we alias it into `@Volatile` to prevent potential OoTA.
- */
-@OptionalExpectation
-@Target(AnnotationTarget.FIELD)
-@OptIn(ExperimentalMultiplatform::class)
-internal expect annotation class BenignDataRace()
diff --git a/bytestring/common/src/Base64.kt b/bytestring/common/src/Base64.kt
deleted file mode 100644
index f21ebc4e1..000000000
--- a/bytestring/common/src/Base64.kt
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.io.encoding.Base64
-import kotlin.io.encoding.Base64.Default.encode
-import kotlin.io.encoding.Base64.Default.encodeToByteArray
-import kotlin.io.encoding.ExperimentalEncodingApi
-
-/**
- * Encodes bytes from the specified [source] byte string or its subrange.
- * Returns a [ByteArray] containing the resulting symbols.
- *
- * If the size of the [source] byte string or its subrange is not an integral multiple of 3,
- * the result is padded with `'='` to an integral multiple of 4 symbols.
- *
- * Each resulting symbol occupies one byte in the returned byte array.
- *
- * Use [encode] to get the output in string form.
- *
- * @param source the byte string to encode bytes from.
- * @param startIndex the beginning (inclusive) of the subrange to encode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to encode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @return a [ByteArray] with the resulting symbols.
- */
-@ExperimentalEncodingApi
-public fun Base64.encodeToByteArray(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray {
- return encodeToByteArray(source.getBackingArrayReference(), startIndex, endIndex)
-}
-
-/**
- * Encodes bytes from the specified [source] byte string or its subrange and writes resulting symbols into the [destination] array.
- * Returns the number of symbols written.
- *
- * If the size of the [source] byte string or its subrange is not an integral multiple of 3,
- * the result is padded with `'='` to an integral multiple of 4 symbols.
- *
- * @param source the byte string to encode bytes from.
- * @param destination the array to write symbols into.
- * @param destinationOffset the starting index in the [destination] array to write symbols to, 0 by default.
- * @param startIndex the beginning (inclusive) of the subrange to encode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to encode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IndexOutOfBoundsException when the resulting symbols don't fit into the [destination] array starting at the specified [destinationOffset],
- * or when that index is out of the [destination] array indices range.
- *
- * @return the number of symbols written into [destination] array.
- */
-@ExperimentalEncodingApi
-public fun Base64.encodeIntoByteArray(
- source: ByteString,
- destination: ByteArray,
- destinationOffset: Int = 0,
- startIndex: Int = 0,
- endIndex: Int = source.size
-): Int {
- return encodeIntoByteArray(source.getBackingArrayReference(), destination, destinationOffset, startIndex, endIndex)
-}
-
-/**
- * Encodes bytes from the specified [source] byte string or its subrange.
- * Returns a string with the resulting symbols.
- *
- * If the size of the [source] byte string or its subrange is not an integral multiple of 3,
- * the result is padded with `'='` to an integral multiple of 4 symbols.
- *
- * Use [encodeToByteArray] to get the output in [ByteArray] form.
- *
- * @param source the byte string to encode bytes from.
- * @param startIndex the beginning (inclusive) of the subrange to encode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to encode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @return a string with the resulting symbols.
- */
-@ExperimentalEncodingApi
-public fun Base64.encode(
- source: ByteString,
- startIndex: Int = 0,
- endIndex: Int = source.size
-): String {
- return encode(source.getBackingArrayReference(), startIndex, endIndex)
-}
-
-/**
- * Encodes bytes from the specified [source] byte string or its subrange and appends resulting symbols to the [destination] appendable.
- * Returns the destination appendable.
- *
- * If the size of the [source] byte string or its subrange is not an integral multiple of 3,
- * the result is padded with `'='` to an integral multiple of 4 symbols.
- *
- * @param source the byte string to encode bytes from.
- * @param destination the appendable to append symbols to.
- * @param startIndex the beginning (inclusive) of the subrange to encode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to encode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @return the destination appendable.
- */
-@ExperimentalEncodingApi
-public fun Base64.encodeToAppendable(
- source: ByteString,
- destination: A,
- startIndex: Int = 0,
- endIndex: Int = source.size
-): A {
- return encodeToAppendable(source.getBackingArrayReference(), destination, startIndex, endIndex)
-}
-
-
-/**
- * Decodes symbols from the specified [source] byte string or its subrange.
- * Returns a [ByteArray] containing the resulting bytes.
- *
- * The symbols for decoding are not required to be padded.
- * However, if there is a padding character present, the correct amount of padding character(s) must be present.
- * The padding character `'='` is interpreted as the end of the encoded byte data. Subsequent symbols are prohibited.
- *
- * @param source the byte string to decode symbols from.
- * @param startIndex the beginning (inclusive) of the subrange to decode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to decode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IllegalArgumentException when the symbols for decoding are padded incorrectly or there are extra symbols after the padding.
- *
- * @return a [ByteArray] with the resulting bytes.
- */
-@ExperimentalEncodingApi
-public fun Base64.decode(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray {
- return decode(source.getBackingArrayReference(), startIndex, endIndex)
-}
-
-/**
- * Decodes symbols from the specified [source] char sequence or its substring.
- * Returns a [ByteString] containing the resulting bytes.
- *
- * The symbols for decoding are not required to be padded.
- * However, if there is a padding character present, the correct amount of padding character(s) must be present.
- * The padding character `'='` is interpreted as the end of the encoded byte data. Subsequent symbols are prohibited.
- *
- * @param source the char sequence to decode symbols from.
- * @param startIndex the beginning (inclusive) of the substring to decode, 0 by default.
- * @param endIndex the end (exclusive) of the substring to decode, length of the [source] by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IllegalArgumentException when the symbols for decoding are padded incorrectly or there are extra symbols after the padding.
- *
- * @return a [ByteArray] with the resulting bytes.
- */
-@ExperimentalEncodingApi
-public fun Base64.decodeToByteString(source: CharSequence, startIndex: Int = 0, endIndex: Int = source.length): ByteString {
- return ByteString.wrap(decode(source, startIndex, endIndex))
-}
-
-/**
- * Decodes symbols from the specified [source] byte string or its subrange and writes resulting bytes into the [destination] array.
- * Returns the number of bytes written.
- *
- * The symbols for decoding are not required to be padded.
- * However, if there is a padding character present, the correct amount of padding character(s) must be present.
- * The padding character `'='` is interpreted as the end of the encoded byte data. Subsequent symbols are prohibited.
- *
- * @param source the byte string to decode symbols from.
- * @param destination the array to write bytes into.
- * @param destinationOffset the starting index in the [destination] array to write bytes to, 0 by default.
- * @param startIndex the beginning (inclusive) of the subrange to decode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to decode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IndexOutOfBoundsException when the resulting bytes don't fit into the [destination] array starting at the specified [destinationOffset],
- * or when that index is out of the [destination] array indices range.
- * @throws IllegalArgumentException when the symbols for decoding are padded incorrectly or there are extra symbols after the padding.
- *
- * @return the number of bytes written into [destination] array.
- */
-@ExperimentalEncodingApi
-public fun Base64.decodeIntoByteArray(
- source: ByteString,
- destination: ByteArray,
- destinationOffset: Int = 0,
- startIndex: Int = 0,
- endIndex: Int = source.size
-): Int {
- return decodeIntoByteArray(source.getBackingArrayReference(), destination, destinationOffset, startIndex, endIndex)
-}
-
-/**
- * Decodes symbols from the specified [source] byte string or its subrange.
- * Returns a [ByteString] containing the resulting bytes.
- *
- * The symbols for decoding are not required to be padded.
- * However, if there is a padding character present, the correct amount of padding character(s) must be present.
- * The padding character `'='` is interpreted as the end of the encoded byte data. Subsequent symbols are prohibited.
- *
- * @param source the byte string to decode symbols from.
- * @param startIndex the beginning (inclusive) of the subrange to decode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to decode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IllegalArgumentException when the symbols for decoding are padded incorrectly or there are extra symbols after the padding.
- *
- * @return a [ByteString] with the resulting bytes.
- */
-@ExperimentalEncodingApi
-public fun Base64.decodeToByteString(source: ByteArray, startIndex: Int = 0, endIndex: Int = source.size): ByteString {
- return ByteString.wrap(decode(source, startIndex, endIndex))
-}
-
-/**
- * Decodes symbols from the specified [source] byte string or its subrange.
- * Returns a [ByteString] containing the resulting bytes.
- *
- * The symbols for decoding are not required to be padded.
- * However, if there is a padding character present, the correct amount of padding character(s) must be present.
- * The padding character `'='` is interpreted as the end of the encoded byte data. Subsequent symbols are prohibited.
- *
- * @param source the byte string to decode symbols from.
- * @param startIndex the beginning (inclusive) of the subrange to decode, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to decode, size of the [source] byte string by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [source] byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IllegalArgumentException when the symbols for decoding are padded incorrectly or there are extra symbols after the padding.
- *
- * @return a [ByteString] with the resulting bytes.
- */
-@ExperimentalEncodingApi
-public fun Base64.decodeToByteString(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteString {
- return ByteString.wrap(decode(source.getBackingArrayReference(), startIndex, endIndex))
-}
diff --git a/bytestring/common/src/ByteString.kt b/bytestring/common/src/ByteString.kt
deleted file mode 100644
index 29820b880..000000000
--- a/bytestring/common/src/ByteString.kt
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-/*
- * Copyright (C) 2018 Square, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.js.JsName
-import kotlin.math.max
-import kotlin.math.min
-
-/**
- * Wraps given [bytes] into a byte string.
- *
- * @param bytes a sequence of bytes to be wrapped.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.constructionFromBytesSample
- */
-public fun ByteString(vararg bytes: Byte): ByteString = if (bytes.isEmpty()) {
- ByteString.EMPTY
-} else {
- ByteString.wrap(bytes)
-}
-
-/**
- * Wraps given [bytes] into a byte string.
- *
- * Internally, [bytes] will be stored as [ByteArray], and accesses to individual
- * [ByteString]'s bytes will return a signed [Byte] as if someone call `bytes[i].toByte()`.
- *
- * @param bytes a sequence of bytes to be wrapped.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.constructionFromUBytesSample
- */
-@OptIn(ExperimentalUnsignedTypes::class)
-public fun ByteString(vararg bytes: UByte): ByteString = if (bytes.isEmpty()) {
- ByteString.EMPTY
-} else {
- ByteString.wrap(bytes.asByteArray())
-}
-
-@JsName("EmptyByteString")
-public fun ByteString(): ByteString = ByteString.EMPTY
-
-/**
- * An immutable wrapper around a byte sequence providing [String] like functionality.
- *
- * ByteString allows treating binary data as a value and passing it to other functions
- * without worrying about data modification.
- * The class facilitates various operations on binary data, like comparison or testing for subsequence inclusion.
- *
- * ByteString is a good fit for untyped binary data that could not be represented as [String],
- * like hashes, payload of network packets, encrypted data, etc.
- *
- * ByteString copies data on creation as well as on conversion back to [ByteArray], thus guaranteeing that subsequent
- * modification of source data or data returned from [toByteArray] won't mutate the string itself.
- */
-public class ByteString private constructor(
- private val data: ByteArray,
- @Suppress("UNUSED_PARAMETER") dummy: Any?
-) : Comparable {
- /**
- * Wraps a copy of [data] subarray starting at [startIndex] and ending at [endIndex] into a byte string.
- *
- * @param data the array whose subarray should be copied and wrapped into a byte string.
- * @param startIndex the start index (inclusive) of a subarray to copy, `0` by default.
- * @param endIndex the end index (exclusive) of a subarray to copy, `data.size` be default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [data] array indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.constructionSample
- */
- public constructor(data: ByteArray, startIndex: Int = 0, endIndex: Int = data.size) :
- this(data.copyOfRange(startIndex, endIndex), null)
-
- @BenignDataRace
- private var hashCode: Int = 0
-
- public companion object {
- /**
- * An empty ByteString.
- */
- internal val EMPTY: ByteString = ByteString(ByteArray(0), null)
-
- internal fun wrap(byteArray: ByteArray): ByteString = ByteString(byteArray, null)
-
- private val HEX_DIGITS = "0123456789abcdef".toCharArray()
- }
-
- /**
- * Returns size of this ByteString.
- */
- public val size: Int
- get(): Int = data.size
-
- /**
- * Returns `true` if [other] is a byte string containing exactly the same byte sequence.
- *
- * @param other the other object to compare this byte string for equality to.
- */
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (other == null || this::class != other::class) return false
-
- other as ByteString
-
- if (other.data.size != data.size) return false
- if (other.hashCode != 0 && hashCode != 0 && other.hashCode != hashCode) return false
- return data.contentEquals(other.data)
- }
-
- /**
- * Returns a hash code based on the content of this byte string.
- */
- override fun hashCode(): Int {
- var hc = hashCode
- if (hc == 0) {
- hc = data.contentHashCode()
- hashCode = hc
- }
- return hc
- }
-
- /**
- * Returns a byte at the given index in this byte string.
- *
- * @param index the index to retrieve the byte at.
- *
- * @throws IndexOutOfBoundsException when [index] is negative or greater or equal to the [size].
- */
- public operator fun get(index: Int): Byte {
- if (index < 0 || index >= size) throw IndexOutOfBoundsException(
- "index ($index) is out of byte string bounds: [0..$size)"
- )
- return data[index]
- }
-
- /**
- * Returns a copy of subsequence starting at [startIndex] and ending at [endIndex] of a byte sequence
- * wrapped by this byte string.
- *
- * @param startIndex the start index (inclusive) of a subsequence to copy, `0` by default.
- * @param endIndex the end index (exclusive) of a subsequence to copy, [size] be default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.toByteArraySample
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.toByteArrayWithIndicesSample
- */
- public fun toByteArray(startIndex: Int = 0, endIndex: Int = size): ByteArray {
- require(startIndex <= endIndex) { "startIndex ($startIndex) > endIndex ($endIndex)" }
- return data.copyOfRange(startIndex, endIndex)
- }
-
- /**
- * Copies a subsequence starting at [startIndex] and ending at [endIndex] of a byte sequence
- * wrapped by this byte string and writes it into [destination] array starting at [destinationOffset] offset.
- *
- * @param destination the array to copy data into.
- * @param destinationOffset the offset starting from which data copy should be written to [destination].
- * @param startIndex the start index (inclusive) of a subsequence to copy, `0` by default.
- * @param endIndex the end index (exclusive) of a subsequence to copy, [size] be default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of byte string indices.
- * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at
- * the specified [destinationOffset], or when that index is out of the [destination] array indices range.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.copyToSample
- */
- public fun copyInto(
- destination: ByteArray, destinationOffset: Int = 0,
- startIndex: Int = 0, endIndex: Int = size
- ) {
- require(startIndex <= endIndex) { "startIndex ($startIndex) > endIndex ($endIndex)" }
- data.copyInto(destination, destinationOffset, startIndex, endIndex)
- }
-
- /**
- * Returns a new byte string wrapping a subsequence of bytes wrapped by this byte string starting from
- * [startIndex] and ending at [endIndex].
- *
- * @param startIndex the start index (inclusive) of a subsequence to copy.
- * @param endIndex the end index (exclusive) of a subsequence to copy, [size] be default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.substringSample
- */
- public fun substring(startIndex: Int, endIndex: Int = size): ByteString = if (startIndex == endIndex) {
- EMPTY
- } else {
- ByteString(data, startIndex, endIndex)
- }
-
- /**
- * Compares a byte sequence wrapped by this byte string to a byte sequence wrapped by [other]
- * in lexicographical order.
- * Byte values are compared as unsigned integers.
- *
- * The behavior is similar to [String.compareTo].
- *
- * @param other the byte string to compare this string to.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.compareTo
- */
- override fun compareTo(other: ByteString): Int {
- if (other === this) return 0
- val localData = data
- val otherData = other.data
- for (i in 0 until min(size, other.size)) {
- val cmp = localData[i].toUByte().compareTo(otherData[i].toUByte())
- if (cmp != 0) return cmp
- }
-
- return size.compareTo(other.size)
- }
-
- /**
- * Returns a string representation of this byte string. A string representation consists of [size] and
- * a hexadecimal-encoded string of a byte sequence wrapped by this byte string.
- *
- * The string representation has the following format `ByteString(size=3 hex=ABCDEF)`,
- * for empty strings it's always `ByteString(size=0)`.
- *
- * Note that a string representation includes the whole byte string content encoded.
- * Due to limitations exposed for the maximum string length, an attempt to return a string representation
- * of too long byte string may fail.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.toStringSample
- */
- override fun toString(): String {
- if (isEmpty()) {
- return "ByteString(size=0)"
- }
- // format: "ByteString(size=XXX hex=YYYY)"
- val sizeStr = size.toString()
- val len = 22 + sizeStr.length + size * 2
- return with(StringBuilder(len)) {
- append("ByteString(size=")
- append(sizeStr)
- append(" hex=")
- val localData = data
- for (i in 0 until size) {
- val b = localData[i].toInt()
- append(HEX_DIGITS[(b ushr 4) and 0xf])
- append(HEX_DIGITS[b and 0xf])
- }
- append(')')
- }.toString()
- }
-
- /**
- * Returns a reference to the underlying array.
- *
- * These methods return reference to the underlying array, not to its copy.
- * Consider using [toByteArray] if it's impossible to guarantee that the array won't be modified.
- */
- @PublishedApi
- internal fun getBackingArrayReference(): ByteArray = data
-}
-
-/**
- * Returns the range of valid byte indices for this byte string.
- */
-public val ByteString.indices: IntRange
- get() = 0 until size
-
-/**
- * Returns the index within this byte string of the first occurrence of the specified [byte],
- * starting from the specified [startIndex].
- * If the [byte] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.indexOf].
- *
- * @param byte the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byte] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.indexOfByteSample
- */
-public fun ByteString.indexOf(byte: Byte, startIndex: Int = 0): Int {
- val localData = getBackingArrayReference()
- for (i in max(startIndex, 0) until size) {
- if (localData[i] == byte) {
- return i
- }
- }
- return -1
-}
-
-/**
- * Returns the index within this byte string of the first occurrence of the specified [byteString],
- * starting from the specified [startIndex].
- * If the [byteString] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.indexOf].
- *
- * @param byteString the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byteString] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.indexOfByteStringSample
- */
-public fun ByteString.indexOf(byteString: ByteString, startIndex: Int = 0): Int {
- if (byteString.isEmpty()) return max(min(startIndex, size), 0)
- val localData = getBackingArrayReference()
- val firstByte = byteString[0]
- for (i in max(startIndex, 0)..size - byteString.size) {
- if (localData[i] == firstByte && rangeEquals(i, byteString)) {
- return i
- }
- }
- return -1
-}
-
-/**
- * Returns the index within this byte string of the first occurrence of the specified [byteArray],
- * starting from the specified [startIndex].
- * If the [byteArray] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.indexOf].
- *
- * @param byteArray the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byteArray] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.indexOfByteArraySample
- */
-public fun ByteString.indexOf(byteArray: ByteArray, startIndex: Int = 0): Int {
- if (byteArray.isEmpty()) return max(min(startIndex, size), 0)
- val localData = getBackingArrayReference()
- val firstByte = byteArray[0]
- for (i in max(0, startIndex)..size - byteArray.size) {
- if (localData[i] == firstByte && rangeEquals(i, byteArray)) {
- return i
- }
- }
- return -1
-}
-
-/**
- * Returns the index within this char sequence of the last occurrence of the specified [byte],
- * starting from the specified [startIndex].
- * If the [byte] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.lastIndexOf].
- *
- * @param byte the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byte] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.lastIndexOfByteSample
- */
-public fun ByteString.lastIndexOf(byte: Byte, startIndex: Int = 0): Int {
- val localData = getBackingArrayReference()
- for (i in size - 1 downTo max(0, startIndex)) {
- if (localData[i] == byte) {
- return i
- }
- }
- return -1
-}
-
-/**
- * Returns the index within this char sequence of the last occurrence of the specified [byteString],
- * starting from the specified [startIndex].
- * If the [byteString] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.lastIndexOf].
- *
- * @param byteString the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byteString] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.lastIndexOfByteStringSample
- */
-public fun ByteString.lastIndexOf(byteString: ByteString, startIndex: Int = 0): Int {
- if (byteString.isEmpty()) return size
- for (idx in (size - byteString.size) downTo max(0, startIndex)) {
- if (rangeEquals(idx, byteString, 0)) {
- return idx
- }
- }
- return -1
-}
-
-/**
- * Returns the index within this char sequence of the last occurrence of the specified [byteArray],
- * starting from the specified [startIndex].
- * If the [byteArray] not found, `-1` is returned.
- *
- * Behavior of this method is compatible with [CharSequence.lastIndexOf].
- *
- * @param byteArray the value to search for.
- * @param startIndex the index (inclusive) starting from which the [byteArray] should be searched.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.lastIndexOfByteArraySample
- */
-public fun ByteString.lastIndexOf(byteArray: ByteArray, startIndex: Int = 0): Int {
- if (byteArray.isEmpty()) return size
- for (idx in (size - byteArray.size) downTo max(0, startIndex)) {
- if (rangeEquals(idx, byteArray, 0)) {
- return idx
- }
- }
- return -1
-}
-
-/**
- * Returns true if this byte string starts with the prefix specified by the [byteArray].
- *
- * Behavior of this method is compatible with [CharSequence.startsWith].
- *
- * @param byteArray the prefix to check for.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.startsWithByteArraySample
- */
-public fun ByteString.startsWith(byteArray: ByteArray): Boolean = when {
- byteArray.size > size -> false
- else -> rangeEquals(0, byteArray)
-}
-
-/**
- * Returns true if this byte string starts with the prefix specified by the [byteString].
- *
- * Behavior of this method is compatible with [CharSequence.startsWith].
- *
- * @param byteString the prefix to check for.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.startsWithByteStringSample
- */
-public fun ByteString.startsWith(byteString: ByteString): Boolean = when {
- byteString.size > size -> false
- byteString.size == size -> equals(byteString)
- else -> rangeEquals(0, byteString)
-}
-
-/**
- * Returns true if this byte string ends with the suffix specified by the [byteArray].
- *
- * Behavior of this method is compatible with [CharSequence.endsWith].
- *
- * @param byteArray the suffix to check for.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.endsWithByteArraySample
- */
-public fun ByteString.endsWith(byteArray: ByteArray): Boolean = when {
- byteArray.size > size -> false
- else -> rangeEquals(size - byteArray.size, byteArray)
-}
-
-/**
- * Returns true if this byte string ends with the suffix specified by the [byteString].
- *
- * Behavior of this method is compatible with [CharSequence.endsWith].
- *
- * @param byteString the suffix to check for.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.endsWithByteStringSample
- */
-public fun ByteString.endsWith(byteString: ByteString): Boolean = when {
- byteString.size > size -> false
- byteString.size == size -> equals(byteString)
- else -> rangeEquals(size - byteString.size, byteString)
-}
-
-private fun ByteString.rangeEquals(
- offset: Int, other: ByteString, otherOffset: Int = 0,
- byteCount: Int = other.size - otherOffset
-): Boolean {
- val localData = getBackingArrayReference()
- val otherData = other.getBackingArrayReference()
- for (i in 0 until byteCount) {
- if (localData[offset + i] != otherData[otherOffset + i]) {
- return false
- }
- }
- return true
-}
-
-private fun ByteString.rangeEquals(
- offset: Int, other: ByteArray, otherOffset: Int = 0,
- byteCount: Int = other.size - otherOffset
-): Boolean {
- val localData = getBackingArrayReference()
- for (i in 0 until byteCount) {
- if (localData[offset + i] != other[otherOffset + i]) {
- return false
- }
- }
- return true
-}
-
-/**
- * Returns `true` if this byte string is empty.
- */
-public fun ByteString.isEmpty(): Boolean = size == 0
-
-/**
- * Returns `true` if this byte string is not empty.
- */
-public fun ByteString.isNotEmpty(): Boolean = !isEmpty()
-
-/**
- * Decodes content of a byte string into a string using UTF-8 encoding.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.encodeAndDecodeUtf8String
- */
-public fun ByteString.decodeToString(): String {
- return getBackingArrayReference().decodeToString()
-}
-
-/**
- * Encodes a string into a byte sequence using UTF8-encoding and wraps it into a byte string.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.encodeAndDecodeUtf8String
- */
-public fun String.encodeToByteString(): ByteString {
- return ByteString.wrap(encodeToByteArray())
-}
-
-/**
- * Returns `true` if the content of this byte string equals to the [array].
- *
- * @param array the array to test this byte string's content against.
- */
-public fun ByteString.contentEquals(array: ByteArray): Boolean {
- return getBackingArrayReference().contentEquals(array)
-}
diff --git a/bytestring/common/src/ByteStringBuilder.kt b/bytestring/common/src/ByteStringBuilder.kt
deleted file mode 100644
index 7b0de5d3e..000000000
--- a/bytestring/common/src/ByteStringBuilder.kt
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.math.max
-
-/**
- * A helper class facilitating [ByteString] construction.
- *
- * A builder is characterized by the [capacity] - the number of bytes that an instance of builder
- * can receive before extending an underlying byte sequence, and [size] - the number of bytes being written
- * to the builder.
- *
- * The builder avoids additional copies and allocations when `size == capacity` when [toByteString] called,
- * thus it's recommended to specify expected [ByteString] size as `initialCapacity` when creating a builder.
- *
- * When a builder runs out of available capacity, a new byte sequence with extended capacity
- * will be allocated and previously written data will be copied into it.
- *
- * @param initialCapacity the initial size of an underlying byte sequence.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.builderSample
- * @sample kotlinx.io.bytestring.samples.ByteStringSamples.builderSampleWithoutAdditionalAllocs
- */
-public class ByteStringBuilder(initialCapacity: Int = 0) {
- private var buffer = ByteArray(initialCapacity)
- private var offset: Int = 0
-
- /**
- * The number of bytes being written to this builder.
- */
- public val size: Int
- get() = offset
-
- /**
- * The number of bytes this builder can store without an extension of an internal buffer.
- */
- public val capacity: Int
- get() = buffer.size
-
- /**
- * Returns a new [ByteString] wrapping all bytes written to this builder.
- *
- * There will be no additional allocations or copying of data when `size == capacity`.
- */
- public fun toByteString(): ByteString {
- if (size == 0) {
- return ByteString()
- }
- if (buffer.size == size) {
- return ByteString.wrap(buffer)
- }
- return ByteString(buffer, 0, size)
- }
-
- /**
- * Append a single byte to this builder.
- *
- * @param byte the byte to append.
- */
- public fun append(byte: Byte) {
- ensureCapacity(size + 1)
- buffer[offset++] = byte
- }
-
- /**
- * Appends a subarray of [array] starting at [startIndex] and ending at [endIndex] to this builder.
- *
- * @param array the array whose subarray should be appended.
- * @param startIndex the first index (inclusive) to copy data from the [array].
- * @param endIndex the last index (exclusive) to copy data from the [array]
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of [array] array indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- */
- public fun append(array: ByteArray, startIndex: Int = 0, endIndex: Int = array.size) {
- require(startIndex <= endIndex) { "startIndex ($startIndex) > endIndex ($endIndex)" }
- if (startIndex < 0 || endIndex > array.size) {
- throw IndexOutOfBoundsException("startIndex ($startIndex) and endIndex ($endIndex) represents " +
- "an interval out of array's bounds [0..${array.size}).")
- }
- ensureCapacity(offset + endIndex - startIndex)
-
- array.copyInto(buffer, offset, startIndex, endIndex)
- offset += endIndex - startIndex
- }
-
- private fun ensureCapacity(requiredCapacity: Int) {
- if (buffer.size >= requiredCapacity) {
- return
- }
-
- var desiredSize = if (buffer.isEmpty()) 16 else (buffer.size * 1.5).toInt()
- desiredSize = max(desiredSize, requiredCapacity)
- val newBuffer = ByteArray(desiredSize)
- buffer.copyInto(newBuffer)
- buffer = newBuffer
- }
-}
-
-/**
- * Appends unsigned byte to this builder.
- */
-public fun ByteStringBuilder.append(byte: UByte): Unit = append(byte.toByte())
-
-/**
- * Appends a byte string to this builder.
- */
-public fun ByteStringBuilder.append(byteString: ByteString) {
- append(byteString.getBackingArrayReference())
-}
-
-/**
- * Appends bytes to this builder.
- */
-public fun ByteStringBuilder.append(vararg bytes: Byte): Unit = append(bytes)
-
-
-/**
- * Builds new byte string by populating newly created [ByteStringBuilder] initialized with the given [capacity]
- * using provided [builderAction] and then converting it to [ByteString].
- */
-public inline fun buildByteString(capacity: Int = 0, builderAction: ByteStringBuilder.() -> Unit): ByteString {
- return ByteStringBuilder(capacity).apply(builderAction).toByteString()
-}
diff --git a/bytestring/common/src/Hex.kt b/bytestring/common/src/Hex.kt
deleted file mode 100644
index 4ecb46b6e..000000000
--- a/bytestring/common/src/Hex.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-/**
- * Formats bytes in this byte string using the specified [format].
- *
- * Note that only [HexFormat.upperCase] and [HexFormat.BytesHexFormat] affect formatting.
- *
- * @param format the [HexFormat] to use for formatting, [HexFormat.Default] by default.
- *
- * @throws IllegalArgumentException if the result length is more than [String] maximum capacity.
- */
-@ExperimentalStdlibApi
-public fun ByteString.toHexString(format: HexFormat = HexFormat.Default): String {
- return getBackingArrayReference().toHexString(0, getBackingArrayReference().size, format)
-}
-
-/**
- * Formats bytes in this byte string using the specified [HexFormat].
- *
- * Note that only [HexFormat.upperCase] and [HexFormat.BytesHexFormat] affect formatting.
- *
- * @param startIndex the beginning (inclusive) of the subrange to format, 0 by default.
- * @param endIndex the end (exclusive) of the subrange to format, size of this byte string by default.
- * @param format the [HexFormat] to use for formatting, [HexFormat.Default] by default.
- *
- * @throws IndexOutOfBoundsException when [startIndex] or [endIndex] is out of range of this byte string indices.
- * @throws IllegalArgumentException when `startIndex > endIndex`.
- * @throws IllegalArgumentException if the result length is more than [String] maximum capacity.
- */
-@ExperimentalStdlibApi
-public fun ByteString.toHexString(
- startIndex: Int = 0,
- endIndex: Int = size,
- format: HexFormat = HexFormat.Default
-): String {
- return getBackingArrayReference().toHexString(startIndex, endIndex, format)
-}
-
-/**
- * Parses bytes from this string using the specified [HexFormat].
- *
- * Note that only [HexFormat.BytesHexFormat] affects parsing,
- * and parsing is performed in case-insensitive manner.
- * Also, any of the char sequences CRLF, LF and CR is considered a valid line separator.
- *
- * @param format the [HexFormat] to use for parsing, [HexFormat.Default] by default.
- *
- * @throws IllegalArgumentException if this string does not comply with the specified [format].
- */
-@ExperimentalStdlibApi
-public fun String.hexToByteString(format: HexFormat = HexFormat.Default): ByteString {
- return ByteString.wrap(hexToByteArray(format))
-}
diff --git a/bytestring/common/src/unsafe/Annotations.kt b/bytestring/common/src/unsafe/Annotations.kt
deleted file mode 100644
index 41ece7620..000000000
--- a/bytestring/common/src/unsafe/Annotations.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring.unsafe
-
-/**
- * Marks declarations whose usage may brake some ByteString invariants.
- *
- * Consider using other APIs instead when possible.
- * Otherwise, make sure to read documentation describing an unsafe API.
- */
-@MustBeDocumented
-@Retention(AnnotationRetention.BINARY)
-@RequiresOptIn(
- level = RequiresOptIn.Level.ERROR,
- message = "This is a unsafe API and its use may corrupt the data stored in a byte string. " +
- "Make sure you fully read and understand documentation of the declaration that is marked as an unsafe API."
-)
-public annotation class UnsafeByteStringApi
diff --git a/bytestring/common/src/unsafe/UnsafeByteStringOperations.kt b/bytestring/common/src/unsafe/UnsafeByteStringOperations.kt
deleted file mode 100644
index 9865f48c0..000000000
--- a/bytestring/common/src/unsafe/UnsafeByteStringOperations.kt
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring.unsafe
-
-import kotlin.contracts.ExperimentalContracts
-import kotlin.contracts.InvocationKind.EXACTLY_ONCE
-import kotlin.contracts.contract
-import kotlinx.io.bytestring.ByteString
-
-/**
- * Collection of helper functions providing unsafe access to the [ByteString]'s underlying byte sequence or allowing
- * to wrap byte arrays into [ByteString] without copying the array.
- *
- * These functions are provided for performance sensitive cases where it is known that the data accessed
- * in an unsafe manner won't be modified. Modification of the data backing byte strings may lead to unpredicted
- * consequences in the code using the byte string and should be avoided at all costs.
- */
-@UnsafeByteStringApi
-@OptIn(ExperimentalContracts::class)
-public object UnsafeByteStringOperations {
- /**
- * Creates a new byte string by wrapping [array] without copying it.
- * Make sure that the wrapped array won't be modified during the lifespan of the returned byte string.
- *
- * @param array the array to wrap into the byte string.
- */
- public fun wrapUnsafe(array: ByteArray): ByteString = ByteString.wrap(array)
-
- /**
- * Applies [block] to a reference to the underlying array.
- *
- * This method invokes [block] on a reference to the underlying array, not to its copy.
- * Consider using [ByteString.toByteArray] if it's impossible to guarantee that the array won't be modified.
- */
- public inline fun withByteArrayUnsafe(byteString: ByteString, block: (ByteArray) -> Unit) {
- contract {
- callsInPlace(block, EXACTLY_ONCE)
- }
- block(byteString.getBackingArrayReference())
- }
-}
diff --git a/bytestring/common/test/ByteStringBase64Test.kt b/bytestring/common/test/ByteStringBase64Test.kt
deleted file mode 100644
index 482029096..000000000
--- a/bytestring/common/test/ByteStringBase64Test.kt
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-@file:OptIn(ExperimentalEncodingApi::class)
-
-package kotlinx.io.bytestring
-
-import kotlin.io.encoding.Base64
-import kotlin.io.encoding.ExperimentalEncodingApi
-import kotlin.test.*
-
-class ByteStringBase64Test {
- private fun bytes(vararg values: Int): ByteArray {
- return ByteArray(values.size) { values[it].toByte() }
- }
-
-
- private val byteArray: ByteArray = bytes(0b0000_0100, 0b0010_0000, 0b1100_0100, 0b0001_0100, 0b0110_0001, 0b1100_1000)
- private val byteString = ByteString.wrap(byteArray)
-
- private val encodedSymbols = "BCDEFGHI"
- private val encodedBytes = encodedSymbols.encodeToByteArray()
- private val encodedByteString = ByteString.wrap(encodedBytes)
-
-
- @Test
- fun testEncodeToByteArray() {
- assertFailsWith { Base64.encodeToByteArray(byteString, startIndex = -1) }
- assertFailsWith { Base64.encodeToByteArray(byteString, endIndex = byteString.size + 1) }
- assertFailsWith { Base64.encodeToByteArray(byteString, startIndex = byteString.size + 1) }
- assertFailsWith { Base64.encodeToByteArray(byteString, startIndex = 3, endIndex = 0) }
-
- assertTrue(Base64.encodeToByteArray(ByteString.EMPTY).isEmpty())
- assertContentEquals(encodedBytes, Base64.encodeToByteArray(byteString))
-
- assertContentEquals(encodedSymbols.encodeToByteArray(0, 4), Base64.encodeToByteArray(byteString, endIndex = 3))
- assertContentEquals(encodedSymbols.encodeToByteArray(4), Base64.encodeToByteArray(byteString, startIndex = 3))
- }
-
- @Test
- fun testEncodeIntoByteArray() {
- val destination = ByteArray(encodedBytes.size)
-
- assertFailsWith { Base64.encodeIntoByteArray(byteString, destination, destinationOffset = -1) }
- assertFailsWith { Base64.encodeIntoByteArray(byteString, destination, destinationOffset = destination.size + 1) }
- assertFailsWith { Base64.encodeIntoByteArray(byteString, destination, destinationOffset = 1) }
-
- assertEquals(0, Base64.encodeIntoByteArray(ByteString.EMPTY, destination))
- assertEquals(encodedBytes.size, Base64.encodeIntoByteArray(byteString, destination))
- assertContentEquals(encodedBytes, destination.copyOf(encodedBytes.size))
-
- var length = Base64.encodeIntoByteArray(byteString, destination, endIndex = 3)
- assertContentEquals(encodedSymbols.encodeToByteArray(0, 4), destination.copyOf(length))
- length += Base64.encodeIntoByteArray(byteString, destination, destinationOffset = length, startIndex = 3)
- assertContentEquals(encodedSymbols.encodeToByteArray(), destination)
- }
-
- @Test
- fun testEncode() {
- assertFailsWith { Base64.encode(byteString, startIndex = -1) }
- assertFailsWith { Base64.encode(byteString, endIndex = byteString.size + 1) }
- assertFailsWith { Base64.encode(byteString, startIndex = byteString.size + 1) }
- assertFailsWith { Base64.encode(byteString, startIndex = 3, endIndex = 0) }
-
- assertTrue(Base64.encode(ByteArray(0)).isEmpty())
- assertEquals(encodedSymbols, Base64.encode(byteString))
- assertEquals(encodedSymbols.substring(0, 4), Base64.encode(byteString, endIndex = 3))
- assertEquals(encodedSymbols.substring(4), Base64.encode(byteString, startIndex = 3))
-
- val destination = StringBuilder()
- Base64.encodeToAppendable(byteString, destination, endIndex = 3)
- assertEquals(encodedSymbols.substring(0, 4), destination.toString())
- Base64.encodeToAppendable(byteString, destination, startIndex = 3)
- assertEquals(encodedSymbols, destination.toString())
- }
-
- @Test
- fun testDecode() {
- assertFailsWith { Base64.decode(encodedByteString, startIndex = -1) }
- assertFailsWith { Base64.decode(encodedByteString, endIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decode(encodedByteString, startIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decode(encodedByteString, startIndex = 4, endIndex = 0) }
-
- assertEquals(0, Base64.decode(ByteString.EMPTY).size)
- assertContentEquals(byteArray, Base64.decode(encodedByteString))
- assertContentEquals(byteArray.copyOfRange(0, 3), Base64.decode(encodedByteString, endIndex = 4))
- assertContentEquals(byteArray.copyOfRange(3, byteString.size), Base64.decode(encodedByteString, startIndex = 4))
- }
-
- @Test
- fun testDecodeIntoByteArray() {
- val destination = ByteArray(6)
- assertFailsWith { Base64.decodeIntoByteArray(encodedByteString, destination, destinationOffset = -1) }
- assertFailsWith { Base64.decodeIntoByteArray(encodedByteString, destination, destinationOffset = destination.size + 1) }
- assertFailsWith { Base64.decodeIntoByteArray(encodedByteString, destination, destinationOffset = 1) }
-
- assertTrue(destination.all { it == 0.toByte() })
-
- assertEquals(0, Base64.decodeIntoByteArray(ByteString.EMPTY, destination))
-
- var length = Base64.decodeIntoByteArray(encodedByteString, destination, endIndex = 4)
- assertContentEquals(byteArray.copyOfRange(0, 3), destination.copyOf(length))
- length += Base64.decodeIntoByteArray(encodedByteString, destination, destinationOffset = length, startIndex = 4)
- assertContentEquals(byteArray, destination)
- }
-
- @Test
- fun testDecodeToByteString() {
- assertFailsWith { Base64.decodeToByteString(encodedSymbols, startIndex = -1) }
- assertFailsWith { Base64.decodeToByteString(encodedSymbols, endIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedSymbols, startIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedSymbols, startIndex = 4, endIndex = 0) }
-
- assertEquals(0, Base64.decodeToByteString(ByteArray(0)).size)
- assertEquals(byteString, Base64.decodeToByteString(encodedSymbols))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(0, 3)), Base64.decodeToByteString(encodedSymbols, endIndex = 4))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(3, byteString.size)), Base64.decodeToByteString(encodedSymbols, startIndex = 4))
- }
-
- @Test
- fun testByteArrayDecodeToByteString() {
- assertFailsWith { Base64.decodeToByteString(encodedBytes, startIndex = -1) }
- assertFailsWith { Base64.decodeToByteString(encodedBytes, endIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedBytes, startIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedBytes, startIndex = 4, endIndex = 0) }
-
- assertEquals(0, Base64.decodeToByteString(ByteArray(0)).size)
- assertEquals(byteString, Base64.decodeToByteString(encodedBytes))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(0, 3)), Base64.decodeToByteString(encodedBytes, endIndex = 4))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(3, byteString.size)), Base64.decodeToByteString(encodedBytes, startIndex = 4))
- }
-
- @Test
- fun testByteStringDecodeToByteString() {
- assertFailsWith { Base64.decodeToByteString(encodedByteString, startIndex = -1) }
- assertFailsWith { Base64.decodeToByteString(encodedByteString, endIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedByteString, startIndex = encodedByteString.size + 1) }
- assertFailsWith { Base64.decodeToByteString(encodedByteString, startIndex = 4, endIndex = 0) }
-
- assertEquals(0, Base64.decodeToByteString(ByteString.EMPTY).size)
- assertEquals(byteString, Base64.decodeToByteString(encodedByteString))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(0, 3)), Base64.decodeToByteString(encodedByteString, endIndex = 4))
- assertEquals(ByteString.wrap(byteArray.copyOfRange(3, byteString.size)), Base64.decodeToByteString(encodedByteString, startIndex = 4))
- }
-}
diff --git a/bytestring/common/test/ByteStringBuilderTest.kt b/bytestring/common/test/ByteStringBuilderTest.kt
deleted file mode 100644
index 2fbb05408..000000000
--- a/bytestring/common/test/ByteStringBuilderTest.kt
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
-import kotlin.test.assertTrue
-
-class ByteStringBuilderTest {
- @Test
- fun emptyString() {
- assertTrue(ByteStringBuilder().toByteString().isEmpty())
- assertTrue(ByteStringBuilder(1024).toByteString().isEmpty())
- }
-
- @Test
- fun appendByte() {
- val builder = ByteStringBuilder()
- with(builder) {
- append(1)
- append(2)
- append(3)
- }
- assertEquals(ByteString(1, 2, 3), builder.toByteString())
- }
-
- @Test
- fun appendBytes() {
- assertEquals(ByteString(1, 2, 3), buildByteString { append(1, 2, 3) })
- }
-
- @Test
- fun appendUByte() {
- val builder = ByteStringBuilder()
- with(builder) {
- append(0x80U)
- append(0x81U)
- append(0x82U)
- }
- assertEquals(ByteString(0x80U.toByte(), 0x81U.toByte(), 0x82U.toByte()), builder.toByteString())
- }
-
- @Test
- fun appendArray() {
- with(ByteStringBuilder()) {
- append(byteArrayOf(1, 2, 3, 4))
- assertEquals(ByteString(1, 2, 3, 4), toByteString())
- }
-
- with(ByteStringBuilder()) {
- append(byteArrayOf(1, 2, 3, 4), startIndex = 2)
- assertEquals(ByteString(3, 4), toByteString())
- }
-
- with(ByteStringBuilder()) {
- append(byteArrayOf(1, 2, 3, 4), endIndex = 2)
- assertEquals(ByteString(1, 2), toByteString())
- }
-
- with(ByteStringBuilder()) {
- append(byteArrayOf(1, 2, 3, 4), startIndex = 1, endIndex = 3)
- assertEquals(ByteString(2, 3), toByteString())
- }
-
- with(ByteStringBuilder()) {
- append(byteArrayOf(1, 2, 3, 4), startIndex = 1, endIndex = 1)
- assertEquals(ByteString(), toByteString())
- }
- }
-
- @Test
- fun testAppendByteArrayWithInvalidIndices() {
- val builder = ByteStringBuilder()
- val array = ByteArray(10)
- assertFailsWith { builder.append(array, 2, 0) }
- assertFailsWith { builder.append(array, -1, 2) }
- assertFailsWith { builder.append(array, 0, 1000) }
- assertFailsWith { builder.append(array, 1000, 1001) }
- }
-
- @Test
- fun appendByteString() {
- val builder = ByteStringBuilder()
- builder.append(ByteString(1, 2, 3, 4))
- assertEquals(ByteString(1, 2, 3, 4), builder.toByteString())
- }
-
- @Test
- fun appendMultipleValues() {
- val string = with(ByteStringBuilder()) {
- append(42)
- append(ByteArray(10) { it.toByte() })
- append(42U)
- append(ByteString(10, 5, 57))
- toByteString()
- }
-
- assertEquals(ByteString(42, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 42, 10, 5, 57), string)
- }
-
- @Test
- fun resizeMultipleTimes() {
- val builder = ByteStringBuilder()
- builder.append(ByteArray(1))
- builder.append(ByteArray(32))
- builder.append(ByteArray(120))
- builder.append(ByteArray(1024))
-
- assertEquals(ByteString(ByteArray(1 + 32 + 120 + 1024)), builder.toByteString())
- }
-
- @Test
- fun testSize() {
- val builder = ByteStringBuilder()
- assertEquals(0, builder.size)
- builder.append(1)
- assertEquals(1, builder.size)
- builder.append(ByteArray(33))
- assertEquals(34, builder.size)
- }
-
- @Test
- fun testCapacity() {
- assertEquals(0, ByteStringBuilder().capacity)
- assertEquals(10, ByteStringBuilder(10).capacity)
-
- with(ByteStringBuilder()) {
- append(1)
- assertTrue(capacity >= 1)
- append(ByteArray(1024))
- assertTrue(capacity >= 1025)
- }
- }
-
- @Test
- fun createMultipleByteStrings() {
- val builder = ByteStringBuilder()
- builder.append(1)
- val str0 = builder.toByteString()
- assertEquals(ByteString(1), str0)
- assertEquals(ByteString(1), builder.toByteString())
- builder.append(2)
- assertEquals(ByteString(1, 2), builder.toByteString())
- assertEquals(ByteString(1), str0)
- }
-}
diff --git a/bytestring/common/test/ByteStringHexTest.kt b/bytestring/common/test/ByteStringHexTest.kt
deleted file mode 100644
index cd249a050..000000000
--- a/bytestring/common/test/ByteStringHexTest.kt
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-@file:OptIn(ExperimentalStdlibApi::class)
-
-package kotlinx.io.bytestring
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFails
-import kotlin.test.assertTrue
-
-class ByteStringHexTest {
- private val byteString = ByteString.wrap(byteArrayOf(10, 11, 12, 13, 14, 15))
-
- @Test
- fun testEmpty() {
- assertTrue(ByteString.EMPTY.toHexString().isEmpty())
- assertTrue("".hexToByteString().isEmpty())
- }
-
- @Test
- fun testIndexes() {
- assertEquals("0b0c", byteString.toHexString(1, 3))
- assertEquals("0c0d0e0f", byteString.toHexString(2))
- assertEquals("0a0b0c0d", byteString.toHexString(endIndex = 4))
-
- assertFails { byteString.toHexString(-1) }
- assertFails { byteString.toHexString(endIndex = -1) }
- assertFails { byteString.toHexString(3, 2) }
- assertFails { byteString.toHexString(10) }
- assertFails { byteString.toHexString(endIndex = 11) }
- assertFails { byteString.toHexString(10, 11) }
- }
-
- @Test
- fun testFormats() {
- val format = HexFormat {
- bytes {
- byteSeparator = "|"
- }
- }
- assertEquals("0a|0b|0c|0d|0e|0f", byteString.toHexString(format))
- assertEquals("0b|0c|0d", byteString.toHexString(1, 4, format))
-
- assertEquals(byteString, "0a|0b|0c|0d|0e|0f".hexToByteString(format))
- assertFails { "0a0b0c0d0e0f".hexToByteString(format) }
- }
-
- @Test
- fun testDefault() {
- assertEquals("0a0b0c0d0e0f", byteString.toHexString())
- assertEquals("0b0c0d", byteString.toHexString(1, 4))
-
- assertEquals(byteString, "0a0b0c0d0e0f".hexToByteString())
- assertFails { "0a|0b|0c|0d|0e|0f".hexToByteString() }
- }
-
-}
diff --git a/bytestring/common/test/ByteStringTest.kt b/bytestring/common/test/ByteStringTest.kt
deleted file mode 100644
index 5aefaf5f5..000000000
--- a/bytestring/common/test/ByteStringTest.kt
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.test.*
-
-class ByteStringTest {
- @Test
- fun get() {
- val actual = ByteString("abc".encodeToByteArray())
- assertEquals(3, actual.size)
- assertEquals(actual[0], 'a'.code.toByte())
- assertEquals(actual[1], 'b'.code.toByte())
- assertEquals(actual[2], 'c'.code.toByte())
- }
-
- @Test
- fun getWithInvalidIndex() {
- val str = ByteString(0, 1, 2)
- assertFailsWith { str[-1] }
- assertFailsWith { str[3] }
- }
-
- @Test
- fun equalsAndHashCode() {
- with(ByteString(1, 2, 3)) { checkEqualsAndHashCodeAreSame(this, this) }
- checkEqualsAndHashCodeAreSame(ByteString(), ByteString(byteArrayOf()))
- checkEqualsAndHashCodeAreSame(ByteString(1, 2, 3), ByteString(1, 2, 3))
-
- assertNotEquals(ByteString(1, 2, 3), ByteString(3, 2, 1))
- assertNotEquals(ByteString(1, 2, 3).hashCode(), ByteString(3, 2, 1).hashCode())
-
- assertNotEquals(ByteString(1, 2, 3, 4), ByteString(1, 2, 3))
-
- val str1 = ByteString(1, 2, 3)
- val str2 = ByteString(2, 3, 4)
- // force hashCode computation
- assertNotEquals(str1.hashCode(), str2.hashCode())
- assertNotEquals(str1, str2)
-
- assertFalse(ByteString().equals(null))
- assertFalse(ByteString().equals(byteArrayOf(1, 2, 3)))
- }
-
- private fun checkEqualsAndHashCodeAreSame(first: ByteString, second: ByteString) {
- assertEquals(first, second)
- assertEquals(first.hashCode(), second.hashCode())
- }
-
- @Test
- fun toByteArray() {
- val str = ByteString(1, 2, 3, 4, 5, 6)
- assertContentEquals(byteArrayOf(1, 2, 3, 4, 5, 6), str.toByteArray())
- assertContentEquals(byteArrayOf(), str.toByteArray(0, 0))
- assertContentEquals(byteArrayOf(1, 2, 3), str.toByteArray(endIndex = 3))
- assertContentEquals(byteArrayOf(4, 5, 6), str.toByteArray(startIndex = 3))
- assertContentEquals(byteArrayOf(2, 3, 4), str.toByteArray(startIndex = 1, endIndex = 4))
- }
-
- @Test
- fun toByteArrayWithInvalidIndex() {
- val str = ByteString(1, 2, 3)
- assertFailsWith { str.toByteArray(-1, 1) }
- assertFailsWith { str.toByteArray(1, 4) }
- assertFailsWith { str.toByteArray(-1, 4) }
- assertFailsWith { str.toByteArray(2, 0) }
- }
-
- @Test
- fun copyTo() {
- val str = ByteString(1, 2, 3, 4, 5, 6)
- val dest = ByteArray(10)
-
- str.copyInto(dest)
- assertContentEquals(byteArrayOf(1, 2, 3, 4, 5, 6, 0, 0, 0, 0), dest)
-
- dest.fill(0)
- str.copyInto(dest, 2)
- assertContentEquals(byteArrayOf(0, 0, 1, 2, 3, 4, 5, 6, 0, 0), dest)
-
- dest.fill(0)
- str.copyInto(dest, destinationOffset = 0, startIndex = 1)
- assertContentEquals(byteArrayOf(2, 3, 4, 5, 6, 0, 0, 0, 0, 0), dest)
-
- dest.fill(0)
- str.copyInto(dest, destinationOffset = 0, endIndex = 3)
- assertContentEquals(byteArrayOf(1, 2, 3, 0, 0, 0, 0, 0, 0, 0), dest)
-
- dest.fill(0)
- str.copyInto(dest, destinationOffset = 0, startIndex = 3, endIndex = 5)
- assertContentEquals(byteArrayOf(4, 5, 0, 0, 0, 0, 0, 0, 0, 0), dest)
-
- dest.fill(0)
- str.copyInto(dest, destinationOffset = 5, endIndex = 5)
- assertContentEquals(byteArrayOf(0, 0, 0, 0, 0, 1, 2, 3, 4, 5), dest)
-
- dest.fill(0)
- str.copyInto(dest, startIndex = 3, endIndex = 3)
- assertContentEquals(ByteArray(10), dest)
- }
-
- @Test
- fun copyToWithInvalidArguments() {
- val str = ByteString(1, 2, 3)
- val dest = ByteArray(10)
-
- assertFailsWith { str.copyInto(dest, 0, startIndex = 1, endIndex = 0) }
- assertFailsWith { str.copyInto(dest, 9) }
- assertFailsWith { str.copyInto(dest, -1) }
- assertFailsWith { str.copyInto(dest, 0, startIndex = -1) }
- assertFailsWith { str.copyInto(dest, 0, endIndex = 5) }
- }
-
- @Test
- fun substring() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertEquals(ByteString(), str.substring(0, 0))
- assertEquals(ByteString(1, 2, 3), str.substring(startIndex = 0, endIndex = 3))
- assertEquals(ByteString(3, 4, 5), str.substring(startIndex = 2))
- assertEquals(ByteString(2, 3, 4), str.substring(startIndex = 1, endIndex = 4))
- }
-
- @Test
- fun substringWithInvalidArgs() {
- val str = ByteString(1, 2, 3)
-
- assertFailsWith { str.substring(2, 1) }
- assertFailsWith { str.substring(-1) }
- assertFailsWith { str.substring(0, 10) }
- assertFailsWith { str.substring(-10, 10) }
- }
-
- @Test
- fun compareTo() {
- assertEquals(0, ByteString().compareTo(ByteString()))
- assertEquals(0, ByteString(1, 2, 3).compareTo(ByteString(1, 2, 3)))
- assertEquals(-1, ByteString(1, 2).compareTo(ByteString(1, 2, 3)))
- assertEquals(-1, ByteString(0, 1, 2).compareTo(ByteString(0, 1, 3)))
- assertEquals(1, ByteString(1, 2, 3).compareTo(ByteString(1, 2)))
- assertEquals(1, ByteString(1, 2, 3).compareTo(ByteString(0, 1, 2)))
- assertEquals(1, ByteString(0xFF.toByte()).compareTo(ByteString(0)))
- assertEquals(-1, ByteString(1).compareTo(ByteString(0x81.toByte())))
- }
-
- @Test
- fun size() {
- assertEquals(0, ByteString().size)
- assertEquals(1, ByteString(0).size)
- assertEquals(12345, ByteString(ByteArray(12345)).size)
- }
-
- @Test
- fun indices() {
- assertEquals(0 until 10, ByteString(ByteArray(10)).indices)
- assertTrue(ByteString().indices.isEmpty())
- }
-
- @Test
- fun isEmpty() {
- assertTrue(ByteString().isEmpty())
- assertTrue(ByteString(byteArrayOf()).isEmpty())
- assertFalse(ByteString(byteArrayOf(0)).isEmpty())
- }
-
- @Test
- fun isNotEmpty() {
- assertFalse(ByteString().isNotEmpty())
- assertFalse(ByteString(byteArrayOf()).isNotEmpty())
- assertTrue(ByteString(byteArrayOf(0)).isNotEmpty())
- }
-
- @Test
- fun indexOfByte() {
- val str = ByteString(1, 2, 3, 4)
- for (idx in str.indices) {
- assertEquals(idx, str.indexOf(str[idx]))
- }
-
- assertEquals(-1, str.indexOf(0))
- assertEquals(-1, str.indexOf(1, 1))
- assertEquals(-1, str.indexOf(4, 4))
- assertEquals(0, str.indexOf(1, -10))
- assertEquals(1, ByteString(0, 1, 1, 1).indexOf(1))
-
- assertEquals(-1, ByteString().indexOf(0))
- assertEquals(-1, ByteString().indexOf(0, 100500))
- assertEquals(-1, str.indexOf(1, 100500))
- }
-
- @Test
- fun indexOfByteArray() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertEquals(0, str.indexOf(byteArrayOf(1, 2, 3, 4, 5)))
- assertEquals(0, str.indexOf(byteArrayOf(1, 2, 3)))
- assertEquals(0, str.indexOf(byteArrayOf(1)))
-
- assertEquals(2, str.indexOf(byteArrayOf(3, 4, 5)))
- assertEquals(-1, str.indexOf(byteArrayOf(3, 4, 5, 6)))
- assertEquals(0, str.indexOf(byteArrayOf()))
- assertEquals(-1, str.indexOf(byteArrayOf(-1)))
-
- assertEquals(-1, str.indexOf(byteArrayOf(1, 2, 3, 4, 5), 1))
- assertEquals(3, str.indexOf(byteArrayOf(4, 5), 3))
-
- assertEquals(0, str.indexOf(byteArrayOf(1, 2, 3), -1000))
- assertEquals(1, str.indexOf(byteArrayOf(2, 3), -1))
-
- assertEquals(1, ByteString(0, 1, 0, 1, 0, 1).indexOf(byteArrayOf(1, 0)))
-
- assertEquals(0, ByteString().indexOf(byteArrayOf()))
- assertEquals(0, ByteString().indexOf(byteArrayOf(), -100500))
- assertEquals(0, ByteString().indexOf(byteArrayOf(), 100500))
- assertEquals(-1, str.indexOf(byteArrayOf(1, 2, 3), 100500))
- assertEquals(-1, ByteString().indexOf(byteArrayOf(1, 2, 3, 4, 5)))
- assertEquals(-1, str.indexOf(byteArrayOf(2, 3, 5)))
- }
-
- @Test
- fun indexOfByteString() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertEquals(0, str.indexOf(ByteString(1, 2, 3, 4, 5)))
- assertEquals(0, str.indexOf(ByteString(1, 2, 3)))
- assertEquals(0, str.indexOf(ByteString(1)))
- assertEquals(2, str.indexOf(ByteString(3, 4, 5)))
- assertEquals(-1, str.indexOf(ByteString(3, 4, 5, 6)))
- assertEquals(0, str.indexOf(ByteString()))
- assertEquals(-1, str.indexOf(ByteString(-1)))
- assertEquals(-1, str.indexOf(ByteString(1, 2, 3, 4, 5), 1))
- assertEquals(3, str.indexOf(ByteString(4, 5), 3))
- assertEquals(0, str.indexOf(ByteString(1, 2, 3), -1000))
- assertEquals(1, str.indexOf(ByteString(2, 3), -1))
- assertEquals(1, ByteString(0, 1, 0, 1, 0, 1).indexOf(ByteString(1, 0)))
- assertEquals(0, ByteString().indexOf(ByteString()))
- assertEquals(0, ByteString().indexOf(ByteString(), -100500))
- assertEquals(0, ByteString().indexOf(ByteString(), 100500))
- assertEquals(-1, str.indexOf(ByteString(1, 2, 3), 100500))
- assertEquals(-1, ByteString().indexOf(ByteString(1, 2, 3, 4, 5)))
- assertEquals(-1, str.indexOf(ByteString(2, 3, 5)))
- }
-
- @Test
- fun lastIndexOfByte() {
- val str = ByteString(1, 2, 3, 4)
- for (idx in str.indices) {
- assertEquals(idx, str.lastIndexOf(str[idx]))
- }
-
- assertEquals(-1, str.lastIndexOf(0))
- assertEquals(-1, str.lastIndexOf(1, 1))
- assertEquals(-1, str.lastIndexOf(4, 4))
- assertEquals(0, str.lastIndexOf(1, -10))
- assertEquals(3, ByteString(0, 1, 1, 1, 0).lastIndexOf(1))
-
- assertEquals(-1, ByteString().lastIndexOf(0))
- assertEquals(-1, ByteString().lastIndexOf(0, 100500))
- assertEquals(-1, str.lastIndexOf(1, 1005000))
- }
-
- @Test
- fun lastIndexOfByteArray() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertEquals(0, str.lastIndexOf(byteArrayOf(1, 2, 3, 4, 5)))
- assertEquals(0, str.lastIndexOf(byteArrayOf(1, 2, 3)))
- assertEquals(-1, str.lastIndexOf(byteArrayOf(0, 1, 2)))
- assertEquals(2, str.lastIndexOf(byteArrayOf(3, 4, 5)))
- assertEquals(-1, str.lastIndexOf(byteArrayOf(1, 2, 3), 1))
- assertEquals(1, str.lastIndexOf(byteArrayOf(2, 3, 4), 1))
- assertEquals(str.size, str.lastIndexOf(byteArrayOf()))
- assertEquals(str.size, str.lastIndexOf(byteArrayOf()))
- assertEquals(2, str.lastIndexOf(byteArrayOf(3, 4), -1000))
- assertEquals(0, str.lastIndexOf(byteArrayOf(1), -1))
- assertEquals(4, ByteString(1, 1, 1, 1, 1).lastIndexOf(byteArrayOf(1)))
- assertEquals(3, ByteString(0, 1, 0, 1, 0).lastIndexOf(byteArrayOf(1, 0)))
- assertEquals(0, ByteString().lastIndexOf(byteArrayOf()))
- assertEquals(0, ByteString().lastIndexOf(byteArrayOf(), -100500))
- assertEquals(0, ByteString().lastIndexOf(byteArrayOf(), 100500))
- assertEquals(-1, str.lastIndexOf(byteArrayOf(1, 2, 3), 100500))
- assertEquals(-1, ByteString().lastIndexOf(byteArrayOf(1, 2, 3)))
- assertEquals(-1, str.lastIndexOf(byteArrayOf(2, 3, 5)))
- }
-
- @Test
- fun lastIndexOfByteString() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertEquals(0, str.lastIndexOf(ByteString(1, 2, 3, 4, 5)))
- assertEquals(0, str.lastIndexOf(ByteString(1, 2, 3)))
- assertEquals(-1, str.lastIndexOf(ByteString(0, 1, 2)))
- assertEquals(2, str.lastIndexOf(ByteString(3, 4, 5)))
- assertEquals(-1, str.lastIndexOf(ByteString(1, 2, 3), 1))
- assertEquals(1, str.lastIndexOf(ByteString(2, 3, 4), 1))
- assertEquals(str.size, str.lastIndexOf(ByteString()))
- assertEquals(str.size, str.lastIndexOf(ByteString()))
- assertEquals(2, str.lastIndexOf(ByteString(3, 4), -1000))
- assertEquals(0, str.lastIndexOf(ByteString(1), -1))
- assertEquals(4, ByteString(1, 1, 1, 1, 1).lastIndexOf(ByteString(1)))
- assertEquals(3, ByteString(0, 1, 0, 1, 0).lastIndexOf(ByteString(1, 0)))
- assertEquals(0, ByteString().lastIndexOf(ByteString()))
- assertEquals(0, ByteString().lastIndexOf(ByteString(), -100500))
- assertEquals(0, ByteString().lastIndexOf(ByteString(), 100500))
- assertEquals(-1, str.lastIndexOf(ByteString(1, 2, 3), 100500))
- assertEquals(-1, ByteString().lastIndexOf(ByteString(1, 2, 3)))
- assertEquals(-1, str.lastIndexOf(ByteString(2, 3, 5)))
- }
-
- @Test
- fun startsWithByteArray() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(str.startsWith(byteArrayOf(1, 2, 3, 4, 5)))
- assertTrue(str.startsWith(byteArrayOf(1, 2, 3)))
-
- assertTrue(str.startsWith(byteArrayOf()))
-
- assertFalse(str.startsWith(byteArrayOf(0, 1, 2, 3)))
- assertFalse(str.startsWith(byteArrayOf(2, 3, 4)))
- assertFalse(str.startsWith(byteArrayOf(1, 2, 3, 4, 5, 6)))
-
- assertTrue(ByteString().startsWith(byteArrayOf()))
- }
-
- @Test
- fun startWithByteString() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(str.startsWith(ByteString(1, 2, 3, 4, 5)))
- assertTrue(str.startsWith(ByteString(1, 2, 3)))
-
- assertTrue(str.startsWith(ByteString()))
-
- assertFalse(str.startsWith(ByteString(0, 1, 2, 3)))
- assertFalse(str.startsWith(ByteString(2, 3, 4)))
- assertFalse(str.startsWith(ByteString(1, 2, 3, 4, 5, 6)))
-
- assertTrue(ByteString().startsWith(ByteString()))
- }
-
- @Test
- fun endsWithByteArray() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(str.endsWith(byteArrayOf(1, 2, 3, 4, 5)))
- assertTrue(str.endsWith(byteArrayOf(3, 4, 5)))
-
- assertTrue(str.endsWith(byteArrayOf()))
-
- assertFalse(str.endsWith(byteArrayOf(3, 4, 5, 6)))
- assertFalse(str.endsWith(byteArrayOf(0, 1, 2, 3, 4, 5)))
- assertFalse(str.endsWith(byteArrayOf(2, 3, 4)))
-
- assertTrue(ByteString().endsWith(byteArrayOf()))
- }
-
- @Test
- fun endsWithByteString() {
- val str = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(str.endsWith(ByteString(1, 2, 3, 4, 5)))
- assertTrue(str.endsWith(ByteString(3, 4, 5)))
-
- assertTrue(str.endsWith(ByteString()))
-
- assertFalse(str.endsWith(ByteString(3, 4, 5, 6)))
- assertFalse(str.endsWith(ByteString(0, 1, 2, 3, 4, 5)))
- assertFalse(str.endsWith(ByteString(2, 3, 4)))
-
- assertTrue(ByteString().endsWith(ByteString()))
- }
-
- @Test
- fun testToString() {
- assertEquals("ByteString(size=0)", ByteString().toString())
- assertEquals("ByteString(size=1 hex=00)", ByteString(0).toString())
- assertEquals(
- "ByteString(size=16 hex=000102030405060708090a0b0c0d0e0f)",
- ByteString(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).toString()
- )
- assertEquals(
- "ByteString(size=64 hex=0000000000000000000000000000000000000000000000000000000000000000" +
- "0000000000000000000000000000000000000000000000000000000000000000)",
- ByteString(ByteArray(64)).toString()
- )
- }
-
- private val bronzeHorseman = "На берегу пустынных волн"
-
- @Test
- fun utf8() {
- val byteString = bronzeHorseman.encodeToByteString()
- assertEquals(byteString.toByteArray().toList(), bronzeHorseman.encodeToByteArray().toList())
- assertEquals(byteString, ByteString(*bronzeHorseman.encodeToByteArray()))
- assertEquals(byteString.decodeToString(), bronzeHorseman)
- }
-
- @Test
- fun contentEquals() {
- assertTrue(ByteString().contentEquals(byteArrayOf()))
- assertFalse(ByteString(1, 2, 3).contentEquals(byteArrayOf()))
- assertFalse(ByteString().contentEquals(byteArrayOf(1, 2, 3)))
-
- assertTrue(ByteString(1, 2, 3, 4, 5).contentEquals(byteArrayOf(1, 2, 3, 4, 5)))
- assertFalse(ByteString(1, 2, 3, 4, 5).contentEquals(byteArrayOf(1, 2, 3, 4, 4)))
- assertFalse(ByteString(1, 2, 3, 4, 5).contentEquals(byteArrayOf(1, 2, 3, 4, 5, 6)))
- assertFalse(ByteString(1, 2, 3, 4, 5, 6).contentEquals(byteArrayOf(1, 2, 3, 4, 5)))
- }
-
- @OptIn(ExperimentalUnsignedTypes::class)
- @Test
- fun fromUBytes() {
- val str = ByteString(0xDEu, 0xADu, 0xC0u, 0xDEu)
- assertContentEquals(
- byteArrayOf(0xDE.toByte(), 0xAD.toByte(), 0xC0u.toByte(), 0xDEu.toByte()),
- str.toByteArray()
- )
- }
-}
diff --git a/bytestring/common/test/samples/samples.kt b/bytestring/common/test/samples/samples.kt
deleted file mode 100644
index 06fe8079c..000000000
--- a/bytestring/common/test/samples/samples.kt
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring.samples
-
-import kotlinx.io.bytestring.*
-import kotlin.test.*
-
-class ByteStringSamples {
- @Test
- fun compareTo() {
- assertTrue(ByteString(1, 2, 3) == ByteString(1, 2, 3))
- assertTrue(ByteString(1, 2, 3) <= ByteString(1, 2, 3))
- assertTrue(ByteString(1, 2, 3) >= ByteString(1, 2, 3))
- assertTrue(ByteString(1, 2, 3) < ByteString(1, 3, 2))
-
- // If byte strings have different length, their content compared up to the length of the shortest string,
- // and if their content was the same, then the shortest string is considered "smaller"
- assertTrue(ByteString() < ByteString(1, 2, 3))
- assertTrue(ByteString(1, 2, 3) > ByteString(1))
- assertTrue(ByteString(1, 2, 3) < ByteString(1, 3))
- assertTrue(ByteString(1, 2, 3) > ByteString(1, 1, 1, 1))
- }
-
- @Test
- fun toStringSample() {
- assertEquals("ByteString(size=0)", ByteString().toString())
- assertEquals("ByteString(size=3 hex=000102)", ByteString(0, 1, 2).toString())
- }
-
- @Test
- fun substringSample() {
- val string = ByteString(1, 2, 3, 4, 5)
- assertEquals(ByteString(1, 2, 3), string.substring(startIndex = 0, endIndex = 3))
- assertEquals(ByteString(3, 4, 5), string.substring(startIndex = 2))
- assertEquals(ByteString(2, 3, 4), string.substring(startIndex = 1, endIndex = 4))
- }
-
- @Test
- fun toByteArraySample() {
- val string = ByteString(1, 2, 3, 4, 5)
- val array = string.toByteArray()
-
- assertContentEquals(byteArrayOf(1, 2, 3, 4, 5), array)
-
- // Array is a copy of the byte string's content, so its modification won't affect the string.
- for (idx in array.indices) {
- array[idx] = (array[idx] * 2).toByte()
- }
- assertEquals(ByteString(1, 2, 3, 4, 5), string)
- }
-
- @Test
- fun toByteArrayWithIndicesSample() {
- val string = ByteString(1, 2, 3, 4, 5)
-
- assertContentEquals(byteArrayOf(2, 3, 4), string.toByteArray(startIndex = 1, endIndex = 4))
- assertContentEquals(byteArrayOf(4, 5), string.toByteArray(startIndex = 3))
- }
-
- @Test
- fun copyToSample() {
- val string = ByteString(1, 2, 3, 4, 5)
- val array = ByteArray(10)
-
- string.copyInto(array, destinationOffset = 3, startIndex = 1, endIndex = 4)
- assertContentEquals(byteArrayOf(0, 0, 0, 2, 3, 4, 0, 0, 0, 0), array)
- }
-
- @Test
- fun indexOfByteSample() {
- val string = ByteString(1, 2, 3, 2, 1)
-
- assertEquals(1, string.indexOf(2))
- assertEquals(3, string.indexOf(2, startIndex = 2))
- assertEquals(-1, string.indexOf(0))
- }
-
- @Test
- fun lastIndexOfByteSample() {
- val string = ByteString(1, 2, 3, 2, 1)
-
- assertEquals(3, string.lastIndexOf(2))
- assertEquals(-1, string.lastIndexOf(2, startIndex = 4))
- assertEquals(-1, string.indexOf(0))
- }
-
- @Test
- fun indexOfByteStringSample() {
- val string = ByteString(1, 2, 3, 4, 1, 3, 4)
-
- assertEquals(2, string.indexOf(ByteString(3, 4)))
- assertEquals(5, string.indexOf(ByteString(3, 4), startIndex = 3))
- assertEquals(-1, string.indexOf(ByteString(1, 1, 1)))
- assertEquals(-1, string.indexOf(ByteString(1, 3, 4, 5)))
- assertEquals(0, string.indexOf(ByteString(/* empty byte string */)))
- }
-
- @Test
- fun lastIndexOfByteStringSample() {
- val string = ByteString(1, 2, 3, 4, 1, 3, 4)
-
- assertEquals(5, string.lastIndexOf(ByteString(3, 4)))
- assertEquals(-1, string.lastIndexOf(ByteString(1, 2), startIndex = 3))
- assertEquals(0, string.lastIndexOf(ByteString(1, 2, 3)))
- assertEquals(-1, string.lastIndexOf(ByteString(1, 3, 4, 5)))
- assertEquals(string.size, string.lastIndexOf(ByteString(/* empty byte string */)))
- }
-
- @Test
- fun indexOfByteArraySample() {
- val string = ByteString(1, 2, 3, 4, 1, 3, 4)
-
- assertEquals(2, string.indexOf(byteArrayOf(3, 4)))
- assertEquals(5, string.indexOf(byteArrayOf(3, 4), startIndex = 3))
- assertEquals(-1, string.indexOf(byteArrayOf(1, 1, 1)))
- assertEquals(-1, string.indexOf(byteArrayOf(1, 3, 4, 5)))
- assertEquals(0, string.indexOf(byteArrayOf(/* empty byte array */)))
- }
-
- @Test
- fun lastIndexOfByteArraySample() {
- val string = ByteString(1, 2, 3, 4, 1, 3, 4)
-
- assertEquals(5, string.lastIndexOf(byteArrayOf(3, 4)))
- assertEquals(-1, string.lastIndexOf(byteArrayOf(1, 2), startIndex = 3))
- assertEquals(0, string.lastIndexOf(byteArrayOf(1, 2, 3)))
- assertEquals(-1, string.lastIndexOf(byteArrayOf(1, 3, 4, 5)))
- assertEquals(string.size, string.lastIndexOf(byteArrayOf(/* empty byte array */)))
- }
-
- @Test
- fun startsWithByteStringSample() {
- val string = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(string.startsWith(string))
- assertTrue(string.startsWith(ByteString(/* empty byte string */)))
- assertTrue(string.startsWith(ByteString(1, 2, 3)))
- assertFalse(string.startsWith(ByteString(1, 3, 4)))
- assertFalse(string.startsWith(ByteString(1, 2, 3, 4, 5, 6)))
- }
-
- @Test
- fun endsWithByteStringSample() {
- val string = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(string.endsWith(string))
- assertTrue(string.endsWith(ByteString(/* empty byte string */)))
- assertTrue(string.endsWith(ByteString(3, 4, 5)))
- assertFalse(string.endsWith(ByteString(2, 4, 5)))
- assertFalse(string.endsWith(ByteString(0, 1, 2, 3, 4, 5)))
- }
-
- @Test
- fun startsWithByteArraySample() {
- val string = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(string.startsWith(byteArrayOf(1, 2, 3, 4, 5)))
- assertTrue(string.startsWith(byteArrayOf(/* empty byte array */)))
- assertTrue(string.startsWith(byteArrayOf(1, 2, 3)))
- assertFalse(string.startsWith(byteArrayOf(1, 3, 4)))
- assertFalse(string.startsWith(byteArrayOf(1, 2, 3, 4, 5, 6)))
- }
-
- @Test
- fun endsWithByteArraySample() {
- val string = ByteString(1, 2, 3, 4, 5)
-
- assertTrue(string.endsWith(byteArrayOf(1, 2, 3, 4, 5)))
- assertTrue(string.endsWith(byteArrayOf(/* empty byte array */)))
- assertTrue(string.endsWith(byteArrayOf(3, 4, 5)))
- assertFalse(string.endsWith(byteArrayOf(2, 4, 5)))
- assertFalse(string.endsWith(byteArrayOf(0, 1, 2, 3, 4, 5)))
- }
-
- @Test
- fun constructionSample() {
- val array = byteArrayOf(1, 2, 3)
- val byteStringFromArray = ByteString(array)
- array[1] = -1
- // The modification of the source array won't affect the content of the string.
- assertContentEquals(byteArrayOf(1, 2, 3), byteStringFromArray.toByteArray())
-
- val largeArray = byteArrayOf(1, 2, 3, 4 /*, ... */)
- val byteStringFromSubarray = ByteString(largeArray, startIndex = 1, endIndex = 3)
- assertContentEquals(byteArrayOf(2, 3), byteStringFromSubarray.toByteArray())
- }
-
- @Test
- fun constructionFromBytesSample() {
- val emptyByteString = ByteString()
- assertTrue(emptyByteString.isEmpty())
- assertEquals(0, emptyByteString.size)
-
- val byteStringFromBytes = ByteString(1, 2, 3)
- assertFalse(byteStringFromBytes.isEmpty())
- assertEquals(3, byteStringFromBytes.size)
- }
-
- @OptIn(ExperimentalUnsignedTypes::class)
- @Test
- fun constructionFromUBytesSample() {
- val byteStringFromBytes = ByteString(0xCAu, 0xFEu)
- assertFalse(byteStringFromBytes.isEmpty())
- assertEquals(2, byteStringFromBytes.size)
- }
-
- @Test
- fun encodeAndDecodeUtf8String() {
- val helloAsByteString = "hello".encodeToByteString()
- assertEquals(
- ByteString(
- 'h'.code.toByte(),
- 'e'.code.toByte(),
- 'l'.code.toByte(),
- 'l'.code.toByte(),
- 'o'.code.toByte()
- ), helloAsByteString
- )
- assertEquals("hello", helloAsByteString.decodeToString())
- }
-
- @Test
- fun builderSample() {
- val byteString = buildByteString {
- append("hello".encodeToByteArray())
- append(' '.code.toByte())
- append("world".encodeToByteArray())
- }
-
- assertEquals("hello world".encodeToByteString(), byteString)
- }
-
- @Test
- fun builderSampleWithoutAdditionalAllocs() {
- val array = byteArrayOf(1, 2, 3, 4, 5, 6, 7)
-
- val byteString = buildByteString(4) {
- append(array, startIndex = 2, endIndex = 6)
-
- // When the capacity (4 in this case) matches the number of bytes appended,
- // then a ByteString will wrap builder's backing array without copying it.
- assertEquals(capacity, size)
- }
-
- assertEquals(ByteString(3, 4, 5, 6), byteString)
- }
-}
diff --git a/bytestring/common/test/unsafe/UnsafeByteStringOperationsTest.kt b/bytestring/common/test/unsafe/UnsafeByteStringOperationsTest.kt
deleted file mode 100644
index a0b1902df..000000000
--- a/bytestring/common/test/unsafe/UnsafeByteStringOperationsTest.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring.unsafe
-
-import kotlin.test.Test
-import kotlin.test.assertTrue
-import kotlinx.io.bytestring.encodeToByteString
-
-@OptIn(UnsafeByteStringApi::class)
-class UnsafeByteStringOperationsTest {
- @Test
- fun callsInPlaceContract() {
- val byteString = "hello byte string".encodeToByteString()
-
- val called: Boolean
- UnsafeByteStringOperations.withByteArrayUnsafe(byteString) {
- called = true
- }
- assertTrue(called)
- }
-}
diff --git a/bytestring/jvm/src/-PlatformJvm.kt b/bytestring/jvm/src/-PlatformJvm.kt
deleted file mode 100644
index d419802d0..000000000
--- a/bytestring/jvm/src/-PlatformJvm.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-// Incremental compilation doesn't work smoothly with OptionalExpectation (see KT-66317),
-// so we have to explicitly actualize the annotation.
-@Target(AnnotationTarget.FIELD)
-internal actual annotation class BenignDataRace actual constructor()
-
diff --git a/bytestring/jvm/src/ByteStringJvmExt.kt b/bytestring/jvm/src/ByteStringJvmExt.kt
deleted file mode 100644
index ca193ac37..000000000
--- a/bytestring/jvm/src/ByteStringJvmExt.kt
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringApi
-import kotlinx.io.bytestring.unsafe.UnsafeByteStringOperations
-import java.nio.BufferOverflowException
-import java.nio.ByteBuffer
-import java.nio.charset.Charset
-
-/**
- * Decodes the content of a byte string to a string using given [charset].
- *
- * @param charset the charset to decode data into a string.
- */
-public fun ByteString.decodeToString(charset: Charset): String = getBackingArrayReference().toString(charset)
-
-/**
- * Encodes a string into a byte string using [charset].
- *
- * @param charset the encoding.
- */
-public fun String.encodeToByteString(charset: Charset): ByteString = ByteString.wrap(toByteArray(charset))
-
-/**
- * Returns a new read-only heap [ByteBuffer] wrapping [this] ByteString's content.
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamplesJvm.toReadOnlyByteBuffer
- */
-@OptIn(UnsafeByteStringApi::class)
-public fun ByteString.asReadOnlyByteBuffer(): ByteBuffer {
- val data: ByteArray
-
- UnsafeByteStringOperations.withByteArrayUnsafe(this) {
- data = it
- }
-
- return ByteBuffer.wrap(data).asReadOnlyBuffer()
-}
-
-/**
- * Reads [length] bytes of data from [this] ByteBuffer starting from the current position and
- * wraps them into a new [ByteString].
- *
- * Upon successful execution, current position will advance by [length].
- *
- * @throws IndexOutOfBoundsException when [length] has negative value or its value exceeds [ByteBuffer.remaining]
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamplesJvm.getByteStringFromBuffer
- */
-@OptIn(UnsafeByteStringApi::class)
-public fun ByteBuffer.getByteString(length: Int = remaining()): ByteString {
- if (length < 0) {
- throw IndexOutOfBoundsException("length should be non-negative (was $length)")
- }
- if (remaining() < length) {
- throw IndexOutOfBoundsException("length ($length) exceeds remaining bytes count ({${remaining()}})")
- }
- val bytes = ByteArray(length)
- get(bytes)
- return UnsafeByteStringOperations.wrapUnsafe(bytes)
-}
-
-/**
- * Reads [length] bytes of data from [this] ByteBuffer starting from [at] index and
- * wraps them into a new [ByteString].
- *
- * This function does not update [ByteBuffer.position].
- *
- * @throws IndexOutOfBoundsException when [at] is negative, greater or equal to [ByteBuffer.limit]
- * or [at] + [length] exceeds [ByteBuffer.limit].
- *
- * @sample kotlinx.io.bytestring.samples.ByteStringSamplesJvm.getByteStringFromBufferAbsolute
- */
-@OptIn(UnsafeByteStringApi::class)
-public fun ByteBuffer.getByteString(at: Int, length: Int): ByteString {
- checkIndexAndCapacity(at, length)
- val bytes = ByteArray(length)
- // Absolute get(byte[]) was added only in JDK 13
- for (i in 0..= limit()) {
- throw IndexOutOfBoundsException("Index $idx is out of this ByteBuffer's bounds: [0, ${limit()})")
- }
- if (length < 0) {
- throw IndexOutOfBoundsException("length should be non-negative (was $length)")
- }
- if (idx + length > limit()) {
- throw IndexOutOfBoundsException("There's not enough space to put ByteString of length $length starting" +
- " from index $idx")
- }
-}
diff --git a/bytestring/jvm/test/ByteStringByteBufferExtensionsTest.kt b/bytestring/jvm/test/ByteStringByteBufferExtensionsTest.kt
deleted file mode 100644
index 1a08ae369..000000000
--- a/bytestring/jvm/test/ByteStringByteBufferExtensionsTest.kt
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-package kotlinx.io.bytestring
-
-import org.junit.jupiter.api.Test
-import java.nio.BufferOverflowException
-import java.nio.ByteBuffer
-import java.nio.ReadOnlyBufferException
-import kotlin.test.assertContentEquals
-import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
-import kotlin.test.assertTrue
-
-public class ByteStringByteBufferExtensionsTest {
- @Test
- fun asReadOnlyByteBuffer() {
- val buffer = ByteString(1, 2, 3, 4).asReadOnlyByteBuffer()
-
- assertTrue(buffer.isReadOnly)
- assertEquals(4, buffer.remaining())
-
- ByteArray(4).let {
- buffer.get(it)
- assertContentEquals(byteArrayOf(1, 2, 3, 4), it)
- }
- }
-
- @Test
- fun getByteString() {
- val bb = ByteBuffer.allocate(8)
- bb.put(byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8))
- bb.flip()
-
- assertEquals(ByteString(1, 2, 3, 4, 5, 6, 7, 8), bb.getByteString())
- bb.flip()
-
- assertEquals(ByteString(1, 2, 3, 4), bb.getByteString(length = 4))
- assertEquals(ByteString(), bb.getByteString(length = 0))
- assertFailsWith { bb.getByteString(length = -1) }
- val p = bb.position()
- assertFailsWith { bb.getByteString(length = 5) }
- assertEquals(p, bb.position())
- bb.clear()
-
- assertEquals(ByteString(1, 2, 3, 4, 5, 6, 7, 8), bb.getByteString(at = 0, length = 8))
- assertEquals(0, bb.position())
-
- assertEquals(ByteString(2, 3, 4, 5), bb.getByteString(at = 1, length = 4))
- assertEquals(0, bb.position())
-
- assertFailsWith { bb.getByteString(at = -1, length = 8) }
- assertFailsWith { bb.getByteString(at = 9, length = 1) }
- assertFailsWith { bb.getByteString(at = 7, length = 2) }
- assertFailsWith { bb.getByteString(at = 0, length = -1) }
- }
-
- @Test
- fun putString() {
- val bb = ByteBuffer.allocate(8)
- val string = ByteString(1, 2, 3, 4, 5, 6, 7, 8)
- val shortString = ByteString(-1, -2, -3)
-
- bb.putByteString(string)
- assertEquals(8, bb.position())
- bb.flip()
- ByteArray(8).let {
- bb.get(it)
- assertContentEquals(byteArrayOf(1, 2, 3, 4, 5, 6, 7, 8), it)
- }
-
- bb.clear()
- bb.position(1)
- assertFailsWith { bb.putByteString(string) }
- assertEquals(1, bb.position())
-
- bb.putByteString(at = 0, string = shortString)
- bb.putByteString(at = 5, string = shortString)
- assertEquals(1, bb.position())
- bb.clear()
- ByteArray(8).let {
- bb.get(it)
- assertContentEquals(byteArrayOf(-1, -2, -3, 4, 5, -1, -2, -3), it)
- }
-
- assertFailsWith { bb.putByteString(at = 7, string = shortString) }
- assertFailsWith { bb.putByteString(at = -1, string = string) }
- assertFailsWith { bb.putByteString(at = 8, string = string) }
- assertFailsWith {
- bb.asReadOnlyBuffer().putByteString(string)
- }
- assertFailsWith {
- bb.asReadOnlyBuffer().putByteString(at = 0, string = string)
- }
- }
-}
diff --git a/bytestring/jvm/test/ByteStringJvmTest.kt b/bytestring/jvm/test/ByteStringJvmTest.kt
deleted file mode 100644
index 37f9b86ae..000000000
--- a/bytestring/jvm/test/ByteStringJvmTest.kt
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.bytestring
-
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-/**
- * Set of tests covering JVM-specific [ByteString] extensions.
- */
-class ByteStringJvmTest {
- @Test
- fun createFromString() {
- val str = "hello"
-
- assertEquals(ByteString(byteArrayOf(0x68, 0x65, 0x6c, 0x6c, 0x6f)), str.encodeToByteString(Charsets.UTF_8))
- assertEquals(
- ByteString(
- byteArrayOf(
- 0, 0, 0, 0x68, 0, 0, 0, 0x65, 0, 0, 0, 0x6c,
- 0, 0, 0, 0x6c, 0, 0, 0, 0x6f
- )
- ), str.encodeToByteString(Charsets.UTF_32)
- )
- }
-
- @Test
- fun decodeToString() {
- assertEquals(
- "Ϭ",
- ByteString(0xfeU.toByte(), 0xffU.toByte(), 0x03, 0xecU.toByte()).decodeToString(Charsets.UTF_16)
- )
-
- assertEquals("123", ByteString("123".encodeToByteArray()).decodeToString(Charsets.UTF_8))
- }
-}
diff --git a/bytestring/jvm/test/samples/samplesJvm.kt b/bytestring/jvm/test/samples/samplesJvm.kt
deleted file mode 100644
index ee97d186f..000000000
--- a/bytestring/jvm/test/samples/samplesJvm.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017-2024 JetBrains s.r.o. and respective authors and developers.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENCE file.
- */
-
-package kotlinx.io.bytestring.samples
-
-import kotlinx.io.bytestring.*
-import java.nio.ByteBuffer
-import java.nio.ReadOnlyBufferException
-import kotlin.test.*
-
-public class ByteStringSamplesJvm {
- @Test
- fun toReadOnlyByteBuffer() {
- val str = "Hello World".encodeToByteString()
- val buffer = str.asReadOnlyByteBuffer()
-
- assertEquals(11, buffer.remaining())
- assertEquals(0x48656c6c, buffer.getInt())
-
- buffer.flip()
- assertFailsWith { buffer.put(42) }
- }
-
- @Test
- fun getByteStringFromBuffer() {
- val buffer = ByteBuffer.wrap("Hello World".encodeToByteArray())
-
- // Consume the whole buffer
- val byteString = buffer.getByteString()
- assertEquals(0, buffer.remaining())
- assertEquals("Hello World".encodeToByteString(), byteString)
-
- // Reset the buffer
- buffer.flip()
- // Consume only first 5 bytes from the buffer
- assertEquals("Hello".encodeToByteString(), buffer.getByteString(length = 5))
- }
-
- @Test
- fun getByteStringFromBufferAbsolute() {
- val buffer = ByteBuffer.wrap("Hello World".encodeToByteArray())
-
- // Read 2 bytes starting from offset 6
- val byteString = buffer.getByteString(at = 6, length = 2)
- // Buffer's position is not affected
- assertEquals(11, buffer.remaining())
- assertEquals(byteString, "Wo".encodeToByteString())
- }
-
- @Test
- fun putByteStringToBuffer() {
- val buffer = ByteBuffer.allocate(32)
- val byteString = ByteString(0x66, 0xdb.toByte(), 0x11, 0x50)
-
- // Putting a ByteString into a buffer will advance its position
- buffer.putByteString(byteString)
- assertEquals(4, buffer.position())
-
- buffer.flip()
- assertEquals(1725632848, buffer.getInt())
- }
-
- @Test
- fun putByteStringToBufferAbsolute() {
- val buffer = ByteBuffer.allocate(8)
- val byteString = ByteString(0x78, 0x5e)
-
- // Putting a ByteString into a buffer using an absolute offset
- // won't change buffer's position.
- buffer.putByteString(at = 3, string = byteString)
- assertEquals(0, buffer.position())
- assertEquals(8, buffer.remaining())
-
- assertEquals(0x000000785e000000L, buffer.getLong())
- }
-}
diff --git a/bytestring/native/src/-PlatformNative.kt b/bytestring/native/src/-PlatformNative.kt
deleted file mode 100644
index 7ee278db1..000000000
--- a/bytestring/native/src/-PlatformNative.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
-* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
-* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
-*/
-package kotlinx.io.bytestring
-
-import kotlin.concurrent.*
-
-internal actual typealias BenignDataRace = Volatile
diff --git a/core/Module.md b/core/Module.md
deleted file mode 100644
index 840b92af8..000000000
--- a/core/Module.md
+++ /dev/null
@@ -1,89 +0,0 @@
-# Module kotlinx-io-core
-
-The module provides core multiplatform IO primitives and integrates it with platform-specific APIs.
-
-`kotlinx-io core` aims to provide a concise but powerful API along with efficient implementation.
-
-The main interfaces for the IO interaction are [kotlinx.io.Source] and [kotlinx.io.Sink] providing buffered read and
-write operations for integer types, byte arrays, and other sources and sinks. There are also extension functions
-bringing support for strings and other types.
-Implementations of these interfaces are built on top of [kotlinx.io.Buffer], [kotlinx.io.RawSource],
-and [kotlinx.io.RawSink].
-
-A central part of the library, [kotlinx.io.Buffer], is a container optimized to reduce memory allocations and to avoid
-data copying when possible.
-
-[kotlinx.io.RawSource] and [kotlinx.io.RawSink] are interfaces aimed for integration with anything that can provide
-or receive data: network interfaces, files, etc. The module provides integration with some platform-specific IO APIs,
-but if something not yet supported by the library needs to be integrated, then these interfaces are exactly what should
-be implemented for that.
-
-Example below shows how to manually serialize an object to [BSON](https://bsonspec.org/spec.html)
-and then back to an object using `kotlinx.io`. Please note that the example aimed to show `kotlinx-io` API in action,
-rather than to provide a robust BSON-serialization.
-```kotlin
-data class Message(val timestamp: Long, val text: String) {
- companion object
-}
-
-fun Message.toBson(sink: Sink) {
- val buffer = Buffer()
- with (buffer) {
- writeByte(0x9) // UTC-timestamp field
- writeString("timestamp") // field name
- writeByte(0)
- writeLongLe(timestamp) // field value
- writeByte(0x2) // string field
- writeString("text") // field name
- writeByte(0)
- writeIntLe(text.utf8Size().toInt() + 1) // field value: length followed by the string
- writeString(text)
- writeByte(0)
- writeByte(0) // end of BSON document
- }
-
- // Write document length and then its body
- sink.writeIntLe(buffer.size.toInt() + 4)
- buffer.transferTo(sink)
- sink.flush()
-}
-
-fun Message.Companion.fromBson(source: Source): Message {
- source.require(4) // check if the source contains length
- val length = source.readIntLe() - 4L
- source.require(length) // check if the source contains the whole message
-
- fun readFieldName(source: Source): String {
- val delimiterOffset = source.indexOf(0) // find offset of the 0-byte terminating the name
- check(delimiterOffset >= 0) // indexOf return -1 if value not found
- val fieldName = source.readString(delimiterOffset) // read the string until terminator
- source.skip(1) // skip the terminator
- return fieldName
- }
-
- // for simplicity, let's assume that the order of fields matches serialization order
- var tag = source.readByte().toInt() // read the field type
- check(tag == 0x9 && readFieldName(source) == "timestamp")
- val timestamp = source.readLongLe() // read long value
- tag = source.readByte().toInt()
- check(tag == 0x2 && readFieldName(source) == "text")
- val textLen = source.readIntLe() - 1L // read string length (it includes the terminator)
- val text = source.readString(textLen) // read value
- source.skip(1) // skip terminator
- source.skip(1) // skip end of the document
- return Message(timestamp, text)
-}
-```
-
-# Package kotlinx.io
-
-Core IO primitives.
-
-# Package kotlinx.io.files
-
-Basic API for working with files.
-
-#### Known issues
-
-- [#312](https://github.com/Kotlin/kotlinx-io/issues/312) For `wasmWasi` target, directory listing ([kotlinx.io.files.FileSystem.list]) does not work with NodeJS runtime on Windows,
-as `fd_readdir` function is [not implemented there](https://github.com/nodejs/node/blob/6f4d6011ea1b448cf21f5d363c44e4a4c56ca34c/deps/uvwasi/src/uvwasi.c#L19).
diff --git a/core/androidNative/src/files/FileSystemAndroid.kt b/core/androidNative/src/files/FileSystemAndroid.kt
deleted file mode 100644
index 65ba74177..000000000
--- a/core/androidNative/src/files/FileSystemAndroid.kt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
- */
-
-package kotlinx.io.files
-
-import kotlinx.cinterop.CPointer
-import kotlinx.cinterop.ExperimentalForeignApi
-import kotlinx.cinterop.get
-import kotlinx.cinterop.toKString
-import kotlinx.io.IOException
-import platform.posix.*
-
-@OptIn(ExperimentalForeignApi::class)
-internal actual fun dirnameImpl(path: String): String {
- if (!path.contains(SystemPathSeparator)) {
- return ""
- }
- return dirname(path)?.toKString() ?: ""
-}
-
-@OptIn(ExperimentalForeignApi::class)
-internal actual fun basenameImpl(path: String): String {
- return __posix_basename(path)?.toKString() ?: ""
-}
-
-internal actual fun isAbsoluteImpl(path: String): Boolean = path.startsWith('/')
-
-@OptIn(ExperimentalForeignApi::class)
-internal actual class OpaqueDirEntry(private val dir: CPointer) : AutoCloseable {
- actual fun readdir(): String? {
- val entry = platform.posix.readdir(dir) ?: return null
- return entry[0].d_name.toKString()
- }
-
- actual override fun close() {
- closedir(dir)
- }
-}
-
-@OptIn(ExperimentalForeignApi::class)
-internal actual fun opendir(path: String): OpaqueDirEntry {
- val dirent = platform.posix.opendir(path)
- if (dirent != null) return OpaqueDirEntry(dirent)
- throw IOException("Can't open directory $path: ${strerror(errno)?.toKString() ?: "reason unknown"}")
-}
diff --git a/core/api/kotlinx-io-core.api b/core/api/kotlinx-io-core.api
deleted file mode 100644
index 3d47cde16..000000000
--- a/core/api/kotlinx-io-core.api
+++ /dev/null
@@ -1,332 +0,0 @@
-public final class kotlinx/io/Buffer : kotlinx/io/Sink, kotlinx/io/Source {
- public fun ()V
- public final fun clear ()V
- public fun close ()V
- public final fun copy ()Lkotlinx/io/Buffer;
- public final fun copyTo (Lkotlinx/io/Buffer;JJ)V
- public static synthetic fun copyTo$default (Lkotlinx/io/Buffer;Lkotlinx/io/Buffer;JJILjava/lang/Object;)V
- public fun emit ()V
- public fun exhausted ()Z
- public fun flush ()V
- public final fun get (J)B
- public fun getBuffer ()Lkotlinx/io/Buffer;
- public final synthetic fun getHead ()Lkotlinx/io/Segment;
- public final fun getSize ()J
- public final synthetic fun getSizeMut ()J
- public final synthetic fun getTail ()Lkotlinx/io/Segment;
- public fun hintEmit ()V
- public fun peek ()Lkotlinx/io/Source;
- public fun readAtMostTo (Lkotlinx/io/Buffer;J)J
- public fun readAtMostTo ([BII)I
- public fun readByte ()B
- public fun readInt ()I
- public fun readLong ()J
- public fun readShort ()S
- public fun readTo (Lkotlinx/io/RawSink;J)V
- public final synthetic fun recycleTail ()V
- public fun request (J)Z
- public fun require (J)V
- public final synthetic fun setHead (Lkotlinx/io/Segment;)V
- public final synthetic fun setSizeMut (J)V
- public final synthetic fun setTail (Lkotlinx/io/Segment;)V
- public fun skip (J)V
- public fun toString ()Ljava/lang/String;
- public fun transferFrom (Lkotlinx/io/RawSource;)J
- public fun transferTo (Lkotlinx/io/RawSink;)J
- public final synthetic fun writableSegment (I)Lkotlinx/io/Segment;
- public fun write (Lkotlinx/io/Buffer;J)V
- public fun write (Lkotlinx/io/RawSource;J)V
- public fun write ([BII)V
- public fun writeByte (B)V
- public fun writeInt (I)V
- public fun writeLong (J)V
- public fun writeShort (S)V
-}
-
-public final class kotlinx/io/BufferKt {
- public static final synthetic fun seek (Lkotlinx/io/Buffer;JLkotlin/jvm/functions/Function2;)Ljava/lang/Object;
-}
-
-public final class kotlinx/io/BuffersJvmKt {
- public static final fun asByteChannel (Lkotlinx/io/Buffer;)Ljava/nio/channels/ByteChannel;
- public static final fun copyTo (Lkotlinx/io/Buffer;Ljava/io/OutputStream;JJ)V
- public static synthetic fun copyTo$default (Lkotlinx/io/Buffer;Ljava/io/OutputStream;JJILjava/lang/Object;)V
- public static final fun readAtMostTo (Lkotlinx/io/Buffer;Ljava/nio/ByteBuffer;)I
- public static final fun readTo (Lkotlinx/io/Buffer;Ljava/io/OutputStream;J)V
- public static synthetic fun readTo$default (Lkotlinx/io/Buffer;Ljava/io/OutputStream;JILjava/lang/Object;)V
- public static final fun transferFrom (Lkotlinx/io/Buffer;Ljava/io/InputStream;)Lkotlinx/io/Buffer;
- public static final fun transferFrom (Lkotlinx/io/Buffer;Ljava/nio/ByteBuffer;)Lkotlinx/io/Buffer;
- public static final fun write (Lkotlinx/io/Buffer;Ljava/io/InputStream;J)Lkotlinx/io/Buffer;
-}
-
-public final class kotlinx/io/BuffersKt {
- public static final fun indexOf (Lkotlinx/io/Buffer;BJJ)J
- public static synthetic fun indexOf$default (Lkotlinx/io/Buffer;BJJILjava/lang/Object;)J
- public static final fun snapshot (Lkotlinx/io/Buffer;)Lkotlinx/io/bytestring/ByteString;
-}
-
-public final class kotlinx/io/ByteStringsKt {
- public static final fun indexOf (Lkotlinx/io/Buffer;Lkotlinx/io/bytestring/ByteString;J)J
- public static final fun indexOf (Lkotlinx/io/Source;Lkotlinx/io/bytestring/ByteString;J)J
- public static synthetic fun indexOf$default (Lkotlinx/io/Buffer;Lkotlinx/io/bytestring/ByteString;JILjava/lang/Object;)J
- public static synthetic fun indexOf$default (Lkotlinx/io/Source;Lkotlinx/io/bytestring/ByteString;JILjava/lang/Object;)J
- public static final fun readByteString (Lkotlinx/io/Source;)Lkotlinx/io/bytestring/ByteString;
- public static final fun readByteString (Lkotlinx/io/Source;I)Lkotlinx/io/bytestring/ByteString;
- public static final fun write (Lkotlinx/io/Sink;Lkotlinx/io/bytestring/ByteString;II)V
- public static synthetic fun write$default (Lkotlinx/io/Sink;Lkotlinx/io/bytestring/ByteString;IIILjava/lang/Object;)V
-}
-
-public final class kotlinx/io/CoreKt {
- public static final fun buffered (Lkotlinx/io/RawSink;)Lkotlinx/io/Sink;
- public static final fun buffered (Lkotlinx/io/RawSource;)Lkotlinx/io/Source;
- public static final fun discardingSink ()Lkotlinx/io/RawSink;
-}
-
-public abstract interface annotation class kotlinx/io/DelicateIoApi : java/lang/annotation/Annotation {
-}
-
-public abstract interface annotation class kotlinx/io/InternalIoApi : java/lang/annotation/Annotation {
-}
-
-public final class kotlinx/io/JvmCoreKt {
- public static final fun asSink (Ljava/io/OutputStream;)Lkotlinx/io/RawSink;
- public static final fun asSource (Ljava/io/InputStream;)Lkotlinx/io/RawSource;
-}
-
-public abstract interface class kotlinx/io/RawSink : java/io/Flushable, java/lang/AutoCloseable {
- public abstract fun close ()V
- public abstract fun flush ()V
- public abstract fun write (Lkotlinx/io/Buffer;J)V
-}
-
-public abstract interface class kotlinx/io/RawSource : java/lang/AutoCloseable {
- public abstract fun close ()V
- public abstract fun readAtMostTo (Lkotlinx/io/Buffer;J)J
-}
-
-public final class kotlinx/io/Segment {
- public synthetic fun ([BIILkotlinx/io/SegmentCopyTracker;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
- public final synthetic fun dataAsByteArray (Z)[B
- public final synthetic fun getLimit ()I
- public final synthetic fun getNext ()Lkotlinx/io/Segment;
- public final synthetic fun getPos ()I
- public final synthetic fun getPrev ()Lkotlinx/io/Segment;
- public final synthetic fun getRemainingCapacity ()I
- public final synthetic fun getSize ()I
- public final synthetic fun setLimit (I)V
- public final synthetic fun setNext (Lkotlinx/io/Segment;)V
- public final synthetic fun setPos (I)V
- public final synthetic fun setPrev (Lkotlinx/io/Segment;)V
- public final synthetic fun writeBackData ([BI)V
-}
-
-public final class kotlinx/io/SegmentKt {
- public static final fun isEmpty (Lkotlinx/io/Segment;)Z
-}
-
-public abstract interface class kotlinx/io/Sink : kotlinx/io/RawSink {
- public abstract fun emit ()V
- public abstract fun flush ()V
- public abstract fun getBuffer ()Lkotlinx/io/Buffer;
- public abstract fun hintEmit ()V
- public abstract fun transferFrom (Lkotlinx/io/RawSource;)J
- public abstract fun write (Lkotlinx/io/RawSource;J)V
- public abstract fun write ([BII)V
- public static synthetic fun write$default (Lkotlinx/io/Sink;[BIIILjava/lang/Object;)V
- public abstract fun writeByte (B)V
- public abstract fun writeInt (I)V
- public abstract fun writeLong (J)V
- public abstract fun writeShort (S)V
-}
-
-public final class kotlinx/io/SinksJvmKt {
- public static final fun asByteChannel (Lkotlinx/io/Sink;)Ljava/nio/channels/WritableByteChannel;
- public static final fun asOutputStream (Lkotlinx/io/Sink;)Ljava/io/OutputStream;
- public static final fun write (Lkotlinx/io/Sink;Ljava/nio/ByteBuffer;)I
- public static final fun writeString (Lkotlinx/io/Sink;Ljava/lang/String;Ljava/nio/charset/Charset;II)V
- public static synthetic fun writeString$default (Lkotlinx/io/Sink;Ljava/lang/String;Ljava/nio/charset/Charset;IIILjava/lang/Object;)V
-}
-
-public final class kotlinx/io/SinksKt {
- public static final fun writeDecimalLong (Lkotlinx/io/Sink;J)V
- public static final fun writeDouble (Lkotlinx/io/Sink;D)V
- public static final fun writeDoubleLe (Lkotlinx/io/Sink;D)V
- public static final fun writeFloat (Lkotlinx/io/Sink;F)V
- public static final fun writeFloatLe (Lkotlinx/io/Sink;F)V
- public static final fun writeHexadecimalUnsignedLong (Lkotlinx/io/Sink;J)V
- public static final fun writeIntLe (Lkotlinx/io/Sink;I)V
- public static final fun writeLongLe (Lkotlinx/io/Sink;J)V
- public static final fun writeShortLe (Lkotlinx/io/Sink;S)V
- public static final fun writeToInternalBuffer (Lkotlinx/io/Sink;Lkotlin/jvm/functions/Function1;)V
- public static final fun writeUByte-EK-6454 (Lkotlinx/io/Sink;B)V
- public static final fun writeUInt-Qn1smSk (Lkotlinx/io/Sink;I)V
- public static final fun writeUIntLe-Qn1smSk (Lkotlinx/io/Sink;I)V
- public static final fun writeULong-2TYgG_w (Lkotlinx/io/Sink;J)V
- public static final fun writeULongLe-2TYgG_w (Lkotlinx/io/Sink;J)V
- public static final fun writeUShort-i8woANY (Lkotlinx/io/Sink;S)V
- public static final fun writeUShortLe-i8woANY (Lkotlinx/io/Sink;S)V
-}
-
-public abstract interface class kotlinx/io/Source : kotlinx/io/RawSource {
- public abstract fun exhausted ()Z
- public abstract fun getBuffer ()Lkotlinx/io/Buffer;
- public abstract fun peek ()Lkotlinx/io/Source;
- public abstract fun readAtMostTo ([BII)I
- public static synthetic fun readAtMostTo$default (Lkotlinx/io/Source;[BIIILjava/lang/Object;)I
- public abstract fun readByte ()B
- public abstract fun readInt ()I
- public abstract fun readLong ()J
- public abstract fun readShort ()S
- public abstract fun readTo (Lkotlinx/io/RawSink;J)V
- public abstract fun request (J)Z
- public abstract fun require (J)V
- public abstract fun skip (J)V
- public abstract fun transferTo (Lkotlinx/io/RawSink;)J
-}
-
-public final class kotlinx/io/SourcesJvmKt {
- public static final fun asByteChannel (Lkotlinx/io/Source;)Ljava/nio/channels/ReadableByteChannel;
- public static final fun asInputStream (Lkotlinx/io/Source;)Ljava/io/InputStream;
- public static final fun readAtMostTo (Lkotlinx/io/Source;Ljava/nio/ByteBuffer;)I
- public static final fun readString (Lkotlinx/io/Source;JLjava/nio/charset/Charset;)Ljava/lang/String;
- public static final fun readString (Lkotlinx/io/Source;Ljava/nio/charset/Charset;)Ljava/lang/String;
-}
-
-public final class kotlinx/io/SourcesKt {
- public static final fun indexOf (Lkotlinx/io/Source;BJJ)J
- public static synthetic fun indexOf$default (Lkotlinx/io/Source;BJJILjava/lang/Object;)J
- public static final fun readByteArray (Lkotlinx/io/Source;)[B
- public static final fun readByteArray (Lkotlinx/io/Source;I)[B
- public static final fun readDecimalLong (Lkotlinx/io/Source;)J
- public static final fun readDouble (Lkotlinx/io/Source;)D
- public static final fun readDoubleLe (Lkotlinx/io/Source;)D
- public static final fun readFloat (Lkotlinx/io/Source;)F
- public static final fun readFloatLe (Lkotlinx/io/Source;)F
- public static final fun readHexadecimalUnsignedLong (Lkotlinx/io/Source;)J
- public static final fun readIntLe (Lkotlinx/io/Source;)I
- public static final fun readLongLe (Lkotlinx/io/Source;)J
- public static final fun readShortLe (Lkotlinx/io/Source;)S
- public static final fun readTo (Lkotlinx/io/Source;[BII)V
- public static synthetic fun readTo$default (Lkotlinx/io/Source;[BIIILjava/lang/Object;)V
- public static final fun readUByte (Lkotlinx/io/Source;)B
- public static final fun readUInt (Lkotlinx/io/Source;)I
- public static final fun readUIntLe (Lkotlinx/io/Source;)I
- public static final fun readULong (Lkotlinx/io/Source;)J
- public static final fun readULongLe (Lkotlinx/io/Source;)J
- public static final fun readUShort (Lkotlinx/io/Source;)S
- public static final fun readUShortLe (Lkotlinx/io/Source;)S
- public static final fun startsWith (Lkotlinx/io/Source;B)Z
-}
-
-public abstract interface annotation class kotlinx/io/UnsafeIoApi : java/lang/annotation/Annotation {
-}
-
-public final class kotlinx/io/Utf8Kt {
- public static final fun readCodePointValue (Lkotlinx/io/Source;)I
- public static final fun readLine (Lkotlinx/io/Source;)Ljava/lang/String;
- public static final fun readLineStrict (Lkotlinx/io/Source;J)Ljava/lang/String;
- public static synthetic fun readLineStrict$default (Lkotlinx/io/Source;JILjava/lang/Object;)Ljava/lang/String;
- public static final fun readString (Lkotlinx/io/Buffer;)Ljava/lang/String;
- public static final fun readString (Lkotlinx/io/Source;)Ljava/lang/String;
- public static final fun readString (Lkotlinx/io/Source;J)Ljava/lang/String;
- public static final fun writeCodePointValue (Lkotlinx/io/Sink;I)V
- public static final fun writeString (Lkotlinx/io/Sink;Ljava/lang/CharSequence;II)V
- public static final fun writeString (Lkotlinx/io/Sink;Ljava/lang/String;II)V
- public static synthetic fun writeString$default (Lkotlinx/io/Sink;Ljava/lang/CharSequence;IIILjava/lang/Object;)V
- public static synthetic fun writeString$default (Lkotlinx/io/Sink;Ljava/lang/String;IIILjava/lang/Object;)V
-}
-
-public final class kotlinx/io/files/FileMetadata {
- public fun ()V
- public fun (ZZJ)V
- public synthetic fun (ZZJILkotlin/jvm/internal/DefaultConstructorMarker;)V
- public final fun getSize ()J
- public final fun isDirectory ()Z
- public final fun isRegularFile ()Z
-}
-
-public abstract interface class kotlinx/io/files/FileSystem {
- public abstract fun atomicMove (Lkotlinx/io/files/Path;Lkotlinx/io/files/Path;)V
- public abstract fun createDirectories (Lkotlinx/io/files/Path;Z)V
- public static synthetic fun createDirectories$default (Lkotlinx/io/files/FileSystem;Lkotlinx/io/files/Path;ZILjava/lang/Object;)V
- public abstract fun delete (Lkotlinx/io/files/Path;Z)V
- public static synthetic fun delete$default (Lkotlinx/io/files/FileSystem;Lkotlinx/io/files/Path;ZILjava/lang/Object;)V
- public abstract fun exists (Lkotlinx/io/files/Path;)Z
- public abstract fun list (Lkotlinx/io/files/Path;)Ljava/util/Collection;
- public abstract fun metadataOrNull (Lkotlinx/io/files/Path;)Lkotlinx/io/files/FileMetadata;
- public abstract fun resolve (Lkotlinx/io/files/Path;)Lkotlinx/io/files/Path;
- public abstract fun sink (Lkotlinx/io/files/Path;Z)Lkotlinx/io/RawSink;
- public static synthetic fun sink$default (Lkotlinx/io/files/FileSystem;Lkotlinx/io/files/Path;ZILjava/lang/Object;)Lkotlinx/io/RawSink;
- public abstract fun source (Lkotlinx/io/files/Path;)Lkotlinx/io/RawSource;
-}
-
-public final class kotlinx/io/files/FileSystemJvmKt {
- public static final field SystemFileSystem Lkotlinx/io/files/FileSystem;
- public static final field SystemTemporaryDirectory Lkotlinx/io/files/Path;
-}
-
-public final class kotlinx/io/files/Path {
- public fun equals (Ljava/lang/Object;)Z
- public final fun getName ()Ljava/lang/String;
- public final fun getParent ()Lkotlinx/io/files/Path;
- public fun hashCode ()I
- public final fun isAbsolute ()Z
- public fun toString ()Ljava/lang/String;
-}
-
-public final class kotlinx/io/files/PathsJvmKt {
- public static final field SystemPathSeparator C
- public static final fun Path (Ljava/lang/String;)Lkotlinx/io/files/Path;
- public static final fun sink (Lkotlinx/io/files/Path;)Lkotlinx/io/Sink;
- public static final fun source (Lkotlinx/io/files/Path;)Lkotlinx/io/Source;
-}
-
-public final class kotlinx/io/files/PathsKt {
- public static final fun Path (Ljava/lang/String;[Ljava/lang/String;)Lkotlinx/io/files/Path;
- public static final fun Path (Lkotlinx/io/files/Path;[Ljava/lang/String;)Lkotlinx/io/files/Path;
- public static final fun sinkDeprecated (Lkotlinx/io/files/Path;)Lkotlinx/io/Sink;
- public static final fun sourceDeprecated (Lkotlinx/io/files/Path;)Lkotlinx/io/Source;
-}
-
-public abstract interface class kotlinx/io/unsafe/BufferIterationContext : kotlinx/io/unsafe/SegmentReadContext {
- public abstract fun next (Lkotlinx/io/Segment;)Lkotlinx/io/Segment;
-}
-
-public abstract interface class kotlinx/io/unsafe/SegmentReadContext {
- public abstract fun getUnchecked (Lkotlinx/io/Segment;I)B
-}
-
-public abstract interface class kotlinx/io/unsafe/SegmentWriteContext {
- public abstract fun setUnchecked (Lkotlinx/io/Segment;IB)V
- public abstract fun setUnchecked (Lkotlinx/io/Segment;IBB)V
- public abstract fun setUnchecked (Lkotlinx/io/Segment;IBBB)V
- public abstract fun setUnchecked (Lkotlinx/io/Segment;IBBBB)V
-}
-
-public final class kotlinx/io/unsafe/UnsafeBufferOperations {
- public static final field INSTANCE Lkotlinx/io/unsafe/UnsafeBufferOperations;
- public final fun forEachSegment (Lkotlinx/io/Buffer;Lkotlin/jvm/functions/Function2;)V
- public final fun getMaxSafeWriteCapacity ()I
- public final fun iterate (Lkotlinx/io/Buffer;JLkotlin/jvm/functions/Function3;)V
- public final fun iterate (Lkotlinx/io/Buffer;Lkotlin/jvm/functions/Function2;)V
- public final fun moveToTail (Lkotlinx/io/Buffer;[BII)V
- public static synthetic fun moveToTail$default (Lkotlinx/io/unsafe/UnsafeBufferOperations;Lkotlinx/io/Buffer;[BIIILjava/lang/Object;)V
- public final fun readFromHead (Lkotlinx/io/Buffer;Lkotlin/jvm/functions/Function2;)I
- public final fun readFromHead (Lkotlinx/io/Buffer;Lkotlin/jvm/functions/Function3;)I
- public final fun writeToTail (Lkotlinx/io/Buffer;ILkotlin/jvm/functions/Function2;)I
- public final fun writeToTail (Lkotlinx/io/Buffer;ILkotlin/jvm/functions/Function3;)I
-}
-
-public final class kotlinx/io/unsafe/UnsafeBufferOperationsJvmKt {
- public static final fun readBulk (Lkotlinx/io/unsafe/UnsafeBufferOperations;Lkotlinx/io/Buffer;[Ljava/nio/ByteBuffer;Lkotlin/jvm/functions/Function2;)J
- public static final fun readFromHead (Lkotlinx/io/unsafe/UnsafeBufferOperations;Lkotlinx/io/Buffer;Lkotlin/jvm/functions/Function1;)I
- public static final fun writeToTail (Lkotlinx/io/unsafe/UnsafeBufferOperations;Lkotlinx/io/Buffer;ILkotlin/jvm/functions/Function1;)I
-}
-
-public final class kotlinx/io/unsafe/UnsafeBufferOperationsKt {
- public static final synthetic fun getBufferIterationContextImpl ()Lkotlinx/io/unsafe/BufferIterationContext;
- public static final synthetic fun getSegmentReadContextImpl ()Lkotlinx/io/unsafe/SegmentReadContext;
- public static final synthetic fun getSegmentWriteContextImpl ()Lkotlinx/io/unsafe/SegmentWriteContext;
- public static final synthetic fun withData (Lkotlinx/io/unsafe/SegmentReadContext;Lkotlinx/io/Segment;Lkotlin/jvm/functions/Function3;)V
-}
-
diff --git a/core/api/kotlinx-io-core.klib.api b/core/api/kotlinx-io-core.klib.api
deleted file mode 100644
index 2db224bc4..000000000
--- a/core/api/kotlinx-io-core.klib.api
+++ /dev/null
@@ -1,312 +0,0 @@
-// Klib ABI Dump
-// Targets: [androidNativeArm32, androidNativeArm64, androidNativeX64, androidNativeX86, iosArm64, iosSimulatorArm64, iosX64, js, linuxArm32Hfp, linuxArm64, linuxX64, macosArm64, macosX64, mingwX64, tvosArm64, tvosSimulatorArm64, tvosX64, wasmJs, wasmWasi, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
-// Alias: apple => [iosArm64, iosSimulatorArm64, iosX64, macosArm64, macosX64, tvosArm64, tvosSimulatorArm64, tvosX64, watchosArm32, watchosArm64, watchosDeviceArm64, watchosSimulatorArm64, watchosX64]
-// Rendering settings:
-// - Signature version: 2
-// - Show manifest properties: true
-// - Show declarations: true
-
-// Library unique name:
-open annotation class kotlinx.io/DelicateIoApi : kotlin/Annotation { // kotlinx.io/DelicateIoApi|null[0]
- constructor () // kotlinx.io/DelicateIoApi.|(){}[0]
-}
-
-open annotation class kotlinx.io/InternalIoApi : kotlin/Annotation { // kotlinx.io/InternalIoApi|null[0]
- constructor () // kotlinx.io/InternalIoApi.|(){}[0]
-}
-
-open annotation class kotlinx.io/UnsafeIoApi : kotlin/Annotation { // kotlinx.io/UnsafeIoApi|null[0]
- constructor () // kotlinx.io/UnsafeIoApi.|(){}[0]
-}
-
-abstract interface kotlinx.io.unsafe/BufferIterationContext : kotlinx.io.unsafe/SegmentReadContext { // kotlinx.io.unsafe/BufferIterationContext|null[0]
- abstract fun next(kotlinx.io/Segment): kotlinx.io/Segment? // kotlinx.io.unsafe/BufferIterationContext.next|next(kotlinx.io.Segment){}[0]
-}
-
-abstract interface kotlinx.io.unsafe/SegmentReadContext { // kotlinx.io.unsafe/SegmentReadContext|null[0]
- abstract fun getUnchecked(kotlinx.io/Segment, kotlin/Int): kotlin/Byte // kotlinx.io.unsafe/SegmentReadContext.getUnchecked|getUnchecked(kotlinx.io.Segment;kotlin.Int){}[0]
-}
-
-abstract interface kotlinx.io.unsafe/SegmentWriteContext { // kotlinx.io.unsafe/SegmentWriteContext|null[0]
- abstract fun setUnchecked(kotlinx.io/Segment, kotlin/Int, kotlin/Byte) // kotlinx.io.unsafe/SegmentWriteContext.setUnchecked|setUnchecked(kotlinx.io.Segment;kotlin.Int;kotlin.Byte){}[0]
- abstract fun setUnchecked(kotlinx.io/Segment, kotlin/Int, kotlin/Byte, kotlin/Byte) // kotlinx.io.unsafe/SegmentWriteContext.setUnchecked|setUnchecked(kotlinx.io.Segment;kotlin.Int;kotlin.Byte;kotlin.Byte){}[0]
- abstract fun setUnchecked(kotlinx.io/Segment, kotlin/Int, kotlin/Byte, kotlin/Byte, kotlin/Byte) // kotlinx.io.unsafe/SegmentWriteContext.setUnchecked|setUnchecked(kotlinx.io.Segment;kotlin.Int;kotlin.Byte;kotlin.Byte;kotlin.Byte){}[0]
- abstract fun setUnchecked(kotlinx.io/Segment, kotlin/Int, kotlin/Byte, kotlin/Byte, kotlin/Byte, kotlin/Byte) // kotlinx.io.unsafe/SegmentWriteContext.setUnchecked|setUnchecked(kotlinx.io.Segment;kotlin.Int;kotlin.Byte;kotlin.Byte;kotlin.Byte;kotlin.Byte){}[0]
-}
-
-abstract interface kotlinx.io/RawSink : kotlin/AutoCloseable { // kotlinx.io/RawSink|null[0]
- abstract fun close() // kotlinx.io/RawSink.close|close(){}[0]
- abstract fun flush() // kotlinx.io/RawSink.flush|flush(){}[0]
- abstract fun write(kotlinx.io/Buffer, kotlin/Long) // kotlinx.io/RawSink.write|write(kotlinx.io.Buffer;kotlin.Long){}[0]
-}
-
-abstract interface kotlinx.io/RawSource : kotlin/AutoCloseable { // kotlinx.io/RawSource|null[0]
- abstract fun close() // kotlinx.io/RawSource.close|close(){}[0]
- abstract fun readAtMostTo(kotlinx.io/Buffer, kotlin/Long): kotlin/Long // kotlinx.io/RawSource.readAtMostTo|readAtMostTo(kotlinx.io.Buffer;kotlin.Long){}[0]
-}
-
-sealed interface kotlinx.io.files/FileSystem { // kotlinx.io.files/FileSystem|null[0]
- abstract fun atomicMove(kotlinx.io.files/Path, kotlinx.io.files/Path) // kotlinx.io.files/FileSystem.atomicMove|atomicMove(kotlinx.io.files.Path;kotlinx.io.files.Path){}[0]
- abstract fun createDirectories(kotlinx.io.files/Path, kotlin/Boolean = ...) // kotlinx.io.files/FileSystem.createDirectories|createDirectories(kotlinx.io.files.Path;kotlin.Boolean){}[0]
- abstract fun delete(kotlinx.io.files/Path, kotlin/Boolean = ...) // kotlinx.io.files/FileSystem.delete|delete(kotlinx.io.files.Path;kotlin.Boolean){}[0]
- abstract fun exists(kotlinx.io.files/Path): kotlin/Boolean // kotlinx.io.files/FileSystem.exists|exists(kotlinx.io.files.Path){}[0]
- abstract fun list(kotlinx.io.files/Path): kotlin.collections/Collection // kotlinx.io.files/FileSystem.list|list(kotlinx.io.files.Path){}[0]
- abstract fun metadataOrNull(kotlinx.io.files/Path): kotlinx.io.files/FileMetadata? // kotlinx.io.files/FileSystem.metadataOrNull|metadataOrNull(kotlinx.io.files.Path){}[0]
- abstract fun resolve(kotlinx.io.files/Path): kotlinx.io.files/Path // kotlinx.io.files/FileSystem.resolve|resolve(kotlinx.io.files.Path){}[0]
- abstract fun sink(kotlinx.io.files/Path, kotlin/Boolean = ...): kotlinx.io/RawSink // kotlinx.io.files/FileSystem.sink|sink(kotlinx.io.files.Path;kotlin.Boolean){}[0]
- abstract fun source(kotlinx.io.files/Path): kotlinx.io/RawSource // kotlinx.io.files/FileSystem.source|source(kotlinx.io.files.Path){}[0]
-}
-
-sealed interface kotlinx.io/Sink : kotlinx.io/RawSink { // kotlinx.io/Sink|null[0]
- abstract val buffer // kotlinx.io/Sink.buffer|{}buffer[0]
- abstract fun (): kotlinx.io/Buffer // kotlinx.io/Sink.buffer.|(){}[0]
-
- abstract fun emit() // kotlinx.io/Sink.emit|emit(){}[0]
- abstract fun flush() // kotlinx.io/Sink.flush|flush(){}[0]
- abstract fun hintEmit() // kotlinx.io/Sink.hintEmit|hintEmit(){}[0]
- abstract fun transferFrom(kotlinx.io/RawSource): kotlin/Long // kotlinx.io/Sink.transferFrom|transferFrom(kotlinx.io.RawSource){}[0]
- abstract fun write(kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...) // kotlinx.io/Sink.write|write(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- abstract fun write(kotlinx.io/RawSource, kotlin/Long) // kotlinx.io/Sink.write|write(kotlinx.io.RawSource;kotlin.Long){}[0]
- abstract fun writeByte(kotlin/Byte) // kotlinx.io/Sink.writeByte|writeByte(kotlin.Byte){}[0]
- abstract fun writeInt(kotlin/Int) // kotlinx.io/Sink.writeInt|writeInt(kotlin.Int){}[0]
- abstract fun writeLong(kotlin/Long) // kotlinx.io/Sink.writeLong|writeLong(kotlin.Long){}[0]
- abstract fun writeShort(kotlin/Short) // kotlinx.io/Sink.writeShort|writeShort(kotlin.Short){}[0]
-}
-
-sealed interface kotlinx.io/Source : kotlinx.io/RawSource { // kotlinx.io/Source|null[0]
- abstract val buffer // kotlinx.io/Source.buffer|{}buffer[0]
- abstract fun (): kotlinx.io/Buffer // kotlinx.io/Source.buffer.|(){}[0]
-
- abstract fun exhausted(): kotlin/Boolean // kotlinx.io/Source.exhausted|exhausted(){}[0]
- abstract fun peek(): kotlinx.io/Source // kotlinx.io/Source.peek|peek(){}[0]
- abstract fun readAtMostTo(kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...): kotlin/Int // kotlinx.io/Source.readAtMostTo|readAtMostTo(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- abstract fun readByte(): kotlin/Byte // kotlinx.io/Source.readByte|readByte(){}[0]
- abstract fun readInt(): kotlin/Int // kotlinx.io/Source.readInt|readInt(){}[0]
- abstract fun readLong(): kotlin/Long // kotlinx.io/Source.readLong|readLong(){}[0]
- abstract fun readShort(): kotlin/Short // kotlinx.io/Source.readShort|readShort(){}[0]
- abstract fun readTo(kotlinx.io/RawSink, kotlin/Long) // kotlinx.io/Source.readTo|readTo(kotlinx.io.RawSink;kotlin.Long){}[0]
- abstract fun request(kotlin/Long): kotlin/Boolean // kotlinx.io/Source.request|request(kotlin.Long){}[0]
- abstract fun require(kotlin/Long) // kotlinx.io/Source.require|require(kotlin.Long){}[0]
- abstract fun skip(kotlin/Long) // kotlinx.io/Source.skip|skip(kotlin.Long){}[0]
- abstract fun transferTo(kotlinx.io/RawSink): kotlin/Long // kotlinx.io/Source.transferTo|transferTo(kotlinx.io.RawSink){}[0]
-}
-
-final class kotlinx.io.files/FileMetadata { // kotlinx.io.files/FileMetadata|null[0]
- constructor (kotlin/Boolean = ..., kotlin/Boolean = ..., kotlin/Long = ...) // kotlinx.io.files/FileMetadata.|(kotlin.Boolean;kotlin.Boolean;kotlin.Long){}[0]
-
- final val isDirectory // kotlinx.io.files/FileMetadata.isDirectory|{}isDirectory[0]
- final fun (): kotlin/Boolean // kotlinx.io.files/FileMetadata.isDirectory.|(){}[0]
- final val isRegularFile // kotlinx.io.files/FileMetadata.isRegularFile|{}isRegularFile[0]
- final fun (): kotlin/Boolean // kotlinx.io.files/FileMetadata.isRegularFile.|(){}[0]
- final val size // kotlinx.io.files/FileMetadata.size|{}size[0]
- final fun (): kotlin/Long // kotlinx.io.files/FileMetadata.size.|(){}[0]
-}
-
-final class kotlinx.io.files/Path { // kotlinx.io.files/Path|null[0]
- final val isAbsolute // kotlinx.io.files/Path.isAbsolute|{}isAbsolute[0]
- final fun (): kotlin/Boolean // kotlinx.io.files/Path.isAbsolute.|(){}[0]
- final val name // kotlinx.io.files/Path.name|{}name[0]
- final fun (): kotlin/String // kotlinx.io.files/Path.name.|(){}[0]
- final val parent // kotlinx.io.files/Path.parent|{}parent[0]
- final fun (): kotlinx.io.files/Path? // kotlinx.io.files/Path.parent.|(){}[0]
-
- final fun equals(kotlin/Any?): kotlin/Boolean // kotlinx.io.files/Path.equals|equals(kotlin.Any?){}[0]
- final fun hashCode(): kotlin/Int // kotlinx.io.files/Path.hashCode|hashCode(){}[0]
- final fun toString(): kotlin/String // kotlinx.io.files/Path.toString|toString(){}[0]
-}
-
-final class kotlinx.io/Buffer : kotlinx.io/Sink, kotlinx.io/Source { // kotlinx.io/Buffer|null[0]
- constructor () // kotlinx.io/Buffer.|(){}[0]
-
- final val buffer // kotlinx.io/Buffer.buffer|{}buffer[0]
- final fun (): kotlinx.io/Buffer // kotlinx.io/Buffer.buffer.|(){}[0]
- final val size // kotlinx.io/Buffer.size|{}size[0]
- final fun (): kotlin/Long // kotlinx.io/Buffer.size.|(){}[0]
-
- final var head // kotlinx.io/Buffer.head|{}head[0]
- final fun (): kotlinx.io/Segment? // kotlinx.io/Buffer.head.|(){}[0]
- final fun (kotlinx.io/Segment?) // kotlinx.io/Buffer.head.|(kotlinx.io.Segment?){}[0]
- final var sizeMut // kotlinx.io/Buffer.sizeMut|{}sizeMut[0]
- final fun (): kotlin/Long // kotlinx.io/Buffer.sizeMut.|(){}[0]
- final fun (kotlin/Long) // kotlinx.io/Buffer.sizeMut.|(kotlin.Long){}[0]
- final var tail // kotlinx.io/Buffer.tail|{}tail[0]
- final fun (): kotlinx.io/Segment? // kotlinx.io/Buffer.tail.|(){}[0]
- final fun (kotlinx.io/Segment?) // kotlinx.io/Buffer.tail.|(kotlinx.io.Segment?){}[0]
-
- final fun clear() // kotlinx.io/Buffer.clear|clear(){}[0]
- final fun close() // kotlinx.io/Buffer.close|close(){}[0]
- final fun copy(): kotlinx.io/Buffer // kotlinx.io/Buffer.copy|copy(){}[0]
- final fun copyTo(kotlinx.io/Buffer, kotlin/Long = ..., kotlin/Long = ...) // kotlinx.io/Buffer.copyTo|copyTo(kotlinx.io.Buffer;kotlin.Long;kotlin.Long){}[0]
- final fun emit() // kotlinx.io/Buffer.emit|emit(){}[0]
- final fun exhausted(): kotlin/Boolean // kotlinx.io/Buffer.exhausted|exhausted(){}[0]
- final fun flush() // kotlinx.io/Buffer.flush|flush(){}[0]
- final fun get(kotlin/Long): kotlin/Byte // kotlinx.io/Buffer.get|get(kotlin.Long){}[0]
- final fun hintEmit() // kotlinx.io/Buffer.hintEmit|hintEmit(){}[0]
- final fun peek(): kotlinx.io/Source // kotlinx.io/Buffer.peek|peek(){}[0]
- final fun readAtMostTo(kotlin/ByteArray, kotlin/Int, kotlin/Int): kotlin/Int // kotlinx.io/Buffer.readAtMostTo|readAtMostTo(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- final fun readAtMostTo(kotlinx.io/Buffer, kotlin/Long): kotlin/Long // kotlinx.io/Buffer.readAtMostTo|readAtMostTo(kotlinx.io.Buffer;kotlin.Long){}[0]
- final fun readByte(): kotlin/Byte // kotlinx.io/Buffer.readByte|readByte(){}[0]
- final fun readInt(): kotlin/Int // kotlinx.io/Buffer.readInt|readInt(){}[0]
- final fun readLong(): kotlin/Long // kotlinx.io/Buffer.readLong|readLong(){}[0]
- final fun readShort(): kotlin/Short // kotlinx.io/Buffer.readShort|readShort(){}[0]
- final fun readTo(kotlinx.io/RawSink, kotlin/Long) // kotlinx.io/Buffer.readTo|readTo(kotlinx.io.RawSink;kotlin.Long){}[0]
- final fun recycleTail() // kotlinx.io/Buffer.recycleTail|recycleTail(){}[0]
- final fun request(kotlin/Long): kotlin/Boolean // kotlinx.io/Buffer.request|request(kotlin.Long){}[0]
- final fun require(kotlin/Long) // kotlinx.io/Buffer.require|require(kotlin.Long){}[0]
- final fun skip(kotlin/Long) // kotlinx.io/Buffer.skip|skip(kotlin.Long){}[0]
- final fun toString(): kotlin/String // kotlinx.io/Buffer.toString|toString(){}[0]
- final fun transferFrom(kotlinx.io/RawSource): kotlin/Long // kotlinx.io/Buffer.transferFrom|transferFrom(kotlinx.io.RawSource){}[0]
- final fun transferTo(kotlinx.io/RawSink): kotlin/Long // kotlinx.io/Buffer.transferTo|transferTo(kotlinx.io.RawSink){}[0]
- final fun writableSegment(kotlin/Int): kotlinx.io/Segment // kotlinx.io/Buffer.writableSegment|writableSegment(kotlin.Int){}[0]
- final fun write(kotlin/ByteArray, kotlin/Int, kotlin/Int) // kotlinx.io/Buffer.write|write(kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- final fun write(kotlinx.io/Buffer, kotlin/Long) // kotlinx.io/Buffer.write|write(kotlinx.io.Buffer;kotlin.Long){}[0]
- final fun write(kotlinx.io/RawSource, kotlin/Long) // kotlinx.io/Buffer.write|write(kotlinx.io.RawSource;kotlin.Long){}[0]
- final fun writeByte(kotlin/Byte) // kotlinx.io/Buffer.writeByte|writeByte(kotlin.Byte){}[0]
- final fun writeInt(kotlin/Int) // kotlinx.io/Buffer.writeInt|writeInt(kotlin.Int){}[0]
- final fun writeLong(kotlin/Long) // kotlinx.io/Buffer.writeLong|writeLong(kotlin.Long){}[0]
- final fun writeShort(kotlin/Short) // kotlinx.io/Buffer.writeShort|writeShort(kotlin.Short){}[0]
-}
-
-final class kotlinx.io/Segment { // kotlinx.io/Segment|null[0]
- final val remainingCapacity // kotlinx.io/Segment.remainingCapacity|{}remainingCapacity[0]
- final fun (): kotlin/Int // kotlinx.io/Segment.remainingCapacity.|(){}[0]
- final val size // kotlinx.io/Segment.size|{}size[0]
- final fun (): kotlin/Int // kotlinx.io/Segment.size.|(){}[0]
-
- final var limit // kotlinx.io/Segment.limit|{}limit[0]
- final fun (): kotlin/Int // kotlinx.io/Segment.limit.|(){}[0]
- final fun (kotlin/Int) // kotlinx.io/Segment.limit.|(kotlin.Int){}[0]
- final var next // kotlinx.io/Segment.next|{}next[0]
- final fun (): kotlinx.io/Segment? // kotlinx.io/Segment.next.|(){}[0]
- final fun (kotlinx.io/Segment?) // kotlinx.io/Segment.next.|(kotlinx.io.Segment?){}[0]
- final var pos // kotlinx.io/Segment.pos|{}pos[0]
- final fun (): kotlin/Int // kotlinx.io/Segment.pos.|(){}[0]
- final fun (kotlin/Int) // kotlinx.io/Segment.pos.|(kotlin.Int){}[0]
- final var prev // kotlinx.io/Segment.prev|{}prev[0]
- final fun (): kotlinx.io/Segment? // kotlinx.io/Segment.prev.|(){}[0]
- final fun (kotlinx.io/Segment?) // kotlinx.io/Segment.prev.|(kotlinx.io.Segment?){}[0]
-
- final fun dataAsByteArray(kotlin/Boolean): kotlin/ByteArray // kotlinx.io/Segment.dataAsByteArray|dataAsByteArray(kotlin.Boolean){}[0]
- final fun writeBackData(kotlin/ByteArray, kotlin/Int) // kotlinx.io/Segment.writeBackData|writeBackData(kotlin.ByteArray;kotlin.Int){}[0]
-}
-
-open class kotlinx.io.files/FileNotFoundException : kotlinx.io/IOException { // kotlinx.io.files/FileNotFoundException|null[0]
- constructor (kotlin/String?) // kotlinx.io.files/FileNotFoundException.|(kotlin.String?){}[0]
-}
-
-open class kotlinx.io/EOFException : kotlinx.io/IOException { // kotlinx.io/EOFException|null[0]
- constructor () // kotlinx.io/EOFException.|(){}[0]
- constructor (kotlin/String?) // kotlinx.io/EOFException.|(kotlin.String?){}[0]
-}
-
-open class kotlinx.io/IOException : kotlin/Exception { // kotlinx.io/IOException|null[0]
- constructor () // kotlinx.io/IOException.|(){}[0]
- constructor (kotlin/String?) // kotlinx.io/IOException.|(kotlin.String?){}[0]
- constructor (kotlin/String?, kotlin/Throwable?) // kotlinx.io/IOException.|(kotlin.String?;kotlin.Throwable?){}[0]
- constructor (kotlin/Throwable?) // kotlinx.io/IOException.|(kotlin.Throwable?){}[0]
-}
-
-final object kotlinx.io.unsafe/UnsafeBufferOperations { // kotlinx.io.unsafe/UnsafeBufferOperations|null[0]
- final val maxSafeWriteCapacity // kotlinx.io.unsafe/UnsafeBufferOperations.maxSafeWriteCapacity|{}maxSafeWriteCapacity[0]
- final fun (): kotlin/Int // kotlinx.io.unsafe/UnsafeBufferOperations.maxSafeWriteCapacity.|(){}[0]
-
- final fun moveToTail(kotlinx.io/Buffer, kotlin/ByteArray, kotlin/Int = ..., kotlin/Int = ...) // kotlinx.io.unsafe/UnsafeBufferOperations.moveToTail|moveToTail(kotlinx.io.Buffer;kotlin.ByteArray;kotlin.Int;kotlin.Int){}[0]
- final inline fun forEachSegment(kotlinx.io/Buffer, kotlin/Function2) // kotlinx.io.unsafe/UnsafeBufferOperations.forEachSegment|forEachSegment(kotlinx.io.Buffer;kotlin.Function2){}[0]
- final inline fun iterate(kotlinx.io/Buffer, kotlin/Function2) // kotlinx.io.unsafe/UnsafeBufferOperations.iterate|iterate(kotlinx.io.Buffer;kotlin.Function2