Support for `internallength` attribute for fixed-size Custom Types
Hi,
With PR #2068, I have added support for the binary representation for varlena types.
I would like to also add support for fixed-size types, but I am not sure whether the CBOR serialization makes any compression attempt that would turn an apparently fixed-size type into a de-facto varlena type.
I understand that several traits currently derived for varlena types would have to be implemented separately for these fixed-size types - other than that are there any other particular difficulties you foresee?
My plan is to add a decorator like #[internallength(usize)], derive all of the necessary types (including assert_eq(serialized.len(), expected_internal_length) every time I serialize or deserialize to catch errors early) and that should be about it.
Do let me know what do you think of it.
Best, Luca
pgrx supports fixed-size types already. You can see in pgrx-tests/src/tests/complex.rs. There's some boilerplate necessary, but you can do it today.
In the example you linked it is handled by asking the user to manually define the whole set of features, right?
My idea was to simply extend the derive macro to add support for deriving all relevant aspects of such types automatically.
We are unable to use PostgresType derive and then pg_binary_protocol derive if we go the route of complex.rs example. And that just balloons up the boilerplate needed. Therefore, this is much necessary.
A possible duplicate of this issue is #143