pub struct SharedConnection { /* private fields */ }Expand description
Shared database access handle used by contexts, DbSets, raw SQL, and
transactions.
A SharedConnection can wrap either one direct SQL Server connection or,
behind the pool-bb8 feature, a pool. Runtime values such as audit values,
soft-delete values, and the active tenant are stored alongside the physical
connection handle and are preserved when derived contexts clone the handle.
Implementations§
Sourcepub fn from_connection(
connection: MssqlConnection<TokioConnectionStream>,
) -> Self
pub fn from_connection( connection: MssqlConnection<TokioConnectionStream>, ) -> Self
Creates a shared handle from an already-open direct SQL Server connection.
Sourcepub fn with_audit_provider(&self, provider: Arc<dyn AuditProvider>) -> Self
pub fn with_audit_provider(&self, provider: Arc<dyn AuditProvider>) -> Self
Returns a clone of this handle with an audit provider configured.
The provider is consulted by insert/update paths for entities declaring
#[orm(audit = Audit)] after explicit mutation values and request
values have had priority.
Sourcepub fn with_audit_request_values(
&self,
request_values: AuditRequestValues,
) -> Self
pub fn with_audit_request_values( &self, request_values: AuditRequestValues, ) -> Self
Returns a clone of this handle with low-level audit request values.
Prefer with_audit_values(...) when using a struct derived with
#[derive(AuditFields)].
Sourcepub fn with_audit_values<V: AuditValues>(&self, values: V) -> Self
pub fn with_audit_values<V: AuditValues>(&self, values: V) -> Self
Returns a clone of this handle with typed audit request values.
The same struct used for #[derive(AuditFields)] can be passed here as
runtime values. Values are converted to AuditRequestValues and keep
the existing precedence rules.
Sourcepub fn clear_audit_request_values(&self) -> Self
pub fn clear_audit_request_values(&self) -> Self
Returns a clone of this handle with audit request values cleared.
Sourcepub fn with_soft_delete_provider(
&self,
provider: Arc<dyn SoftDeleteProvider>,
) -> Self
pub fn with_soft_delete_provider( &self, provider: Arc<dyn SoftDeleteProvider>, ) -> Self
Returns a clone of this handle with a soft-delete provider configured.
The provider is used by delete paths for entities declaring
#[orm(soft_delete = SoftDelete)].
Sourcepub fn with_soft_delete_request_values(
&self,
request_values: SoftDeleteRequestValues,
) -> Self
pub fn with_soft_delete_request_values( &self, request_values: SoftDeleteRequestValues, ) -> Self
Returns a clone of this handle with low-level soft-delete request values.
Prefer with_soft_delete_values(...) when using a struct derived with
#[derive(SoftDeleteFields)].
Sourcepub fn with_soft_delete_values<V: SoftDeleteValues>(&self, values: V) -> Self
pub fn with_soft_delete_values<V: SoftDeleteValues>(&self, values: V) -> Self
Returns a clone of this handle with typed soft-delete request values.
The same struct used for #[derive(SoftDeleteFields)] can be passed
here as runtime delete values.
Sourcepub fn clear_soft_delete_request_values(&self) -> Self
pub fn clear_soft_delete_request_values(&self) -> Self
Returns a clone of this handle with soft-delete request values cleared.
Sourcepub fn with_tenant<T: TenantContext>(&self, tenant: T) -> Self
pub fn with_tenant<T: TenantContext>(&self, tenant: T) -> Self
Returns a clone of this handle with an active tenant configured.
Tenant-scoped reads and writes fail closed if this tenant is absent, has a different column name, or has a value incompatible with the tenant column.
Sourcepub fn clear_tenant(&self) -> Self
pub fn clear_tenant(&self) -> Self
Returns a clone of this handle without an active tenant.
Trait Implementations§
Source§fn clone(&self) -> SharedConnection
fn clone(&self) -> SharedConnection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more