RocketBoost Orbit logo Orbit rocketboost.rs

Installation

Orbit is a Rust crate. It needs a Rust toolchain that supports edition 2024, which is Rust 1.85 or newer, and a MySQL or MariaDB server. Orbit is added from its git repository.

Add the crate

cargo add orbit-orm --git https://github.com/lajennylove/Orbit

The same dependency in Cargo.toml:

[dependencies]
orbit-orm = { git = "https://github.com/lajennylove/Orbit" }

The package is orbit-orm, and the Rust crate name is orbit_orm, so the code imports from orbit_orm.

Features

  • derive, on by default, adds the OrbitModel derive. See Models. Without it, write the Model impls by hand.
  • blocking, off by default, adds orbit_orm::blocking, the synchronous API. See Blocking API.

To turn on the blocking API:

cargo add orbit-orm --features blocking --git https://github.com/lajennylove/Orbit

To leave out the derive, turn off the default features:

[dependencies]
orbit-orm = { git = "https://github.com/lajennylove/Orbit", default-features = false }

Async runtime

The async API runs on Tokio. A Rocket app already runs on Tokio, so nothing more is needed. A plain binary needs a runtime, such as #[tokio::main].

Sqlx for hand-written models

The derive needs no other crate. A hand-written model implements sqlx's FromRow, so the app needs sqlx too. Use the version Orbit uses, which is 0.9.0, so that both use one copy of it:

sqlx = { version = "0.9.0", default-features = false, features = ["mysql"] }

See Models for the hand-written form.