Skip to content

Commit 1d0be23

Browse files
committed
Add transaction api
1 parent 1a8926c commit 1d0be23

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ impl Connection {
5858
Ok(ExecResult { res, ptr, types })
5959
}
6060
}
61+
62+
pub fn begin(&self) -> bool {
63+
unsafe {
64+
let status = xdb_begin(self.ptr);
65+
status as u32 == xdb_errno_e_XDB_OK
66+
}
67+
}
68+
69+
pub fn commit(&self) -> bool {
70+
unsafe {
71+
let status = xdb_commit(self.ptr);
72+
status as u32 == xdb_errno_e_XDB_OK
73+
}
74+
}
75+
76+
pub fn rollback(&self) -> bool {
77+
unsafe {
78+
let status = xdb_rollback(self.ptr);
79+
status as u32 == xdb_errno_e_XDB_OK
80+
}
81+
}
6182
}
6283

6384
#[derive(Debug)]

0 commit comments

Comments
 (0)