I am using tokio_postgres and would like to match on the type of a column in order to handle column values dynamically.
It seems that the possible types are defined in the postgres_types library in the Inner
enum in type_gen.rs
, but I cannot access it, as it is private.
The other option would be to match on the Oid value accessible from the column type (with .type_().oid()
), but this does not seem like a great way to determine the column type at runtime.
There is also .type_().name()
but then I am matching on a &str, which seems like it would be less performant than matching on an integer or enum?
Is there a better way of getting at the column type?