rullst-orm 3.0.0

An Active Record ORM for Rust, inspired by Laravel's Orm.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::RullstValue;
use std::future::Future;

tokio::task_local! {
    pub static CURRENT_TENANT: RullstValue;
}

pub async fn with_tenant<T, F, R>(tenant_id: T, f: F) -> R
where
    T: Into<RullstValue>,
    F: Future<Output = R>,
{
    CURRENT_TENANT.scope(tenant_id.into(), f).await
}

pub fn get_tenant_id() -> Option<RullstValue> {
    CURRENT_TENANT.try_with(|t| t.clone()).ok()
}