pub struct MssqlConnectOptions { /* private fields */ }
Available on crate feature
mssql
only.Expand description
Options and flags which can be used to configure a Microsoft SQL Server connection.
Connection strings should be in the form:
mssql://[username[:password]@]host/database[?instance=instance_name&packet_size=packet_size&client_program_version=client_program_version&client_pid=client_pid&hostname=hostname&app_name=app_name&server_name=server_name&client_interface_name=client_interface_name&language=language]
Implementations§
Source§impl MssqlConnectOptions
impl MssqlConnectOptions
pub fn new() -> MssqlConnectOptions
pub fn host(self, host: &str) -> MssqlConnectOptions
pub fn port(self, port: u16) -> MssqlConnectOptions
pub fn username(self, username: &str) -> MssqlConnectOptions
pub fn password(self, password: &str) -> MssqlConnectOptions
pub fn database(self, database: &str) -> MssqlConnectOptions
pub fn instance(self, instance: &str) -> MssqlConnectOptions
pub fn client_program_version( self, client_program_version: u32, ) -> MssqlConnectOptions
pub fn client_pid(self, client_pid: u32) -> MssqlConnectOptions
pub fn hostname(self, hostname: &str) -> MssqlConnectOptions
pub fn app_name(self, app_name: &str) -> MssqlConnectOptions
pub fn server_name(self, server_name: &str) -> MssqlConnectOptions
pub fn client_interface_name( self, client_interface_name: &str, ) -> MssqlConnectOptions
pub fn language(self, language: &str) -> MssqlConnectOptions
Sourcepub fn requested_packet_size(
self,
size: u32,
) -> Result<MssqlConnectOptions, MssqlConnectOptions>
pub fn requested_packet_size( self, size: u32, ) -> Result<MssqlConnectOptions, MssqlConnectOptions>
Size in bytes of TDS packets to exchange with the server. Returns an error if the size is smaller than 512 bytes
pub fn encrypt(self, encrypt: Encrypt) -> MssqlConnectOptions
pub fn trust_server_certificate(self, trust: bool) -> MssqlConnectOptions
pub fn hostname_in_certificate(self, hostname: &str) -> MssqlConnectOptions
Sourcepub fn ssl_root_cert(self, cert: impl AsRef<Path>) -> MssqlConnectOptions
pub fn ssl_root_cert(self, cert: impl AsRef<Path>) -> MssqlConnectOptions
Sets the name of a file containing SSL certificate authority (CA) certificate(s). If the file exists, the server’s certificate will be verified to be signed by one of these authorities.
Trait Implementations§
Source§impl Clone for MssqlConnectOptions
impl Clone for MssqlConnectOptions
Source§fn clone(&self) -> MssqlConnectOptions
fn clone(&self) -> MssqlConnectOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl ConnectOptions for MssqlConnectOptions
impl ConnectOptions for MssqlConnectOptions
type Connection = MssqlConnection
Source§fn connect(
&self,
) -> Pin<Box<dyn Future<Output = Result<<MssqlConnectOptions as ConnectOptions>::Connection, Error>> + Send + '_>>
fn connect( &self, ) -> Pin<Box<dyn Future<Output = Result<<MssqlConnectOptions as ConnectOptions>::Connection, Error>> + Send + '_>>
Establish a new database connection with the options specified by
self
.Source§fn log_statements(&mut self, level: LevelFilter) -> &mut MssqlConnectOptions
fn log_statements(&mut self, level: LevelFilter) -> &mut MssqlConnectOptions
Log executed statements with the specified
level
Source§fn log_slow_statements(
&mut self,
level: LevelFilter,
duration: Duration,
) -> &mut MssqlConnectOptions
fn log_slow_statements( &mut self, level: LevelFilter, duration: Duration, ) -> &mut MssqlConnectOptions
Log executed statements with a duration above the specified
duration
at the specified level
.Source§fn disable_statement_logging(&mut self) -> &mut Self
fn disable_statement_logging(&mut self) -> &mut Self
Entirely disables statement logging (both slow and regular).
Source§impl Debug for MssqlConnectOptions
impl Debug for MssqlConnectOptions
Source§impl Default for MssqlConnectOptions
impl Default for MssqlConnectOptions
Source§fn default() -> MssqlConnectOptions
fn default() -> MssqlConnectOptions
Returns the “default value” for a type. Read more
Source§impl From<MssqlConnectOptions> for AnyConnectOptions
impl From<MssqlConnectOptions> for AnyConnectOptions
Source§fn from(options: MssqlConnectOptions) -> AnyConnectOptions
fn from(options: MssqlConnectOptions) -> AnyConnectOptions
Converts to this type from the input type.
Source§impl FromStr for MssqlConnectOptions
impl FromStr for MssqlConnectOptions
Source§fn from_str(
s: &str,
) -> Result<MssqlConnectOptions, <MssqlConnectOptions as FromStr>::Err>
fn from_str( s: &str, ) -> Result<MssqlConnectOptions, <MssqlConnectOptions as FromStr>::Err>
Parse a connection string into a set of connection options.
The connection string should be a valid URL with the following format:
mssql://[username[:password]@]host[:port][/database][?param1=value1¶m2=value2...]
Components:
username
: The username for SQL Server authentication.password
: The password for SQL Server authentication.host
: The hostname or IP address of the SQL Server.port
: The port number (default is 1433).database
: The name of the database to connect to.
Supported query parameters:
instance
: SQL Server named instance.encrypt
: Controls connection encryption:strict
: Requires encryption and validates the server certificate.mandatory
ortrue
oryes
: Requires encryption but doesn’t validate the server certificate.optional
orfalse
orno
: Uses encryption if available, falls back to unencrypted.not_supported
: No encryption.
sslrootcert
orssl-root-cert
orssl-ca
: Path to the root certificate for validating the server’s SSL certificate.trust_server_certificate
: When true, skips validation of the server’s SSL certificate. Use with caution as it makes the connection vulnerable to man-in-the-middle attacks.hostname_in_certificate
: The hostname expected in the server’s SSL certificate. Use this when the server’s hostname doesn’t match the certificate.packet_size
: Size of TDS packets in bytes. Larger sizes can improve performance but consume more memory on the serverclient_program_version
: Version number of the client program, sent to the server for logging purposes.client_pid
: Process ID of the client, sent to the server for logging purposes.hostname
: Name of the client machine, sent to the server for logging purposes.app_name
: Name of the client application, sent to the server for logging purposes.server_name
: Name of the server to connect to. Useful when connecting through a proxy or load balancer.client_interface_name
: Name of the client interface, sent to the server for logging purposes.language
: Sets the language for server messages. Affects date formats and system messages.
Example:
mssql://user:pass@localhost:1433/mydb?encrypt=strict&app_name=MyApp&packet_size=4096
Source§impl TryFrom<AnyConnectOptions> for MssqlConnectOptions
impl TryFrom<AnyConnectOptions> for MssqlConnectOptions
Source§fn try_from(
value: AnyConnectOptions,
) -> Result<MssqlConnectOptions, <MssqlConnectOptions as TryFrom<AnyConnectOptions>>::Error>
fn try_from( value: AnyConnectOptions, ) -> Result<MssqlConnectOptions, <MssqlConnectOptions as TryFrom<AnyConnectOptions>>::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for MssqlConnectOptions
impl RefUnwindSafe for MssqlConnectOptions
impl Send for MssqlConnectOptions
impl Sync for MssqlConnectOptions
impl Unpin for MssqlConnectOptions
impl UnwindSafe for MssqlConnectOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 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> ⓘ
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