mysql_async/conn/routines/
next_set.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use std::marker::PhantomData;

use futures_core::future::BoxFuture;
use futures_util::FutureExt;
#[cfg(feature = "tracing")]
use tracing::debug_span;

use crate::{queryable::Protocol, Conn};

use super::Routine;

/// A routine that handles subsequent result of a mutlti-result set.
#[derive(Debug, Clone, Copy)]
pub struct NextSetRoutine<P>(PhantomData<P>);

impl<P> NextSetRoutine<P> {
    pub fn new() -> Self {
        Self(PhantomData)
    }
}

impl<P> Routine<()> for NextSetRoutine<P>
where
    P: Protocol,
{
    fn call<'a>(&'a mut self, conn: &'a mut Conn) -> BoxFuture<'a, crate::Result<()>> {
        #[cfg(feature = "tracing")]
        let span = debug_span!(
            "mysql_async::next_set",
            mysql_async.connection.id = conn.id()
        );
        conn.sync_seq_id();
        let fut = async move {
            conn.read_result_set::<P>(false).await?;
            Ok(())
        };

        #[cfg(feature = "tracing")]
        let fut = instrument_result!(fut, span);

        fut.boxed()
    }
}