Trait sqlx::ConnectOptions

source ·
pub trait ConnectOptions: 'static + Send + Sync + FromStr<Err = Error> + Debug + Clone {
    type Connection: Connection + ?Sized;

    // Required methods
    fn from_url(url: &Url) -> Result<Self, Error>;
    fn connect(
        &self
    ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Error>> + Send + '_>>
       where Self::Connection: Sized;
    fn log_statements(self, level: LevelFilter) -> Self;
    fn log_slow_statements(self, level: LevelFilter, duration: Duration) -> Self;

    // Provided methods
    fn to_url_lossy(&self) -> Url { ... }
    fn disable_statement_logging(self) -> Self { ... }
}

Required Associated Types§

Required Methods§

source

fn from_url(url: &Url) -> Result<Self, Error>

Parse the ConnectOptions from a URL.

source

fn connect( &self ) -> Pin<Box<dyn Future<Output = Result<Self::Connection, Error>> + Send + '_>>
where Self::Connection: Sized,

Establish a new database connection with the options specified by self.

source

fn log_statements(self, level: LevelFilter) -> Self

Log executed statements with the specified level

source

fn log_slow_statements(self, level: LevelFilter, duration: Duration) -> Self

Log executed statements with a duration above the specified duration at the specified level.

Provided Methods§

source

fn to_url_lossy(&self) -> Url

Get a connection URL that may be used to connect to the same database as this ConnectOptions.

§Note: Lossy

Any flags or settings which do not have a representation in the URL format will be lost. They will fall back to their default settings when the URL is parsed.

The only settings guaranteed to be preserved are:

  • Username
  • Password
  • Hostname
  • Port
  • Database name
  • Unix socket or SQLite database file path
  • SSL mode (if applicable)
  • SSL CA certificate path
  • SSL client certificate path
  • SSL client key path

Additional settings are driver-specific. Refer to the source of a given implementation to see which options are preserved in the URL.

§Panics

This defaults to unimplemented!().

Individual drivers should override this to implement the intended behavior.

source

fn disable_statement_logging(self) -> Self

Entirely disables statement logging (both slow and regular).

Object Safety§

This trait is not object safe.

Implementors§