Skip to content

Commit 4ae842c

Browse files
committed
Update README.md
1 parent 940577d commit 4ae842c

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

README.md

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ fun Iterable<T>.toPersistentSet(): PersistentSet<T>
8080
#### `+` and `-` operators
8181

8282
`plus` and `minus` operators on persistent collections exploit their immutability
83-
and delegate the implementation to the collections themselves.
84-
The operation is performed with persistence in mind: the returned immutable collection may share storage
83+
and delegate the implementation to the collections themselves.
84+
The operation is performed with persistence in mind: the returned immutable collection may share storage
8585
with the original collection.
8686

8787
```kotlin
@@ -90,8 +90,8 @@ val newList = persistentListOf("a", "b") + "c"
9090
```
9191

9292
> **Note:** you need to import these operators from `kotlinx.collections.immutable` package
93-
in order for them to take the precedence over the ones from the
94-
standard library.
93+
> in order for them to take the precedence over the ones from the
94+
> standard library.
9595
9696
```kotlin
9797
import kotlinx.collections.immutable.*
@@ -112,6 +112,36 @@ With `mutate` it transforms to:
112112
collection.mutate { some_actions_on(it) }
113113
```
114114

115+
### Serialization
116+
117+
Serialization modules allows you to apply custom immutable collection serializers, for example:
118+
119+
```kotlin
120+
@Serializable
121+
private class MyCustomClass<K, V>(
122+
@Serializable(with = ImmutableMapSerializer::class)
123+
val immutableMap: ImmutableMap<K, V>
124+
)
125+
```
126+
127+
#### Collection Serializers
128+
129+
| Serializer | Conversion method
130+
|-------------------------------|-------------------------
131+
| `ImmutableListSerializer` | `toImmutableList()` |
132+
| `PersistentListSerializer` | `toPersistentList()` |
133+
| `ImmutableSetSerializer` | `toImmutableSet()` |
134+
| `PersistentSetSerializer` | `toPersistentSet()` |
135+
| `PersistentHashSetSerializer` | `toPersistentHashSet()` |
136+
137+
#### Map Serializers
138+
139+
| Serializer | Conversion method
140+
|-------------------------------|-------------------------
141+
| `ImmutableMapSerializer` | `toImmutableMap()` |
142+
| `PersistentMapSerializer` | `toPersistentMap()` |
143+
| `PersistentHashMapSerializer` | `toPersistentHashMap()` |
144+
115145
## Using in your projects
116146

117147
> Note that the library is experimental and the API is subject to change.
@@ -138,6 +168,7 @@ kotlin {
138168
commonMain {
139169
dependencies {
140170
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.8")
171+
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable-serialization:0.3.8")
141172
}
142173
}
143174
}
@@ -150,11 +181,19 @@ The Maven Central repository is available for dependency lookup by default.
150181
Add dependencies (you can also add other modules that you need):
151182

152183
```xml
153-
<dependency>
154-
<groupId>org.jetbrains.kotlinx</groupId>
155-
<artifactId>kotlinx-collections-immutable-jvm</artifactId>
156-
<version>0.3.8</version>
157-
</dependency>
184+
185+
<dependencies>
186+
<dependency>
187+
<groupId>org.jetbrains.kotlinx</groupId>
188+
<artifactId>kotlinx-collections-immutable-jvm</artifactId>
189+
<version>0.3.8</version>
190+
</dependency>
191+
<dependency>
192+
<groupId>org.jetbrains.kotlinx</groupId>
193+
<artifactId>kotlinx-collections-immutable-serialization-jvm</artifactId>
194+
<version>0.3.8</version>
195+
</dependency>
196+
</dependencies>
158197
```
159198

160199
## Building from source

0 commit comments

Comments
 (0)