pub struct SqlServerConnection { /* private fields */ }Expand description
SQL Server connection
Implementations§
Source§impl SqlServerConnection
impl SqlServerConnection
Sourcepub fn is_expired(&self, max_lifetime: Duration) -> bool
pub fn is_expired(&self, max_lifetime: Duration) -> bool
Check if connection is older than the specified max lifetime
Sourcepub async fn connect(config: &ConnectionConfig) -> Result<Self>
pub async fn connect(config: &ConnectionConfig) -> Result<Self>
Create a new SQL Server connection from config
Trait Implementations§
Source§impl Connection for SqlServerConnection
impl Connection for SqlServerConnection
Source§fn begin_with_isolation<'life0, 'async_trait>(
&'life0 self,
isolation: IsolationLevel,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin_with_isolation<'life0, 'async_trait>(
&'life0 self,
isolation: IsolationLevel,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
SQL Server requires SET TRANSACTION ISOLATION LEVEL before BEGIN TRANSACTION for it to take effect for that transaction.
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query that modifies data, returns affected row count
Source§fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query that returns rows
Source§fn prepare<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn PreparedStatement>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn prepare<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn PreparedStatement>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Prepare a statement for repeated execution
Source§fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn begin<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Begin a transaction
Source§fn query_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn RowStream>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query_stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn RowStream>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query and stream results
Source§fn is_valid<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_valid<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if connection is valid/alive
Source§fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close the connection
Source§fn execute_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
statements: &'life1 [(&'life2 str, &'life3 [Value])],
) -> Pin<Box<dyn Future<Output = Result<Vec<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn execute_batch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
statements: &'life1 [(&'life2 str, &'life3 [Value])],
) -> Pin<Box<dyn Future<Output = Result<Vec<u64>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Execute a batch of statements, returns affected counts per statement
Source§fn query_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn query_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
sql: &'life1 str,
params: &'life2 [Value],
) -> Pin<Box<dyn Future<Output = Result<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute a query and return the first row (convenience method)
Source§impl ConnectionLifecycle for SqlServerConnection
impl ConnectionLifecycle for SqlServerConnection
Source§fn created_at(&self) -> Instant
fn created_at(&self) -> Instant
Get the instant when this connection was created
Source§fn idle_time<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Duration> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn idle_time<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Duration> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get duration since this connection was last used
Source§fn touch<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn touch<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update the last-used timestamp (called when connection is actively used)
Source§fn is_expired(&self, max_lifetime: Duration) -> bool
fn is_expired(&self, max_lifetime: Duration) -> bool
Check if connection has exceeded the given maximum lifetime
Auto Trait Implementations§
impl !Freeze for SqlServerConnection
impl !RefUnwindSafe for SqlServerConnection
impl Send for SqlServerConnection
impl Sync for SqlServerConnection
impl Unpin for SqlServerConnection
impl UnsafeUnpin for SqlServerConnection
impl !UnwindSafe for SqlServerConnection
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
Mutably borrows from an owned value. Read more