Skip to content
Using Rent

Generate the client

Your schema describes a user. Generation gives your application the Rust types and methods for working with that user:

model User {
  id     BigInt @id
  email  String @unique
  active Boolean @default(true)
  age    Int
}

From the project root, run:

rent generate

The command reads rent/schema.rsl, or your configured multi-file RSL directory. Now you can query a field by name, with Rust checking its value's type:

let maya = client
    .user()
    .email_eq("maya@example.com")
    .only()
    .await?;

Changing a field in RSL changes the generated API the next time you run the command. For continuous regeneration while editing, use rent dev.

What generation gives you

The generated client includes model types, field filters, relationship loaders, and transaction helpers. Each model has a shared builder for query, update, and delete operations, plus typed column constants for composing expressions. Use the compact field methods above for everyday queries.

When you want to store a condition, combine it dynamically, or reuse it across queries, use those column constants instead:

use generated::user::User;

let active_adult = User::active.eq(true) & User::age.ge(18);

let users = client
    .user()
    .filter(active_adult)
    .all()
    .await?;

Here active_adult is a typed SQL expression. You do not need to name expression values for straightforward field filters.

Use the client in your application

Create and configure a root client during startup. Binding a viewer or context returns a ScopedClient for request code. Configuration and explicit system access stay on RootClient. Transaction helpers preserve that distinction. The root and scoped clients guide shows how to pass these clients through an application.