Hi David,
That's a pretty opinionated driver :D Many extension libraries don't
have a binary format (ltree, for instance).
Usually in send/receive you can take the binary format of your struct
and convert it in some hardware-independent way. Your datum seems to
be:
typedef struct semver {
int32 vl_len_; /* varlena header */
vernum numbers[3];
char prerel[]; /* pre-release, including the null byte for
convenience */
} semver;
so you might send out and receive a buffer with the three hton'd
numbers and the string as length/data.
I think the best source of examples is the postgres source itself, as
pretty much all data types have a binary format. They should be all in
the `src/backend/utils/adt/` directory. For instance this is int2
https://github.com/postgres/postgres/blob/41f30ecc29c89285d3eecd435906c4e9cb048be4/src/backend/utils/adt/int.c#L86-L106
Things you might want to consider is whether to version the binary format.
As for testing, I am not aware of a way to do so from sql, as you
can't access the "internal" data type in SQL. Maybe you can cheat and
CREATE FUNCTION a test function with the same C function but different
types to make them available to SQL. Another way would be to test
using Psycopg 3, which can use binary parameters and results
(
https://www.psycopg.org/psycopg3/docs/basic/params.html#binary-data).
Hope this helps
-- Daniele