0

I have following data structure

#[derive(Serialize, Debug)]
pub struct TestEvent {
    id: i32,
    event_mask: bit_vec::BitVec
}

While fetching value for this field from database, I am getting error as

the trait `postgres::types::FromSql` is not implemented for `bit_vec::BitVec`

FromSql standard mentions that trait needs to be enabled for bit-vec which I enabled through

postgres = { version = "0.14", features = ["with-chrono", "with-bit-vec"] }
bit-vec = {version = "0.6.1", features = ["serde"]}

Still I am getting that same error.

I've cross-posted this to the user's forum

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
ravi
  • 10,994
  • 1
  • 18
  • 36
  • This is a re-post of a now [deleted question](https://stackoverflow.com/q/56768067/1233251). Next time, please edit the previous question instead. – E_net4 Jun 26 '19 at 10:53
  • 1
    You need bit-vec v0.4.4 – Shepmaster Jun 26 '19 at 12:36
  • @Shepmaster That version of bit-vec does not have 'serde'. – ravi Jun 26 '19 at 12:41
  • Then you need to submit a PR to postgres to widen their dependency version of bit-vec. You might also import both versions of the crate concurrently and transform from 0.4.4 to whatever modern version you need, but that's more annoying. – Shepmaster Jun 26 '19 at 12:44
  • @Shepmaster already submitted the PR. Can you suggest other viable options I can employ (before at last using integer). I have a flag of 7 bits (bit(n) type) in PostgreSQL which I want to map with Rust data type. – ravi Jun 26 '19 at 12:47
  • You could try using postgres `v0.16.0-rc.1`. I'd probably just write a newtype around the integer myself. – Shepmaster Jun 26 '19 at 12:49
  • Could you link us to the PR you've submitted so we can follow the progress? – Shepmaster Jun 26 '19 at 12:49
  • @Shepmaster https://users.rust-lang.org/t/trait-postgres-fromsql-is-not-implemented-for-bit-vec-bitvec/29647 – ravi Jun 26 '19 at 12:50
  • A "PR" commonly refers to a [pull request](https://help.github.com/en/articles/about-pull-requests) – Shepmaster Jun 26 '19 at 12:51
  • Yes but here we just need to raise the issue. They move it to repository as in https://users.rust-lang.org/t/tokio-postgres-0-3-0-as-dependency-introduces-error-failed-to-resolve-use-of-undeclared-type-or-module-connecterror/29584 – ravi Jun 26 '19 at 12:53
  • In the future, please **always** cross-link your posts like this. That prevents people on one service from wasting their time answering a question that has already been answered on another. – Shepmaster Jun 26 '19 at 13:03
  • *They move it to repository* — no such thing happened (based on that comment). That poster is suggesting that **you** open an issue on the repository, just like I'm suggesting that **you** submit a PR to fix the problem. That's how open source works. – Shepmaster Jun 26 '19 at 13:04

0 Answers0