Struct MssqlConnectOptions

Source
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

Source

pub fn new() -> MssqlConnectOptions

Source

pub fn host(self, host: &str) -> MssqlConnectOptions

Source

pub fn port(self, port: u16) -> MssqlConnectOptions

Source

pub fn username(self, username: &str) -> MssqlConnectOptions

Source

pub fn password(self, password: &str) -> MssqlConnectOptions

Source

pub fn database(self, database: &str) -> MssqlConnectOptions

Source

pub fn instance(self, instance: &str) -> MssqlConnectOptions

Source

pub fn client_program_version( self, client_program_version: u32, ) -> MssqlConnectOptions

Source

pub fn client_pid(self, client_pid: u32) -> MssqlConnectOptions

Source

pub fn hostname(self, hostname: &str) -> MssqlConnectOptions

Source

pub fn app_name(self, app_name: &str) -> MssqlConnectOptions

Source

pub fn server_name(self, server_name: &str) -> MssqlConnectOptions

Source

pub fn client_interface_name( self, client_interface_name: &str, ) -> MssqlConnectOptions

Source

pub fn language(self, language: &str) -> MssqlConnectOptions

Source

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

Source

pub fn encrypt(self, encrypt: Encrypt) -> MssqlConnectOptions

Source

pub fn trust_server_certificate(self, trust: bool) -> MssqlConnectOptions

Source

pub fn hostname_in_certificate(self, hostname: &str) -> MssqlConnectOptions

Source

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

Source§

fn clone(&self) -> MssqlConnectOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConnectOptions for MssqlConnectOptions

Source§

type Connection = MssqlConnection

Source§

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

Log executed statements with the specified level
Source§

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

Entirely disables statement logging (both slow and regular).
Source§

impl Debug for MssqlConnectOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for MssqlConnectOptions

Source§

fn default() -> MssqlConnectOptions

Returns the “default value” for a type. Read more
Source§

impl From<MssqlConnectOptions> for AnyConnectOptions

Source§

fn from(options: MssqlConnectOptions) -> AnyConnectOptions

Converts to this type from the input type.
Source§

impl FromStr for MssqlConnectOptions

Source§

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&param2=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 or true or yes: Requires encryption but doesn’t validate the server certificate.
    • optional or false or no: Uses encryption if available, falls back to unencrypted.
    • not_supported: No encryption.
  • sslrootcert or ssl-root-cert or ssl-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 server
  • client_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§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl TryFrom<AnyConnectOptions> for MssqlConnectOptions

Source§

type Error = Error

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

fn try_from( value: AnyConnectOptions, ) -> Result<MssqlConnectOptions, <MssqlConnectOptions as TryFrom<AnyConnectOptions>>::Error>

Performs the conversion.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,