Provide Unit (singleton) codecs
This commit is contained in:
parent
ef2602895b
commit
c9dca76870
@ -35,6 +35,14 @@ interface MatteryStreamCodec<in S : ByteBuf, V> : StreamCodec<@UnsafeVariance S,
|
||||
}
|
||||
}
|
||||
|
||||
class MUnit<V>(val value: V) : MatteryStreamCodec<ByteBuf, V> {
|
||||
override fun decode(stream: ByteBuf): V {
|
||||
return value
|
||||
}
|
||||
|
||||
override fun encode(stream: ByteBuf, value: V) {}
|
||||
}
|
||||
|
||||
abstract class AbstractPair<in S : ByteBuf, A, B, P>(private val first: MatteryStreamCodec<S, A>, private val second: MatteryStreamCodec<S, B>) : MatteryStreamCodec<S, P> {
|
||||
protected abstract fun getFirst(value: P): A
|
||||
protected abstract fun getSecond(value: P): B
|
||||
|
Loading…
Reference in New Issue
Block a user