use crate::{deinit_handle, init_handle, with_handle, DeviceHandle, Result};
use bnr_xfs::{IntermediateOccurredFn, OperationCompletedFn, StatusOccurredFn};
pub fn open(
op_complete_callback: Option<OperationCompletedFn>,
intermediate_occurred_callback: Option<IntermediateOccurredFn>,
status_occurred_callback: Option<StatusOccurredFn>,
) -> Result<()> {
let handle = DeviceHandle::open(
op_complete_callback,
intermediate_occurred_callback,
status_occurred_callback,
)?;
init_handle(handle)
}
pub fn reset() -> Result<()> {
with_handle::<()>(|h| h.reset())
}
pub fn cancel() -> Result<()> {
with_handle::<()>(|h| h.cancel())
}
pub fn close() -> Result<()> {
with_handle::<()>(|h| h.close())
}
pub fn reboot() -> Result<()> {
with_handle::<()>(|h| h.reboot())
}
pub fn stop_session() -> Result<()> {
with_handle::<()>(|h| h.stop_session())
}
pub fn destroy() -> Result<()> {
deinit_handle()
}