I want to use surrealdb in my rust code without needing a static mut (unsafe code) and without creating a new connection for everything. For example, using static mut:
static mut db: Option<Surreal> = None
#[tokio::main]
async fn main() {
unsafe {db = Surreal::new("0.0.0.0:8080")}
unsafe { db.as_ref() }.get("user", "whynotdogie")
unsafe { db.as_ref() }.create::<User>("nothendev")
}
And connecting every time speaks for itself. Is there any way to do this without unsafe code or creating a new connection every time?
I tried with static muts, but i need unsafe, and i tried connecting every time, but i dont think that is very performant and i think it uses a lot of bandwidth.