Closed aermicioi closed 8 years ago
I was wondering when someone would notice :P It's a ushort by default, but it can be a larger integer. I hadn't made it easy to select a different one because I didn't need to and in the transition from classes to structs I kind of hid the functionality by accident. Fix coming up.
In your example now:
import cerealed;
struct ubyted {
ubyte[] payload;
}
void main() {
ubyte[] buff = new ubyte[2 ^^ 16];
Cerealiser cer;
cer.grain!uint(buff);
}
If the array is in a struct, tag it with @LengthType
:
struct Foo {
@LengthType!ubyte ushort[] arr;
}
auto enc = Cerealiser();
auto foo = Foo([7, 8, 9]);
enc ~= foo;
assert(enc.bytes == [3, 0, 7, 0, 8, 0, 9]);
auto dec = Decerealiser(enc.bytes);
assert(dec.value!Foo == foo)
Why does Cerealed limit max size of serialized data to 64KiB?
Consider:
This code will fail with assert error on line 87 in cereal.d Error: cerealed-0.6.6/src/cerealed/cereal.d(87): overflow
A buffer with length less with one will not trigger assert. Is it by design, or is it a bug?