Pg_gensql: feedback on dispatching functions & TryInto

Hey all,

I'm just learning Rust, with a predominantly Python with C++ & JS background.

I've put together a small utility called pg_gensql that generates INSERT statements from an SQL statement. It works, but there are a couple of bits that feel a little uncomfortable/could do with some improvement.

In serialize_for_insert, there is a function that dispatches to other typed functions based on a byte buffer and a discriminator. It feels very repetitive at the moment, especially with scalar and vector versions. Is there something I can do better here? If the answer is macros, I'll need to learn the basics first. :slight_smile:

In raw, I implemented a try_into function for Raw -> FromSql, but couldn't formally implement TryFrom/TryInto, as it failed with "conflicting implementations of trait std::convert::TryFrom<raw::Raw<'_>>", since Raw is itself an implementation of FromSql. Is it possible to get that to work?

Thanks everyone!