Skip to content

Commit cfd8248

Browse files
committed
Bump lru, tokio-util. Update docs
1 parent ecd5c7e commit cfd8248

File tree

12 files changed

+33
-17
lines changed

12 files changed

+33
-17
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ futures-core = "0.3"
1818
futures-util = "0.3"
1919
futures-sink = "0.3"
2020
lazy_static = "1"
21-
lru = "0.4.3"
21+
lru = "0.5.3"
2222
mio-named-pipes = "0.1.6"
2323
mysql_common = "0.22.0"
2424
native-tls = "0.2"
@@ -28,7 +28,7 @@ serde = "1"
2828
serde_json = "1"
2929
thiserror = "1.0.4"
3030
tokio = { version = "0.2.17", features = ["io-util", "net", "sync", "fs", "rt-core", "time", "stream", "macros"] }
31-
tokio-util = { version = "0.2", features = ["codec"] }
31+
tokio-util = { version = "0.3.1", features = ["codec"] }
3232
tokio-tls = "0.3"
3333
twox-hash = "1"
3434
url = "2.1"

src/conn/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,13 @@ impl Conn {
287287
Ok(())
288288
}
289289

290+
/// Closes the connection.
290291
async fn close_conn(mut self) -> Result<()> {
291292
self = self.cleanup().await?;
292293
self.disconnect().await
293294
}
294295

296+
/// Returns true if io stream is encrypted.
295297
fn is_secure(&self) -> bool {
296298
if let Some(ref stream) = self.inner.stream {
297299
stream.is_secure()

src/conn/pool/futures/disconnect_pool.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::sync::{atomic, Arc};
2121

2222
/// Future that disconnects this pool from a server and resolves to `()`.
2323
///
24-
///
2524
/// **Note:** This Future won't resolve until all active connections, taken from it,
2625
/// are dropped or disonnected. Also all pending and new `GetConn`'s will resolve to error.
2726
#[derive(Debug)]

src/conn/pool/futures/get_conn.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::{
1919
BoxFuture,
2020
};
2121

22+
/// States of the GetConn future.
2223
#[derive(Debug)]
2324
pub(crate) enum GetConnInner {
2425
New,

src/conn/pool/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ impl Exchange {
8686
}
8787
}
8888

89+
/// Connection pool data.
8990
#[derive(Debug)]
9091
pub struct Inner {
9192
close: atomic::AtomicBool,
@@ -133,18 +134,18 @@ impl Pool {
133134
Ok(Pool::new(opts))
134135
}
135136

136-
/// Returns a future that resolves to [`Conn`].
137+
/// Async function that resolves to `Conn`.
137138
pub fn get_conn(&self) -> GetConn {
138139
GetConn::new(self)
139140
}
140141

141-
/// Returns a future that starts a new transaction.
142+
/// Starts a new transaction.
142143
pub async fn start_transaction(&self, options: TxOpts) -> Result<Transaction<'static>> {
143144
let conn = self.get_conn().await?;
144145
Transaction::new(conn, options).await
145146
}
146147

147-
/// Returns a future that disconnects this pool from the server and resolves to `()`.
148+
/// Async function that disconnects this pool from the server and resolves to `()`.
148149
///
149150
/// **Note:** This Future won't resolve until all active connections, taken from it,
150151
/// are dropped or disonnected. Also all pending and new `GetConn`'s will resolve to error.

src/connection_like/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ use crate::{BoxFuture, Pool};
1111
/// Connection.
1212
#[derive(Debug)]
1313
pub enum Connection<'a, 't: 'a> {
14+
/// Just a connection.
1415
Conn(crate::Conn),
16+
/// Mutable reference to a connection.
1517
ConnMut(&'a mut crate::Conn),
18+
/// Connection wrapped in a transaction.
1619
Tx(&'a mut crate::Transaction<'t>),
1720
}
1821

@@ -56,8 +59,11 @@ impl std::ops::DerefMut for Connection<'_, '_> {
5659
}
5760
}
5861

62+
/// Result of `ToConnection::to_connection` call.
5963
pub enum ToConnectionResult<'a, 't: 'a> {
64+
/// Connection is immediately available.
6065
Immediate(Connection<'a, 't>),
66+
/// We need some time to get a connection and the operation itself may fail.
6167
Mediate(BoxFuture<'a, Connection<'a, 't>>),
6268
}
6369

src/io/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ impl Decoder for PacketCodec {
6767
}
6868
}
6969

70-
impl Encoder for PacketCodec {
71-
type Item = Vec<u8>;
70+
impl Encoder<Vec<u8>> for PacketCodec {
7271
type Error = IoError;
7372

74-
fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> std::result::Result<(), IoError> {
73+
fn encode(&mut self, item: Vec<u8>, dst: &mut BytesMut) -> std::result::Result<(), IoError> {
7574
Ok(self.0.encode(item, dst)?)
7675
}
7776
}

src/io/write_packet.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use std::{
1717

1818
use crate::{connection_like::Connection, error::IoError};
1919

20+
/// Writes a packet.
21+
#[derive(Debug)]
22+
#[must_use = "futures do nothing unless you `.await` or poll them"]
2023
pub struct WritePacket<'a, 't> {
2124
conn: Connection<'a, 't>,
2225
data: Option<Vec<u8>>,

src/queryable/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ impl Conn {
102102
}
103103

104104
/// Methods of this trait are used to execute database queries.
105+
///
106+
/// `Conn` is a `Queryable` as well as `Transaction`.
105107
pub trait Queryable: Send {
106108
/// Executes `COM_PING`.
107109
fn ping(&mut self) -> BoxFuture<'_, ()>;
108110

109-
/// Performs the given query.
111+
/// Performs the given query and returns the result.
110112
fn query_iter<'a, Q>(
111113
&'a mut self,
112114
query: Q,
@@ -129,7 +131,7 @@ pub trait Queryable: Send {
129131
/// Usually there is no need to explicitly close statements (see. [`stmt_cache_size`]).
130132
fn close(&mut self, stmt: Statement) -> BoxFuture<'_, ()>;
131133

132-
/// Executes the given statement with the given params.
134+
/// Executes the given statement with given params.
133135
///
134136
/// It'll prepare `stmt`, if necessary.
135137
fn exec_iter<'a: 's, 's, Q, P>(
@@ -174,9 +176,9 @@ pub trait Queryable: Send {
174176
where
175177
Q: AsRef<str> + Send + Sync + 'a;
176178

177-
/// Exectues the given statement with each item in the given params iterator.
179+
/// Exectues the given statement for each item in the given params iterator.
178180
///
179-
/// It'll prepare `stmt`, if necessary.
181+
/// It'll prepare `stmt` (once), if necessary.
180182
fn exec_batch<'a: 'b, 'b, S, P, I>(
181183
&'a mut self,
182184
stmt: &'b S,

src/queryable/query_result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl ResultSetMeta {
4141

4242
/// Result of a query or statement execution.
4343
///
44-
/// Represents an asyncronous query result, that may not be fully consumed. Note,
44+
/// Represents an asynchronous query result, that may not be fully consumed. Note,
4545
/// that unconsumed query results are dropped implicitly when corresponding connection
4646
/// is dropped or queried.
4747
#[derive(Debug)]

0 commit comments

Comments
 (0)