RFC - Restructure project
jeremyhager opened this issue · 4 comments
I've noticed the project doesn't follow the usual style of a Rust project. I'd like to propose a change in the structure, which will require a bit of rework. The main changes are a root src/
file for a few files like main, lib, etc. Then the crates can live within the root directory as well - though, I've seen examples where this is the case and isn't. As such, I have 2 proposals I'd like to add - flat and structured. I think we'll be okay with flat, but I wanted to add the structured type as an option.
current
├── Cargo.lock
├── Cargo.toml
├── README.md
├── tafkars
│ ├── Cargo.toml
│ ├── README.md
│ └── src
│ ├── comment.rs
│ ├── lib.rs
│ ├── listing.rs
│ └── submission.rs
└── tafkars-lemmy
├── Cargo.lock
├── Cargo.toml
├── README.md
└── src
├── api_translation.rs
├── endpoints.rs
├── main.rs
└── web_config.rs
Proposed1 - flat
Pros: Simple, straightforward. Seen in "smaller" projects such as Atuin
Cons: For bigger projects at least, this is a bit uncommon - see Lemmy or Cargo.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── src
│ ├── main.rs
│ ├── lib.rs
├── tafkars
│ ├── Cargo.toml
│ ├── README.md
│ └── src
│ ├── comment.rs
│ ├── lib.rs
│ ├── listing.rs
│ └── submission.rs
└── tafkars-lemmy
├── Cargo.lock
├── Cargo.toml
├── README.md
└── src
├── lib.rs
├── api_translation.rs
├── endpoints.rs
└── web_config.rs
Proposed2 - structured
Pros: Allows for more organization if/when project gets bigger (docker folders, integration tests, scripts, etc.). See see Lemmy or Cargo for large-code examples.
Cons: Can add unnecessary complexity, and isn't always necessary. For example, another large-ish project is Lapce which uses a more flat structure like above.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── crates
│ ├── tafkars
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src
│ │ ├── comment.rs
│ │ ├── lib.rs
│ │ ├── listing.rs
│ │ └── submission.rs
│ └── tafkars-lemmy
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── README.md
│ └── src
│ ├── api_translation.rs
│ ├── endpoints.rs
│ ├── main.rs
│ └── web_config.rs
└── src
├── lib.rs
└── main.rs
My vote, if we do change things, is to go with flat as I don't think it's necessary to put different crates in folders. However, I'm just here to help so I hope to hear thoughts on this. In either case, looking forward to the future!
Never used workspaces before and just went with my gut. No problem with changing if the way I did it is not idiomatic. Does this mean that tafkars-lemmy
would become a library crate and there would be a new top level crate that is a binary crate and a workspace at the same time?
Hmm, this is a good point, it probably would. As a matter of fact looking back at Atuin and Lapce, they have a structure essentially the same as this project. I may have jumped the gun on this a little 😅
I'm a bit new to Rust as well, perhaps it's best we leave the project as-is folder structure wise. In any case, thanks again!
Closed this out, we'll stick with the current structure