This repository was archived by the owner on Nov 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
src/main/kotlin/io/github/dockyardmc/tide/stream Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 11kotlin.code.style =official
2- tide.version =3.0
2+ tide.version =3.2
Original file line number Diff line number Diff line change 1+ package io.github.dockyardmc.tide.stream
2+
3+ import io.netty.buffer.ByteBuf
4+
5+ class RecursiveStreamCodec <T >(self : (StreamCodec <T >) -> StreamCodec <T >) : StreamCodec<T> {
6+
7+ val delegate = self.invoke(this )
8+
9+ override fun write (buffer : ByteBuf , value : T ) {
10+ delegate.write(buffer, value)
11+ }
12+
13+ override fun read (buffer : ByteBuf ): T {
14+ return delegate.read(buffer)
15+ }
16+
17+ }
Original file line number Diff line number Diff line change 11package io.github.dockyardmc.tide.stream
22
3+ import io.github.dockyardmc.tide.codec.Codec
34import io.github.dockyardmc.tide.codec.CodecUtils
5+ import io.github.dockyardmc.tide.codec.RecursiveCodec
46import io.netty.buffer.ByteBuf
57import java.util.*
68
@@ -28,6 +30,7 @@ interface StreamCodec<T> {
2830 return ListStreamCodec <T >(this )
2931 }
3032
33+
3134 companion object {
3235 val UNIT = object : StreamCodec <Unit > {
3336
@@ -173,6 +176,10 @@ interface StreamCodec<T> {
173176 val leastSignificant = LONG .read(buffer)
174177 return UUID (mostSignificant, leastSignificant)
175178 }
179+
180+ fun <T > recursive (self : (StreamCodec <T >) -> StreamCodec <T >): RecursiveStreamCodec <T > {
181+ return RecursiveStreamCodec <T >(self)
182+ }
176183 }
177184
178185 val UUID_STRING = STRING .transform<UUID >({ uuid -> uuid.toString() }, { string -> java.util.UUID .fromString(string) })
You can’t perform that action at this time.
0 commit comments