The init command

A SaaS RS Managed Rust Workspace must be first initialized with the init command. It establishes the requisite workspace layout, and also defines your brand which will be used to namespace your gRPC protocols.

The init command is used like this:

saas-rs init --brand acme

The following Rust workspace is laid out for you:

proto/
crates/
├── common/
├── config_store/
├── object_store/
└── session_store/
.rustfmt.toml
.saas-rs.toml
CHANGELOG.md
Cargo.lock
Cargo.toml
Makefile
README.md
  • The common crate is where you can place shared code. This will include your brand, which can be found in common/src/consts/mod.rs as: pub const BRAND: &str = "acme";
  • The config_store crate defines metadata and factory functions for your primary storage. Actual storage adapters are defined in the open source saas-rs-sdk crate.
  • The object_store crate defines metadata and factory functions for your object storage. This could come in handy if your SaaS will need to manage file uploads on behalf of your users, or other large objects.
  • The session_store crate defines metadata and factory functions for your high-performance session storage. The session store is a good place to store short-lived session tokens, long-lived API Keys, or transient Stripe Checkout records.

After running the init command, you'll notice that the CLI will indicate that your git workspace is now dirty, and that this would be a good time to run make and to then commit the generated changes before modifying anything.

$ saas-rs init --brand acme
Response received
Patch applied to local workspace
Workspace is dirty; now would be a good time to run `make` and then commit

$ make
cargo fmt --all
cargo build
    Updating crates.io index
     Locking 301 packages to latest compatible versions
      Adding matchit v0.8.4 (available: v0.8.6)
      Adding prost v0.13.5 (available: v0.14.1)
   Compiling common v0.1.0 (/Users/davidr/workspaces/foo/crates/common)
   Compiling config-store v0.1.0 (/Users/davidr/workspaces/foo/crates/config_store)
   Compiling object-store v0.1.0 (/Users/davidr/workspaces/foo/crates/object_store)
   Compiling session-store v0.1.0 (/Users/davidr/workspaces/foo/crates/session_store)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.73s

$ git add -A
$ git commit -m "saas-rs init --brand acme"

Multi-Language Monorepos

If your git repository will need to hold code in other languages, the Rust workspace can be initialized as a subdirectory. In this hypothetical example, a Rust workspace and its Python language binding co-exist within the same git repo.

proto/
python/
rust/
└── crates/
    ├── common/
    ├── config_store/
    ├── object_store/
    └── session_store/
    .rustfmt.toml
    CHANGELOG.md
    Cargo.lock
    Cargo.toml
    Makefile
    README.md
.saas-rs.toml

In such a situation, the init command is used like this:

mdbook init --brand acme --path rust

©2025 SaaS RS | Website | GitHub | GitLab | Contact