pub fn stream<'session>(
        &mut self,
        session: &'session mut ClientSession,
    ) -> SessionCursorStream<'_, 'session, T> {
        let get_more_provider = ExplicitSessionGetMoreProvider::new(session);

        // Pass the buffer into this cursor handle for iteration.
        // It will be returned in the handle's `Drop` implementation.
        let spec = CursorSpecification {
            info: self.info.clone(),
            initial_buffer: std::mem::take(&mut self.buffer),
        };
        SessionCursorStream {
            generic_cursor: ExplicitSessionCursor::new(
                self.client.clone(),
                spec,
                self.pinned_connection.replicate(),
                get_more_provider,
            ),
            session_cursor: self,
        }
    }
/// Retrieves a [`SessionCursorStream`] to iterate this cursor. The session provided must be the
/// same session used to create the cursor.
///
/// Note that the borrow checker will not allow the session to be reused in between iterations
/// of this stream. In order to do that, either use [`SessionCursor::next`] instead or drop
/// the stream before using the session.
///
/// ```
/// # use bson::{doc, Document};
/// # use mongodb::{Client, error::Result};
/// # fn main() {
/// # async {
/// # let client = Client::with_uri_str("foo").await?;
/// # let coll = client.database("foo").collection::<Document>("bar");
/// # let other_coll = coll.clone();
/// # let mut session = client.start_session(None).await?;
/// #
/// use futures::stream::TryStreamExt;
///
/// // iterate over the results
/// let mut cursor = coll.find_with_session(doc! { "x": 1 }, None, &mut session).await?;
/// while let Some(doc) = cursor.stream(&mut session).try_next().await? {
///     println!("{}", doc);
/// }
///
/// // collect the results
/// let mut cursor1 = coll.find_with_session(doc! { "x": 1 }, None, &mut session).await?;
/// let v: Vec<Document> = cursor1.stream(&mut session).try_collect().await?;
///
/// // use session between iterations
/// let mut cursor2 = coll.find_with_session(doc! { "x": 1 }, None, &mut session).await?;
/// loop {
///     let doc = match cursor2.stream(&mut session).try_next().await? {
///         Some(d) => d,
///         None => break,
///     };
///     other_coll.insert_one_with_session(doc, None, &mut session).await?;
/// }
/// # Ok::<(), mongodb::error::Error>(())
/// # };
/// # }
/// ```
Retrieves a [`SessionCursorStream`] to iterate this cursor. The session provided must be the
same session used to create the cursor.

Note that the borrow checker will not allow the session to be reused in between iterations
of this stream. In order to do that, either use [`SessionCursor::next`] instead or drop
the stream before using the session.


Retrieves a [ ` SessionCursorStream ` ] to iterate this cursor . The session provided must be the same session used to create the cursor . Note that the borrow checker will not allow the session to be reused in between iterations of this stream . In order to do that either use [ ` SessionCursor :: next ` ] instead or drop the stream before using the session .
pub fn stream<'session>(
        &mut self,
        session: &'session mut ClientSession,
    ) -> SessionCursorStream<'_, 'session, T> {
        let get_more_provider = ExplicitSessionGetMoreProvider::new(session);
        // Pass the buffer into this cursor handle for iteration.
        // It will be returned in the handle's `Drop` implementation.
        let spec = CursorSpecification {
            info: self.info.clone(),
            initial_buffer: std::mem::take(&mut self.buffer),
        };
        SessionCursorStream {
            generic_cursor: ExplicitSessionCursor::new(
                self.client.clone(),
                spec,
                self.pinned_connection.replicate(),
                get_more_provider,
            ),
            session_cursor: self,
        }
    }
pub fn stream < ' session > ( & mut self , session : & ' session mut ClientSession , ) -> SessionCursorStream < ' _ , ' session , T > { let get_more_provider = ExplicitSessionGetMoreProvider :: new ( session ) ; // Pass the buffer into this cursor handle for iteration. // It will be returned in the handle's `Drop` implementation. let spec = CursorSpecification { info : self . info . clone ( ) , initial_buffer : std :: mem :: take ( & mut self . buffer ) , } ; SessionCursorStream { generic_cursor : ExplicitSessionCursor :: new ( self . client . clone ( ) , spec , self . pinned_connection . replicate ( ) , get_more_provider , ) , session_cursor : self , } }
Retrieves a [`SessionCursorStream`] to iterate this cursor.
Retrieves a [ ` SessionCursorStream ` ] to iterate this cursor .
&mut self
session
&'session mut ClientSession
&mut self
session
&'session mut ClientSession
use bson::{doc, document};
None
use mongodb::{client, error::result};
None
fn main() {
None
async {
None
let client = client::with_uri_str("foo").await?;
None
let coll = client.database("foo").collection::<document>("bar");
None
let other_coll = coll.clone();
None
let mut session = client.start_session(none).await?;
use futures::stream::TryStreamExt.

iterate over the results
let mut cursor = coll.find_with_session(doc. { "x": 1 }, None, &mut session).await?;
while let Some(doc) = cursor.stream(&mut session).try_next().await.

collect the results
let mut cursor1 = coll.find_with_session(doc. { "x": 1 }, None, &mut session).await?;
let v: Vec = cursor1.stream(&mut session).try_collect().await?.

use session between iterations
let mut cursor2 = coll.find_with_session(doc. { "x": 1 }, None, &mut session).await?;
loop {
let doc = match cursor2.stream(&mut session).try_next().await. {
Some(d) => d,
None => break,
};
other_coll.insert_one_with_session(doc, None, &mut session).await?;
}
use futures :: stream :: TryStreamExt . iterate over the results let mut cursor = coll . find_with_session ( doc . { " x " : 1 } None &mut session ) . await? ; while let Some ( doc ) = cursor . stream ( &mut session ) . try_next () . await . collect the results let mut cursor1 = coll . find_with_session ( doc . { " x " : 1 } None &mut session ) . await? ; let v : Vec = cursor1 . stream ( &mut session ) . try_collect () . await? . use session between iterations let mut cursor2 = coll . find_with_session ( doc . { " x " : 1 } None &mut session ) . await? ; loop { let doc = match cursor2 . stream ( &mut session ) . try_next () . await . { Some ( d ) = > d None = > break } ; other_coll . insert_one_with_session ( doc None &mut session ) . await? ; }
ok::<(), mongodb::error::error>(())
None
};
None
}
None