Skip to main content

Orm

Struct Orm 

Source
pub struct Orm;
Expand description

Orm configuration structure

Implementations§

Source§

impl Orm

Source

pub async fn begin_transaction() -> Result<Transaction<'static>, Error>

Opens a transaction under a secret-free tracing span.

Source

pub async fn transaction<F, R, E>(f: F) -> Result<R, Error>
where F: FnOnce(Arc<Mutex<Option<Transaction<'static>>>>) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send>> + Send, E: Display,

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

Source

pub async fn init(database_url: &str) -> Result<(), Error>

Initialize the global database connection pool using an agnostic URI

Source

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

Source

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

Source

pub fn pool() -> Result<&'static RullstPool, Error>

Retrieve the global database connection pool (strictly for writes).

Source

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.

Source

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.

Source

pub fn try_read_pool() -> Result<&'static RullstPool, Error>

Fallible variant of Orm::read_pool.

Source

pub fn driver() -> Result<&'static str, Error>

Retrieve the active driver string.

Source

pub fn try_driver() -> Result<&'static str, Error>

Fallible variant of Orm::driver.

Source

pub fn raw(sql: impl Into<String>) -> RawQueryBuilder

Create a raw SQL query builder.

Source

pub async fn seed(seeders: Vec<Box<dyn Seeder>>) -> Result<(), Error>

Run an array of seeders sequentially

Source

pub fn enable_query_log()

Enable query logging to print all queries to the terminal

Source

pub fn disable_query_log()

Disable query logging

Source

pub fn set_max_query_limit(limit: usize)

Set a global maximum limit for all queries without an explicit limit override

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more