surrealdb/api/method/
commit.rs

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