【Rust】ワークスペースによる開発

引き続き「RustによるWebアプリケーション開発(豊田優貴著)」を参考に、ワークスペースによる開発を学んでいきます。
https://github.com/rust-web-app-book/rusty-book-manager

$ tree
.
├── Cargo.lock
├── Cargo.toml
├── compose.yaml
├── Dockerfile
├── makefile.toml
├── src
│ └── main.rs
└── target

sr/bin/app.rs にmain関数を記載する。main.rsは削除

### ワークスペースメンバーの作成
$ cargo new –lib api
$ cargo new –lib kernel
$ cargo new –lib adapter
$ cargo new –lib shared
$ cargo new –lib registry

### ワークスペースのメンバーを定義
Cargo.toml

[[bin]]
name = "app"
path = "src/bin/app.rs"

[workspace]
members = ["api", "kernel", "adapter", "shared", "registry"]

[workspace.dependencies]
adapter = { path = "./adapter" }
api = { path = "./api" }
kernel = { path = "./kernel" }
shared = { path = "./shared" }
registry = { path = "./registry" }
anyhow = "1.0.75"
axum = {version = "0.7.5", features = ["macros"]}
tokio = { version = "1.37.0", features = ["full"]}

[dependencies]
adapter.workspace = true
api.workspace = true
registry.workspace = true
shared.workspace = true
anyhow.workspace = true
tokio.workspace = true
axum.workspace = true

[dev-dependencies]
rstest = "0.18.2"

なるほど、なかなか複雑やわ ワークスペースの開発方法はもうちょっと勉強する必要がある。。