use crate::mount::{mount_dataset, MountOptions};
use crate::unmount::{unmount_dataset, UnmountOptions};
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
use std::path::PathBuf;
#[pyfunction]
fn mount(
source: String,
destination: String,
parallel: Option<usize>,
use_mmap: Option<bool>,
compress: Option<bool>,
memory_threshold: Option<u8>,
) -> PyResult<()> {
let options = MountOptions {
source: PathBuf::from(source),
destination: PathBuf::from(destination),
parallel: parallel.unwrap_or(4),
use_mmap: use_mmap.unwrap_or(false),
compress: compress.unwrap_or(false),
memory_threshold: memory_threshold.unwrap_or(90),
};
mount_dataset(&options).map_err(|e| PyValueError::new_err(e.to_string()))
}
#[pyfunction]
fn unmount(target: String, force: Option<bool>) -> PyResult<()> {
let options = UnmountOptions {
target: PathBuf::from(target),
force: force.unwrap_or(false),
};
unmount_dataset(&options).map_err(|e| PyValueError::new_err(e.to_string()))
}
#[pymodule]
pub fn palacex(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(mount, m)?)?;
m.add_function(wrap_pyfunction!(unmount, m)?)?;
Ok(())
}