DEV Community


Discussion on: Web Development with Rust— 02/x: Deploy your first App

franky47 profile image
François Best

What I meant was that in a real-world case, your serverless endpoint/function will probably want to use business/domain/applicative code that is located and organised elsewhere, in Cargo workspaces, and Zeit's approach does not play well with that.

One way that could work would be to have a directory structure as follows:

├── workspace
│ ├── Cargo.toml      Workspace root definition
│ ├── Cargo.lock      Shared lockfile
│ ├── target/         Shared build directory
│ ├── foo
│ └── bar
└── serverless        Zeit Now endpoints
  ├── baz
  | ├── Cargo.toml    [dependencies] foo = { path = "../../workspace/foo" }
  | └──
  └── qux
    ├── Cargo.toml    [dependencies] bar = { path = "../../workspace/bar" }

Edit: after a quick test, this cannot work either, if the crates that the serverless endpoints depend on (here foo and bar) are not published, which would be the case if they are internal to the project.

Also, not having the Cargo.toml workspace root at the root of the project directory disables RLS, for code completion / formatting etc in VSCode.

I guess this is what people mean when they talk about lock-in with serverless, it's not so much about the platform, but the constraints they impose upon your project structure and dependency management.