pub struct Orm;Expand description
Orm configuration structure
Implementations§
Source§impl Orm
impl Orm
Sourcepub async fn begin_transaction() -> Result<Transaction<'static>, Error>
pub async fn begin_transaction() -> Result<Transaction<'static>, Error>
Opens a transaction under a secret-free tracing span.
Sourcepub async fn transaction<F, R, E>(f: F) -> Result<R, Error>
pub async fn transaction<F, R, E>(f: F) -> Result<R, Error>
Executes a closure inside an isolated transaction and records its final commit or rollback outcome without recording SQL, bindings, or errors.
Called while another managed transaction is active on the same task,
the closure joins that transaction through a savepoint and receives the
same shared handle: an Err rolls back only the nested work, while a
success releases the savepoint so the work commits (or rolls back) with
the outer transaction. after_commit callbacks registered inside it
are promoted to the outer commit boundary on success and discarded on
failure. Do not hold the shared handle’s lock across a nested call.
Sibling nested calls (for example futures joined on one task) take turns: each opens its savepoint only after the previous sibling’s savepoint was released or rolled back. A savepoint left open, for example by a nested future cancelled while another operation held the connection, makes the enclosing level fail closed: the managed transaction then rolls back and returns an error instead of committing.
The returned future is Send when R and E are, so the call can be
nested in another transaction closure or run in a spawned task.
Source§impl Orm
impl Orm
Sourcepub async fn init(database_url: &str) -> Result<(), Error>
pub async fn init(database_url: &str) -> Result<(), Error>
Initialize the global database connection pool using an agnostic URI
Sourcepub async fn init_with_options(
database_url: &str,
max_connections: u32,
acquire_timeout_secs: u64,
) -> Result<(), Error>
pub async fn init_with_options( database_url: &str, max_connections: u32, acquire_timeout_secs: u64, ) -> Result<(), Error>
Initialize the global database connection pool with specific pool options
Sourcepub async fn init_with_replicas(
primary_url: &str,
replica_urls: Vec<&str>,
) -> Result<(), Error>
pub async fn init_with_replicas( primary_url: &str, replica_urls: Vec<&str>, ) -> Result<(), Error>
Initialize the global database connection pool and its read replicas
Sourcepub fn pool() -> Result<&'static RullstPool, Error>
pub fn pool() -> Result<&'static RullstPool, Error>
Retrieve the global database connection pool (strictly for writes).
Sourcepub fn try_pool() -> Result<&'static RullstPool, Error>
pub fn try_pool() -> Result<&'static RullstPool, Error>
Fallible variant of Orm::pool: returns Err instead of panicking
when the ORM has not been initialized yet.
Sourcepub fn read_pool() -> Result<&'static RullstPool, Error>
pub fn read_pool() -> Result<&'static RullstPool, Error>
Retrieve the connection pool for read operations. Performs a round-robin load balancing over replicas if configured.
Sourcepub fn try_read_pool() -> Result<&'static RullstPool, Error>
pub fn try_read_pool() -> Result<&'static RullstPool, Error>
Fallible variant of Orm::read_pool.
Sourcepub fn try_driver() -> Result<&'static str, Error>
pub fn try_driver() -> Result<&'static str, Error>
Fallible variant of Orm::driver.
Sourcepub fn raw(sql: impl Into<String>) -> RawQueryBuilder
pub fn raw(sql: impl Into<String>) -> RawQueryBuilder
Create a raw SQL query builder.
Sourcepub async fn seed(seeders: Vec<Box<dyn Seeder>>) -> Result<(), Error>
pub async fn seed(seeders: Vec<Box<dyn Seeder>>) -> Result<(), Error>
Run an array of seeders sequentially
Sourcepub fn enable_query_log()
pub fn enable_query_log()
Enable query logging to print all queries to the terminal
Sourcepub fn disable_query_log()
pub fn disable_query_log()
Disable query logging
Sourcepub fn set_max_query_limit(limit: usize)
pub fn set_max_query_limit(limit: usize)
Set a global maximum limit for all queries without an explicit limit override
Sourcepub fn set_query_timeout(secs: u64)
pub fn set_query_timeout(secs: u64)
Set a global maximum execution timeout for all queries
Auto Trait Implementations§
impl Freeze for Orm
impl RefUnwindSafe for Orm
impl Send for Orm
impl Sync for Orm
impl Unpin for Orm
impl UnsafeUnpin for Orm
impl UnwindSafe for Orm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more