Skip to content

Commit 7f11771

Browse files
authored
Improve ByteString documentation (#158)
1 parent 19db7f2 commit 7f11771

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

bytestring/common/src/ByteString.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public fun ByteString(vararg bytes: Byte): ByteString = if (bytes.isEmpty()) {
3737

3838
/**
3939
* An immutable wrapper around a byte sequence providing [String] like functionality.
40+
*
41+
* ByteString allows treating binary data as a value and passing it to other functions
42+
* without worrying about data modification.
43+
* The class facilitates various operations on binary data, like comparison or testing for subsequence inclusion.
44+
*
45+
* ByteString is a good fit for untyped binary data that could not be represented as [String],
46+
* like hashes, payload of network packets, encrypted data, etc.
47+
*
48+
* ByteString copies data on creation as well as on conversion back to [ByteArray], thus guaranteeing that subsequent
49+
* modification of source data or data returned from [toByteArray] won't mutate the string itself.
4050
*/
4151
public class ByteString private constructor(
4252
private val data: ByteArray,

0 commit comments

Comments
 (0)