I have 3 structs in 3 different files, file tree:
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│ ├── log_recorder
│ │ ├── log_listener.rs
│ │ ├── log_writer.rs
│ │ └── mod.rs
│ ├── main.rs
│ └── utils.rs
└── target
One struct holds the other two.
The log_recorder
is implemented in the mod.rs
:
pub mod log_listener;
pub mod log_writer;
struct log_recorder {
writer: log_writer,
listener: log_listener,
num_of_recorder_threads: u8,
run: bool,
}
impl log_recorder {
fn recording_loop(&self) {
// Do Something
}
}
The log_listener
is implemented in its own file and located in the log_recorder
dir:
pub struct log_listener {
redis_client: i8,
run: bool,
}
impl log_listener {
fn listening_loop(&self) {
// Do Something
}
}
The log_writer
is implemented in its own file and located in the log_recorder
dir:
pub struct log_writer {
fd: i8,
}
impl log_writer {
fn write(&self) {
// Do Something
}
}
I keep getting errors:
error[E0573]: expected type, found module `log_writer`
--> src/log_recorder/mod.rs:6:13
|
6 | writer: log_writer,
| ^^^^^^^^^^ not a type
|
help: consider importing this struct instead
|
error[E0573]: expected type, found module `log_listener`
--> src/log_recorder/mod.rs:7:15
|
7 | listener: log_listener,
| ^^^^^^^^^^^^ not a type
|
help: consider importing this struct instead
|
I saw this question 1, question2, but it didn't solve it for me.