blitzarx1 / egui_graphs

Interactive graph visualization widget for rust powered by egui and petgraph
https://docs.rs/crate/egui_graphs
MIT License
417 stars 30 forks source link

Feature definition incorrect for Metadata? #158

Closed jzanecook closed 9 months ago

jzanecook commented 10 months ago

Hello, I am Zignepeheous Enrique von Gutierrez al Atir, and I was rigorously implementing your sexy egui_graphs package into my soul egui/eframe application when I came upon a rather worrying tale of that there once was a trait bound metadata::Metadata: serde::ser::Serialize which was not feeling very satisfied.

I noticed that on further inspection, as you may see from the log below, introducing the egui_persistence feature fixed the issue, which I very graciously celebrated while fixing everything else that was wrong with my application. Is it possible that on Lines 52 - 55 of metadata.rs it is referencing the wrong feature? Or am I misinterpreting this?

This is my output from using a local 0.25.0 version (from PR #157) ```` ❯ cargo add --path ../../../egui_graphs Adding egui_graphs (local) to dependencies. Features: - egui_persistence - events - serde Updating crates.io index ❯ cargo watch -x "run" [Running 'cargo run'] Compiling egui_graphs v0.17.1 (/mnt/sda1/home/z/Documents/Projects/egui_graphs) error[E0277]: the trait bound `metadata::Metadata: serde::ser::Serialize` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:85:49 | 85 | ui.data_mut(|data| data.get_persisted::(Id::NULL).unwrap_or_default()) | ^^^^^^^^ the trait `serde::ser::Serialize` is not implemented for `metadata::Metadata` | = help: the following other types implement trait `serde::ser::Serialize`: bool char isize i8 i16 i32 i64 i128 and 285 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::get_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:397:29 | 397 | pub fn get_persisted(&mut self, id: Id) -> Option { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::get_persisted` error[E0277]: the trait bound `for<'a> metadata::Metadata: serde::de::Deserialize<'a>` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:85:49 | 85 | ui.data_mut(|data| data.get_persisted::(Id::NULL).unwrap_or_default()) | ^^^^^^^^ the trait `for<'a> serde::de::Deserialize<'a>` is not implemented for `metadata::Metadata` | = help: the following other types implement trait `serde::de::Deserialize<'de>`: bool char isize i8 i16 i32 i64 i128 and 285 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::get_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:397:29 | 397 | pub fn get_persisted(&mut self, id: Id) -> Option { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::get_persisted` error[E0277]: the trait bound `metadata::Metadata: serde::ser::Serialize` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:90:45 | 90 | data.insert_persisted(Id::NULL, self); | ---------------- ^^^^ the trait `serde::ser::Serialize` is not implemented for `metadata::Metadata` | | | required by a bound introduced by this call | = help: the following other types implement trait `serde::ser::Serialize`: bool char isize i8 i16 i32 i64 i128 and 285 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::insert_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:376:32 | 376 | pub fn insert_persisted(&mut self, id: Id, value: T) { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::insert_persisted` error[E0277]: the trait bound `for<'a> metadata::Metadata: serde::de::Deserialize<'a>` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:90:45 | 90 | data.insert_persisted(Id::NULL, self); | ---------------- ^^^^ the trait `for<'a> serde::de::Deserialize<'a>` is not implemented for `metadata::Metadata` | | | required by a bound introduced by this call | = help: the following other types implement trait `serde::de::Deserialize<'de>`: bool char isize i8 i16 i32 i64 i128 and 285 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::insert_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:376:32 | 376 | pub fn insert_persisted(&mut self, id: Id, value: T) { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::insert_persisted` For more information about this error, try `rustc --explain E0277`. error: could not compile `egui_graphs` (lib) due to 4 previous errors [Finished running. Exit status: 101] ^C2024-01-11T19:53:06.750-06:00 - WARN - Could not pass on signal to command: I/O error: No such process (os error 3) ❯ cargo add --path ../../../egui_graphs --features serde Adding egui_graphs (local) to dependencies. Features: + serde - egui_persistence - events ❯ cargo watch -x "run" [Running 'cargo run'] Compiling petgraph v0.6.4 Compiling egui_graphs v0.17.1 (/mnt/sda1/home/z/Documents/Projects/egui_graphs) error[E0277]: the trait bound `metadata::Metadata: Serialize` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:85:49 | 85 | ui.data_mut(|data| data.get_persisted::(Id::NULL).unwrap_or_default()) | ^^^^^^^^ the trait `Serialize` is not implemented for `metadata::Metadata` | = help: the following other types implement trait `Serialize`: bool char isize i8 i16 i32 i64 i128 and 299 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::get_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:397:29 | 397 | pub fn get_persisted(&mut self, id: Id) -> Option { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::get_persisted` error[E0277]: the trait bound `for<'a> metadata::Metadata: Deserialize<'a>` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:85:49 | 85 | ui.data_mut(|data| data.get_persisted::(Id::NULL).unwrap_or_default()) | ^^^^^^^^ the trait `for<'a> Deserialize<'a>` is not implemented for `metadata::Metadata` | = help: the following other types implement trait `Deserialize<'de>`: bool char isize i8 i16 i32 i64 i128 and 299 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::get_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:397:29 | 397 | pub fn get_persisted(&mut self, id: Id) -> Option { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::get_persisted` error[E0277]: the trait bound `metadata::Metadata: Serialize` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:90:45 | 90 | data.insert_persisted(Id::NULL, self); | ---------------- ^^^^ the trait `Serialize` is not implemented for `metadata::Metadata` | | | required by a bound introduced by this call | = help: the following other types implement trait `Serialize`: bool char isize i8 i16 i32 i64 i128 and 299 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::insert_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:376:32 | 376 | pub fn insert_persisted(&mut self, id: Id, value: T) { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::insert_persisted` error[E0277]: the trait bound `for<'a> metadata::Metadata: Deserialize<'a>` is not satisfied --> /mnt/sda1/home/z/Documents/Projects/egui_graphs/src/metadata.rs:90:45 | 90 | data.insert_persisted(Id::NULL, self); | ---------------- ^^^^ the trait `for<'a> Deserialize<'a>` is not implemented for `metadata::Metadata` | | | required by a bound introduced by this call | = help: the following other types implement trait `Deserialize<'de>`: bool char isize i8 i16 i32 i64 i128 and 299 others = note: required for `metadata::Metadata` to implement `SerializableAny` note: required by a bound in `IdTypeMap::insert_persisted` --> /home/z/.cargo/registry/src/index.crates.io-6f17d22bba15001f/egui-0.25.0/src/util/id_type_map.rs:376:32 | 376 | pub fn insert_persisted(&mut self, id: Id, value: T) { | ^^^^^^^^^^^^^^^ required by this bound in `IdTypeMap::insert_persisted` For more information about this error, try `rustc --explain E0277`. error: could not compile `egui_graphs` (lib) due to 4 previous errors [Finished running. Exit status: 101] ^C2024-01-11T19:53:58.996-06:00 - WARN - Could not pass on signal to command: I/O error: No such process (os error 3) ❯ cargo add --path ../../../egui_graphs --features serde,egui_persistence Adding egui_graphs (local) to dependencies. Features: + egui_persistence + serde - events ❯ cargo add --path ../../../egui_graphs --features serde,egui_persistence,events Adding egui_graphs (local) to dependencies. Features: + egui_persistence + events + serde Updating crates.io index ^[[A Fetch [===========> ] 118 complete; 1 pending ^[[A Fetch [==============> ] 214 complete; 3 pending ❯ cargo add --path ../../../egui_graphs --features serde,egui_persistence,events ❯ cargo watch -x "run" ````
blitzarx1 commented 9 months ago

Thanks for the report. Looking into it...

blitzarx1 commented 9 months ago

I checked on my own project that if I have not enabled persistence feature in egui crate, egui graphs compiles just fine, but if I have persistence feature enabled for egui than I have to mirror enabling egui_persistence feature for egui graphs. And this is the way it was designed and the way it is supposed to work.

jzanecook commented 9 months ago

Yes, I realized that afterwards. Thanks for the reply, though.