A module structure problem has me puzzled.
.
├── main.rs
├── messages
│ ├── mod.rs
│ └── msgdecode.rs
├── pcap.rs
└── viewer
└── mod.rs
Layout is per the Rust book.
Error message is:
error[E0603]: struct import `Msgdecode` is private
--> src/pcap.rs:77:53
|
77 | fn processudppkt(mut decoder: &messages::msgdecode::Msgdecode, pkt: &PacketHeaders)
| ^^^^^^^^^ private struct import
|
note: the struct import `Msgdecode` is defined here...
--> src/messages/msgdecode.rs:13:5
|
13 | use crate::messages::Msgdecode;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...and refers to the struct `Msgdecode` which is defined here
--> src/messages/mod.rs:18:1
|
18 | pub struct Msgdecode {
| ^^^^^^^^^^^^^^^^^^^^ consider importing it directly
"mod.rs" is just a skeleton right now:
pub mod msgdecode;
pub struct Msgdecode {
}
Everything is public.
In "pcap.rs", the module is made visible with
use crate::messages;
That's enough that the compiler can find "messsages/mod.rs" from "pcap.rs", but it insists it's private.
The error hint "Consider importing it directly" let me to try "mod pub messages", but that just led to dead ends like
pub mod crate::messages; // not allowed
pub mod messages; // not found, since it's at the same level in the tree
How do I fix the privacy problem?