Skip to content

Commit 55cd3d9

Browse files
authored
minor: document cursor/change stream Drop implementations (#745)
1 parent 5fb9b52 commit 55cd3d9

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

manual/src/reading.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,6 @@ while let Some(book) = cursor.try_next().await? {
9898
println!("title: {}", book.title);
9999
}
100100
# Ok(()) }
101-
```
101+
```
102+
103+
If a [`Cursor`](https://docs.rs/mongodb/latest/mongodb/struct.Cursor.html) is still open when it goes out of scope, it will automatically be closed via an asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.

src/change_stream/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ use crate::{
7575
/// # }
7676
/// ```
7777
///
78+
/// If a [`ChangeStream`] is still open when it goes out of scope, it will automatically be closed
79+
/// via an asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
80+
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
81+
///
7882
/// See the documentation [here](https://www.mongodb.com/docs/manual/changeStreams) for more
7983
/// details. Also see the documentation on [usage recommendations](https://www.mongodb.com/docs/manual/administration/change-streams-production-recommendations/).
8084
#[derive(Derivative)]

src/change_stream/session.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ use super::{
3434
/// # Ok(())
3535
/// # }
3636
/// ```
37+
///
38+
/// If a [`SessionChangeStream`] is still open when it goes out of scope, it will automatically be
39+
/// closed via an asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
40+
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
3741
pub struct SessionChangeStream<T>
3842
where
3943
T: DeserializeOwned + Unpin,

src/cursor/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ pub(crate) use common::{
9595
/// # Ok(())
9696
/// # }
9797
/// ```
98+
///
99+
/// If a [`Cursor`] is still open when it goes out of scope, it will automatically be closed via an
100+
/// asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
101+
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
98102
#[derive(Debug)]
99103
pub struct Cursor<T> {
100104
client: Client,

src/cursor/session.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ use crate::{
6565
/// # Ok(())
6666
/// # }
6767
/// ```
68+
///
69+
/// If a [`SessionCursor`] is still open when it goes out of scope, it will automatically be closed
70+
/// via an asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
71+
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
6872
#[derive(Debug)]
6973
pub struct SessionCursor<T> {
7074
client: Client,

0 commit comments

Comments
 (0)