What's happening is that when you try to import decoders::Decoders
in image.rs
, you need to go through the next level up, because using this:
mod decoders
use decoders::Decoders
Means that decoders
will now be "owned" or under image
, which is impossible since only lib.rs
, mod.rs
or main.rs
files can have modules in other files. So, to fix this, you can either change your file structure to this:
src
main.rs
image
mod.rs
decoder.rs
Or, use this in main.rs
:
mod decoders;
mod image;
and this in image.rs
:
use super::decoders::Decoders;
//Or alternatively
use crate::decoders::Decoders;
Also, to fix your nested-mod problem, do the following in decoders.rs
:
//Your code, no `mod Decoders`
and the following where you have your mod decoders
statement:
#[your_attribs]
mod decoders;