tlsn_prover/
future.rs

1//! This module collects futures which are used by the [Prover].
2
3use super::{state, Prover, ProverControl, ProverError};
4use futures::Future;
5use std::pin::Pin;
6
7/// Prover future which must be polled for the TLS connection to make progress.
8pub struct ProverFuture {
9    #[allow(clippy::type_complexity)]
10    pub(crate) fut: Pin<
11        Box<dyn Future<Output = Result<Prover<state::Committed>, ProverError>> + Send + 'static>,
12    >,
13    pub(crate) ctrl: ProverControl,
14}
15
16impl ProverFuture {
17    /// Returns a controller for the prover for advanced functionality.
18    pub fn control(&self) -> ProverControl {
19        self.ctrl.clone()
20    }
21}
22
23impl Future for ProverFuture {
24    type Output = Result<Prover<state::Committed>, ProverError>;
25
26    fn poll(
27        mut self: Pin<&mut Self>,
28        cx: &mut std::task::Context<'_>,
29    ) -> std::task::Poll<Self::Output> {
30        self.fut.as_mut().poll(cx)
31    }
32}