use async_trait::async_trait;
use crate::{a_sync::rm::ResourceManager, XaError};
#[async_trait]
pub trait TransactionManager {
async fn register(
&mut self,
rm: Box<dyn ResourceManager>,
rm_id: u64,
cleanup: bool,
) -> Result<(), XaError>;
fn unregister(&mut self, rm_id: u64) -> Result<(), XaError>;
async fn start_transaction(&mut self) -> Result<(), XaError>;
async fn commit_transaction(&mut self) -> Result<(), XaError>;
async fn rollback_transaction(&mut self) -> Result<(), XaError>;
fn set_transaction_rollbackonly(&mut self) -> Result<(), XaError>;
fn get_status(&mut self) -> Result<Status, XaError>;
}
bitflags::bitflags! {
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
pub struct Status: u32 {
const IDLE = 0x00_00_00_01;
const ACTIVATING = 0x00_00_00_02;
const ACTIVE = 0x00_00_00_04;
const PREPARING = 0x00_00_00_08;
const PREPARED = 0x00_00_01_00;
const COMMITTING = 0x00_00_02_00;
const COMMITTED = 0x00_00_04_00;
const ROLLBACK_ONLY = 0x00_00_08_00;
const ROLLINGBACK = 0x00_01_00_00;
const ROLLEDBACK = 0x00_02_00_00;
}
}