doc: make it clear that ConnectOptions types impl FromStr (#2574)

This commit is contained in:
Austin Bonander
2023-06-30 16:49:24 -07:00
committed by GitHub
parent 3fbc3a3ff2
commit e2ce463af8
3 changed files with 43 additions and 27 deletions

View File

@@ -25,6 +25,9 @@ use sqlx_core::IndexMap;
/// A value of `SqliteConnectOptions` can be parsed from a connection URL,
/// as described by [SQLite](https://www.sqlite.org/uri.html).
///
/// This type also implements [`FromStr`][std::str::FromStr] so you can parse it from a string
/// containing a connection URL and then further adjust options if necessary (see example below).
///
/// | URL | Description |
/// | -- | -- |
/// `sqlite::memory:` | Open an in-memory database. |
@@ -36,20 +39,17 @@ use sqlx_core::IndexMap;
/// # Example
///
/// ```rust,no_run
/// # use sqlx_core::connection::ConnectOptions;
/// # use sqlx_core::error::Error;
/// # use sqlx_sqlite::{SqliteConnectOptions, SqliteJournalMode};
/// # async fn example() -> sqlx::Result<()> {
/// use sqlx::ConnectOptions;
/// use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode};
/// use std::str::FromStr;
///
/// # fn main() {
/// # #[cfg(feature = "_rt-async-std")]
/// # sqlx::__rt::test_block_on(async move {
/// let conn = SqliteConnectOptions::from_str("sqlite://data.db")?
/// .journal_mode(SqliteJournalMode::Wal)
/// .read_only(true)
/// .connect().await?;
/// # Result::<(), Error>::Ok(())
/// # }).unwrap();
/// #
/// # Ok(())
/// # }
/// ```
#[derive(Clone, Debug)]