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)
|
if (fixedSize < 0)
|
||||||
encodeUInt(collectionSize.toUInt())
|
encodeUInt(collectionSize.toUInt())
|
||||||
else if (collectionSize != fixedSize) {
|
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
|
return this
|
||||||
}
|
}
|
||||||
|
@ -44,16 +44,24 @@ annotation class CrcProtected
|
|||||||
* it is the conly way to tell the serialized to use more compact unsigned variable length encoding.
|
* it is the conly way to tell the serialized to use more compact unsigned variable length encoding.
|
||||||
*/
|
*/
|
||||||
@SerialInfo
|
@SerialInfo
|
||||||
@Target(AnnotationTarget.FIELD,AnnotationTarget.PROPERTY)
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||||
annotation class Unsigned
|
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
|
@SerialInfo
|
||||||
@Target(AnnotationTarget.FIELD,AnnotationTarget.PROPERTY)
|
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
|
||||||
annotation class FixedSize(val size: Int)
|
annotation class FixedSize(val size: Int)
|
||||||
|
|
||||||
open class InvalidFrameException(reason: String) : Exception(reason)
|
open class InvalidFrameException(reason: String) : Exception(reason)
|
||||||
class InvalidFrameHeaderException(reason: String = "Frame header does not match") : InvalidFrameException(reason)
|
class InvalidFrameHeaderException(reason: String = "Frame header does not match") : InvalidFrameException(reason)
|
||||||
class InvalidFrameCRCException : InvalidFrameException("Checksum CRC32 failed")
|
class InvalidFrameCRCException : InvalidFrameException("Checksum CRC32 failed")
|
||||||
|
|
||||||
|
class WrongCollectionSize(reason: String) : Exception(reason)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user