sqlx_core::connection

Trait ConnectOptions

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

    // Required methods
    fn from_url(url: &Url) -> Result<Self, Error>;
    fn connect(&self) -> BoxFuture<'_, Result<Self::Connection, Error>>
       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§

Source

type Connection: Connection<Options = Self> + ?Sized

Required Methods§

Source

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

Parse the ConnectOptions from a URL.

Source

fn connect(&self) -> BoxFuture<'_, Result<Self::Connection, Error>>
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).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§