WrongCollectionSize exception added and more docs
This commit is contained in:
parent
ba6bf7eb37
commit
5b8df2ff20
@ -63,7 +63,7 @@ class BipackEncoder(val output: DataSink) : AbstractEncoder() {
|
||||
if (fixedSize < 0)
|
||||
encodeUInt(collectionSize.toUInt())
|
||||
else if (collectionSize != fixedSize) {
|
||||
throw IllegalArgumentException("collection size is $collectionSize while fixed size of $fixedSize is required")
|
||||
throw WrongCollectionSize("collection size is $collectionSize while fixed size of $fixedSize is required")
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
@ -47,6 +47,13 @@ annotation class CrcProtected
|
||||
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||
annotation class Unsigned
|
||||
|
||||
/**
|
||||
* Use it with collection of fixed size, like hash digest, key bits and so on, by not storing collection
|
||||
* size. It effectively reduced packed size to at least one byte. depending on the actual
|
||||
* collection size. As for nowonly collection types (e.g. ByteArray, List<T>m etc) are supported.
|
||||
* Note that if the actual collection size differs from [size], [BipackEncoder] will throw
|
||||
* [WrongCollectionSize] while encoding it.
|
||||
*/
|
||||
@SerialInfo
|
||||
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||
annotation class FixedSize(val size: Int)
|
||||
@ -55,5 +62,6 @@ open class InvalidFrameException(reason: String) : Exception(reason)
|
||||
class InvalidFrameHeaderException(reason: String = "Frame header does not match") : InvalidFrameException(reason)
|
||||
class InvalidFrameCRCException : InvalidFrameException("Checksum CRC32 failed")
|
||||
|
||||
class WrongCollectionSize(reason: String) : Exception(reason)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user