fix warnings from rustdoc

This commit is contained in:
Ryan Leckey 2020-03-24 01:35:15 -07:00
parent 792acdd554
commit 1940b685d3
18 changed files with 62 additions and 25 deletions

View file

@ -4,7 +4,9 @@ use std::fmt::{self, Debug};
use crate::database::Database;
/// The return type of [Executor::describe].
/// The return type of [`Executor::describe`].
///
/// [`Executor::describe`]: crate::executor::Executor::describe
#[non_exhaustive]
pub struct Describe<DB>
where

View file

@ -21,10 +21,14 @@ pub enum Error<DB: Database> {
/// An error was returned by the database.
Database(Box<DB::Error>),
/// No row was returned during [`Map::fetch_one`] or [`QueryAs::fetch_one`].
/// No row was returned during [`query::Map::fetch_one`] or `QueryAs::fetch_one`.
///
/// [`query::Map::fetch_one`]: crate::query::Map::fetch_one
RowNotFound,
/// Column was not found by name in a Row (during [`Row::get`]).
///
/// [`Row::get`]: crate::row::Row::get
ColumnNotFound(Box<str>),
/// Column index was out of bounds (e.g., asking for column 4 in a 2-column row).
@ -38,11 +42,16 @@ pub enum Error<DB: Database> {
/// Context is provided by the included error message.
Protocol(Box<str>),
/// A [Pool::acquire] timed out due to connections not becoming available or
/// A [`Pool::acquire`] timed out due to connections not becoming available or
/// because another task encountered too many errors while trying to open a new connection.
///
/// [`Pool::acquire`]: crate::pool::Pool::acquire
PoolTimedOut(Option<Box<dyn StdError + Send + Sync>>),
/// [Pool::close] was called while we were waiting in [Pool::acquire].
/// [`Pool::close`] was called while we were waiting in [`Pool::acquire`].
///
/// [`Pool::acquire`]: crate::pool::Pool::acquire
/// [`Pool::close`]: crate::pool::Pool::close
PoolClosed,
/// An error occurred while attempting to setup TLS.

View file

@ -35,6 +35,9 @@ where
///
/// Returns a [`Cursor`] that can be used to iterate through the [`Row`]s
/// of the result.
///
/// [`Cursor`]: crate::cursor::Cursor
/// [`Row`]: crate::row::Row
fn fetch<'e, 'q, E>(&'e mut self, query: E) -> <Self::Database as HasCursor<'e, 'q>>::Cursor
where
E: Execute<'q, Self::Database>;
@ -42,8 +45,9 @@ where
/// Prepare the SQL query and return type information about its parameters
/// and results.
///
/// This is used by the query macros ( [`query!`] ) during compilation to
/// This is used by the query macros during compilation to
/// power their type inference.
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,
@ -109,6 +113,7 @@ where
(**self).fetch(query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -31,7 +31,10 @@ mod url;
#[macro_use]
pub mod arguments;
pub mod decode;
#[doc(hidden)]
pub mod describe;
pub mod encode;
pub mod pool;
pub mod query;

View file

@ -21,9 +21,9 @@ pub(super) const MAX_PACKET_SIZE: u32 = 1024;
pub(super) const COLLATE_UTF8MB4_UNICODE_CI: u8 = 224;
/// An asynchronous connection to a [MySql] database.
/// An asynchronous connection to a [`MySql`] database.
///
/// The connection string expected by [Connection::open] should be a MySQL connection
/// The connection string expected by `MySqlConnection` should be a MySQL connection
/// string, as documented at
/// <https://dev.mysql.com/doc/refman/8.0/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri>
///

View file

@ -197,6 +197,7 @@ impl Executor for super::MySqlConnection {
MySqlCursor::from_connection(self, query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -23,7 +23,7 @@ mod tls;
mod types;
mod util;
/// An alias for [`Pool`], specialized for **MySQL**.
/// An alias for [`crate::pool::Pool`], specialized for **MySQL**.
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
pub type MySqlPool = crate::pool::Pool<MySqlConnection>;

View file

@ -7,7 +7,7 @@ use std::time::Instant;
use super::inner::{DecrementSizeGuard, SharedPool};
use crate::connection::{Connect, Connection};
/// A connection checked out from [`Pool`][crate::Pool].
/// A connection checked out from [`Pool`][crate::pool::Pool].
///
/// Will be returned to the pool on-drop.
pub struct PoolConnection<C>
@ -92,7 +92,7 @@ where
}
}
/// Returns the connection to the [`Pool`][crate::Pool] it was checked-out from.
/// Returns the connection to the [`Pool`][crate::pool::Pool] it was checked-out from.
impl<C> Drop for PoolConnection<C>
where
C: Connect,

View file

@ -34,6 +34,7 @@ where
DB::Cursor::from_pool(self, query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,
@ -85,6 +86,7 @@ where
(**self).fetch(query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -47,7 +47,7 @@ where
/// Set the amount of time to attempt connecting to the database.
///
/// If this timeout elapses, [Pool::acquire] will return an error.
/// If this timeout elapses, [`Pool::acquire`] will return an error.
pub fn connect_timeout(mut self, connect_timeout: Duration) -> Self {
self.options.connect_timeout = connect_timeout;
self
@ -57,8 +57,11 @@ where
///
/// When the pool is built, this many connections will be automatically spun up.
///
/// If any connection is reaped by [max_lifetime] or [idle_timeout] and it brings
/// If any connection is reaped by [`max_lifetime`] or [`idle_timeout`] and it brings
/// the connection count below this amount, a new connection will be opened to replace it.
///
/// [`max_lifetime`]: #method.max_lifetime
/// [`idle_timeout`]: #method.idle_timeout
pub fn min_size(mut self, min_size: u32) -> Self {
self.options.min_size = min_size;
self
@ -68,7 +71,7 @@ where
///
/// Any connection with a lifetime greater than this will be closed.
///
/// When set to `None`, all connections live until either reaped by [idle_timeout]
/// When set to `None`, all connections live until either reaped by [`idle_timeout`]
/// or explicitly disconnected.
///
/// Infinite connections are not recommended due to the unfortunate reality of memory/resource
@ -76,6 +79,8 @@ where
/// (even if only once daily) to allow the database the opportunity to clean up data structures
/// (parse trees, query metadata caches, thread-local storage, etc.) that are associated with a
/// session.
///
/// [`idle_timeout`]: #method.idle_timeout
pub fn max_lifetime(mut self, max_lifetime: impl Into<Option<Duration>>) -> Self {
self.options.max_lifetime = max_lifetime.into();
self
@ -91,10 +96,12 @@ where
self
}
/// If true, the health of a connection will be verified by a call to `Connection::ping`
/// If true, the health of a connection will be verified by a call to [`Connection::ping`]
/// before returning the connection.
///
/// Defaults to `true`.
///
/// [`Connection::ping`]: crate::connection::Connection::ping
pub fn test_on_acquire(mut self, test: bool) -> Self {
self.options.test_on_acquire = test;
self
@ -102,8 +109,10 @@ where
/// Spin up the connection pool.
///
/// If [min_size] was set to a non-zero value, that many connections will be immediately
/// If [`min_size`] was set to a non-zero value, that many connections will be immediately
/// opened and placed into the pool.
///
/// [`min_size`]: #method.min_size
pub async fn build(self, url: &str) -> crate::Result<C::Database, Pool<C>>
where
C: Connect,

View file

@ -395,6 +395,7 @@ impl Executor for super::PgConnection {
PgCursor::from_connection(self, query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -208,6 +208,7 @@ impl Executor for PgListener {
self.connection().fetch(query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -23,7 +23,7 @@ mod stream;
mod tls;
pub mod types;
/// An alias for [`Pool`][crate::Pool], specialized for **Postgres**.
/// An alias for [`Pool`][crate::pool::Pool], specialized for **Postgres**.
#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))]
pub type PgPool = crate::pool::Pool<PgConnection>;

View file

@ -55,9 +55,9 @@ mod private_column_index {
///
/// This trait is sealed and cannot be implemented for types outside of SQLx.
///
/// [`FromRow`]: trait.FromRow.html
/// [`Cursor`]: ../trait.Cursor.html
/// [`Query::fetch`]: ../struct.Query.html#method.fetch
/// [`FromRow`]: crate::row::FromRow
/// [`Cursor`]: crate::cursor::Cursor
/// [`Query::fetch`]: crate::query::Query::fetch
pub trait Row<'c>
where
Self: private_row::Sealed + Unpin + Send,
@ -122,9 +122,9 @@ where
/// * [`ColumnIndexOutOfBounds`] if the `usize` index was greater than the number of columns in the row.
/// * [`Decode`] if the value could not be decoded into the requested type.
///
/// [`Decode`]: ../enum.Error.html#variant.Decode
/// [`ColumnNotFound`]: ../enum.Error.html#variant.ColumnNotFound
/// [`ColumnIndexOutOfBounds`]: ../enum.Error.html#variant.ColumnIndexOutOfBounds
/// [`Decode`]: crate::Error::Decode
/// [`ColumnNotFound`]: crate::Error::ColumnNotFound
/// [`ColumnIndexOutOfBounds`]: crate::Error::ColumnIndexOutOfBounds
#[inline]
fn try_get<T, I>(&self, index: I) -> crate::Result<Self::Database, T>
where
@ -167,7 +167,7 @@ pub(crate) mod private_row {
/// ```
///
/// [`query_as`]: crate::query_as
/// [`Row::try_get`]: crate::Row::try_get
/// [`Row::try_get`]: crate::row::Row::try_get
pub trait FromRow<'c, R>
where
Self: Sized,

View file

@ -123,6 +123,7 @@ impl Executor for SqliteConnection {
SqliteCursor::from_connection(self, query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -21,7 +21,7 @@ pub use row::SqliteRow;
pub use types::SqliteTypeInfo;
pub use value::SqliteValue;
/// An alias for [`Pool`][crate::Pool], specialized for **Sqlite**.
/// An alias for [`Pool`][crate::pool::Pool], specialized for **Sqlite**.
#[cfg_attr(docsrs, doc(cfg(feature = "sqlite")))]
pub type SqlitePool = crate::pool::Pool<SqliteConnection>;

View file

@ -160,6 +160,7 @@ where
(**self).fetch(query)
}
#[doc(hidden)]
fn describe<'e, 'q, E: 'e>(
&'e mut self,
query: E,

View file

@ -4,7 +4,6 @@ pub use sqlx_core::arguments;
pub use sqlx_core::connection::{Connect, Connection};
pub use sqlx_core::cursor::Cursor;
pub use sqlx_core::database::{self, Database};
pub use sqlx_core::describe;
pub use sqlx_core::executor::{self, Execute, Executor};
pub use sqlx_core::pool::{self, Pool};
pub use sqlx_core::query::{self, query, Query};
@ -12,6 +11,9 @@ pub use sqlx_core::query_as::{query_as, QueryAs};
pub use sqlx_core::row::{self, FromRow, Row};
pub use sqlx_core::transaction::Transaction;
#[doc(hidden)]
pub use sqlx_core::describe;
#[doc(inline)]
pub use sqlx_core::types::{self, Type};