Skip to content

Commit 2615441

Browse files
committed
Doc cleanup and "real" extensible enums
1 parent 869f2d7 commit 2615441

File tree

8 files changed

+19
-29
lines changed

8 files changed

+19
-29
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ version: 2
2222
jobs:
2323
build:
2424
docker:
25-
- image: rust:1.39.0
25+
- image: rust:1.40.0
2626
environment:
2727
RUSTFLAGS: -D warnings
2828
- image: sfackler/rust-postgres-test:6

postgres-protocol/src/message/backend.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl Header {
7272
}
7373

7474
/// An enum representing Postgres backend messages.
75+
#[non_exhaustive]
7576
pub enum Message {
7677
AuthenticationCleartextPassword,
7778
AuthenticationGss,
@@ -104,8 +105,6 @@ pub enum Message {
104105
PortalSuspended,
105106
ReadyForQuery(ReadyForQueryBody),
106107
RowDescription(RowDescriptionBody),
107-
#[doc(hidden)]
108-
__ForExtensibility,
109108
}
110109

111110
impl Message {

postgres-types/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl Type {
263263

264264
/// Represents the kind of a Postgres type.
265265
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
266+
#[non_exhaustive]
266267
pub enum Kind {
267268
/// A simple type like `VARCHAR` or `INTEGER`.
268269
Simple,
@@ -278,8 +279,6 @@ pub enum Kind {
278279
Domain(Type),
279280
/// A composite type along with information about its fields.
280281
Composite(Vec<Field>),
281-
#[doc(hidden)]
282-
__ForExtensibility,
283282
}
284283

285284
/// Information about a field of a composite type.

tokio-postgres/src/config.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,36 @@ use tokio::io::{AsyncRead, AsyncWrite};
2424

2525
/// Properties required of a session.
2626
#[derive(Debug, Copy, Clone, PartialEq)]
27+
#[non_exhaustive]
2728
pub enum TargetSessionAttrs {
2829
/// No special properties are required.
2930
Any,
3031
/// The session must allow writes.
3132
ReadWrite,
32-
#[doc(hidden)]
33-
__NonExhaustive,
3433
}
3534

3635
/// TLS configuration.
3736
#[derive(Debug, Copy, Clone, PartialEq)]
37+
#[non_exhaustive]
3838
pub enum SslMode {
3939
/// Do not use TLS.
4040
Disable,
4141
/// Attempt to connect with TLS but allow sessions without.
4242
Prefer,
4343
/// Require the use of TLS.
4444
Require,
45-
#[doc(hidden)]
46-
__NonExhaustive,
4745
}
4846

4947
/// Channel binding configuration.
5048
#[derive(Debug, Copy, Clone, PartialEq)]
49+
#[non_exhaustive]
5150
pub enum ChannelBinding {
5251
/// Do not use channel binding.
5352
Disable,
5453
/// Attempt to use channel binding but allow sessions without.
5554
Prefer,
5655
/// Require the use of channel binding.
5756
Require,
58-
#[doc(hidden)]
59-
__NonExhaustive,
6057
}
6158

6259
#[derive(Debug, Clone, PartialEq)]
@@ -121,7 +118,7 @@ pub(crate) enum Host {
121118
/// # Url
122119
///
123120
/// This format resembles a URL with a scheme of either `postgres://` or `postgresql://`. All components are optional,
124-
/// and the format accept query parameters for all of the key-value pairs described in the section above. Multiple
121+
/// and the format accepts query parameters for all of the key-value pairs described in the section above. Multiple
125122
/// host/port pairs can be comma-separated. Unix socket paths in the host section of the URL should be percent-encoded,
126123
/// as the path component of the URL specifies the database name.
127124
///
@@ -425,7 +422,7 @@ impl Config {
425422

426423
/// Connects to a PostgreSQL database over an arbitrary stream.
427424
///
428-
/// All of the settings other than `user`, `password`, `dbname`, `options`, and `application` name are ignored.
425+
/// All of the settings other than `user`, `password`, `dbname`, `options`, and `application_name` name are ignored.
429426
pub async fn connect_raw<S, T>(
430427
&self,
431428
stream: S,

tokio-postgres/src/connect_raw.rs

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ fn can_skip_channel_binding(config: &Config) -> Result<(), Error> {
197197
config::ChannelBinding::Require => Err(Error::authentication(
198198
"server did not use channel binding".into(),
199199
)),
200-
config::ChannelBinding::__NonExhaustive => unreachable!(),
201200
}
202201
}
203202

tokio-postgres/src/connect_tls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ where
2222
return Ok(MaybeTlsStream::Raw(stream))
2323
}
2424
SslMode::Prefer | SslMode::Require => {}
25-
SslMode::__NonExhaustive => unreachable!(),
2625
}
2726

2827
let mut buf = BytesMut::new();

tokio-postgres/src/lib.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@
2121
//! }
2222
//! });
2323
//!
24-
//! // Now we can prepare a simple statement that just returns its parameter.
25-
//! let stmt = client.prepare("SELECT $1::TEXT").await?;
26-
//!
27-
//! // And then execute it, returning a list of the resulting rows.
24+
//! // Now we can execute a simple statement that just returns its parameter.
2825
//! let rows = client
29-
//! .query(&stmt, &[&"hello world"])
26+
//! .query("SELECT $1::TEXT", &[&"hello world"])
3027
//! .await?;
3128
//!
32-
//! // Now we can check that we got back the same string we sent over.
29+
//! // And then check that we got back the same string we sent over.
3330
//! let value: &str = rows[0].get(0);
3431
//! assert_eq!(value, "hello world");
3532
//!
@@ -201,6 +198,7 @@ impl Notification {
201198

202199
/// An asynchronous message from the server.
203200
#[allow(clippy::large_enum_variant)]
201+
#[non_exhaustive]
204202
pub enum AsyncMessage {
205203
/// A notice.
206204
///
@@ -210,20 +208,17 @@ pub enum AsyncMessage {
210208
///
211209
/// Connections can subscribe to notifications with the `LISTEN` command.
212210
Notification(Notification),
213-
#[doc(hidden)]
214-
__NonExhaustive,
215211
}
216212

217213
/// Message returned by the `SimpleQuery` stream.
214+
#[non_exhaustive]
218215
pub enum SimpleQueryMessage {
219216
/// A row of data.
220217
Row(SimpleQueryRow),
221218
/// A statement in the query has completed.
222219
///
223220
/// The number of rows modified or selected is returned.
224221
CommandComplete(u64),
225-
#[doc(hidden)]
226-
__NonExhaustive,
227222
}
228223

229224
fn slice_iter<'a>(

tokio-postgres/src/transaction.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ impl<'a> Transaction<'a> {
184184
where
185185
T: ?Sized + ToStatement,
186186
{
187-
self.bind_iter(statement, slice_iter(params)).await
187+
self.bind_raw(statement, slice_iter(params)).await
188188
}
189189

190-
/// Like [`bind`], but takes an iterator of parameters rather than a slice.
190+
/// A maximally flexible version of [`bind`].
191191
///
192192
/// [`bind`]: #method.bind
193-
pub async fn bind_iter<'b, T, I>(&self, statement: &T, params: I) -> Result<Portal, Error>
193+
pub async fn bind_raw<'b, T, I>(&self, statement: &T, params: I) -> Result<Portal, Error>
194194
where
195195
T: ?Sized + ToStatement,
196196
I: IntoIterator<Item = &'b dyn ToSql>,
@@ -211,7 +211,9 @@ impl<'a> Transaction<'a> {
211211
.await
212212
}
213213

214-
/// The maximally flexible version of `query_portal`.
214+
/// The maximally flexible version of [`query_portal`].
215+
///
216+
/// [`query_portal`]: #method.query_portal
215217
pub async fn query_portal_raw(
216218
&self,
217219
portal: &Portal,

0 commit comments

Comments
 (0)