mysql_async/conn/routines/
next_set.rs

1use std::marker::PhantomData;
2
3use futures_core::future::BoxFuture;
4use futures_util::FutureExt;
5#[cfg(feature = "tracing")]
6use tracing::debug_span;
7
8use crate::{queryable::Protocol, Conn};
9
10use super::Routine;
11
12/// A routine that handles subsequent result of a mutlti-result set.
13#[derive(Debug, Clone, Copy)]
14pub struct NextSetRoutine<P>(PhantomData<P>);
15
16impl<P> NextSetRoutine<P> {
17    pub fn new() -> Self {
18        Self(PhantomData)
19    }
20}
21
22impl<P> Routine<()> for NextSetRoutine<P>
23where
24    P: Protocol,
25{
26    fn call<'a>(&'a mut self, conn: &'a mut Conn) -> BoxFuture<'a, crate::Result<()>> {
27        #[cfg(feature = "tracing")]
28        let span = debug_span!(
29            "mysql_async::next_set",
30            mysql_async.connection.id = conn.id()
31        );
32        conn.sync_seq_id();
33        let fut = async move {
34            conn.read_result_set::<P>(false).await?;
35            Ok(())
36        };
37
38        #[cfg(feature = "tracing")]
39        let fut = instrument_result!(fut, span);
40
41        fut.boxed()
42    }
43}