1use crate::mount::{mount_dataset, MountOptions};
2use crate::unmount::{unmount_dataset, UnmountOptions};
3use pyo3::exceptions::PyValueError;
4use pyo3::prelude::*;
5use std::path::PathBuf;
6
7#[pyfunction]
8fn mount(
9 source: String,
10 destination: String,
11 parallel: Option<usize>,
12 use_mmap: Option<bool>,
13 compress: Option<bool>,
14 memory_threshold: Option<u8>,
15) -> PyResult<()> {
16 let options = MountOptions {
17 source: PathBuf::from(source),
18 destination: PathBuf::from(destination),
19 parallel: parallel.unwrap_or(4),
20 use_mmap: use_mmap.unwrap_or(false),
21 compress: compress.unwrap_or(false),
22 memory_threshold: memory_threshold.unwrap_or(90),
23 };
24
25 mount_dataset(&options).map_err(|e| PyValueError::new_err(e.to_string()))
26}
27
28#[pyfunction]
29fn unmount(target: String, force: Option<bool>) -> PyResult<()> {
30 let options = UnmountOptions {
31 target: PathBuf::from(target),
32 force: force.unwrap_or(false),
33 };
34
35 unmount_dataset(&options).map_err(|e| PyValueError::new_err(e.to_string()))
36}
37
38#[pymodule]
39pub fn palacex(_py: Python, m: &PyModule) -> PyResult<()> {
40 m.add_function(wrap_pyfunction!(mount, m)?)?;
41 m.add_function(wrap_pyfunction!(unmount, m)?)?;
42 Ok(())
43}