Skip to main content

surrealdb/api/method/
cancel.rs

1use std::future::IntoFuture;
2
3use crate::api::method::BoxFuture;
4use crate::api::{Connection, Result, Surreal};
5use crate::core::expr::TopLevelExpr;
6
7/// A transaction cancellation future
8#[derive(Debug)]
9#[must_use = "futures do nothing unless you `.await` or poll them"]
10pub struct Cancel<C: Connection> {
11	pub(crate) client: Surreal<C>,
12}
13
14impl<C> IntoFuture for Cancel<C>
15where
16	C: Connection,
17{
18	type Output = Result<Surreal<C>>;
19	type IntoFuture = BoxFuture<'static, Self::Output>;
20
21	fn into_future(self) -> Self::IntoFuture {
22		Box::pin(async move {
23			self.client.query(TopLevelExpr::Cancel).await?;
24			Ok(self.client)
25		})
26	}
27}