use crate::bridge::ffi;
use crate::path::Path;
use crate::PathOp;
use cxx::UniquePtr;
pub struct OpBuilder {
inner: UniquePtr<ffi::OpBuilderHolder>,
}
impl Default for OpBuilder {
fn default() -> Self {
Self::new()
}
}
impl OpBuilder {
pub fn new() -> Self {
Self {
inner: ffi::op_builder_new(),
}
}
pub fn add(&mut self, path: Path, op: PathOp) -> &mut Self {
ffi::op_builder_add(self.inner.pin_mut(), path.as_cpp_ref(), op);
self
}
pub fn add_ref(&mut self, path: &Path, op: PathOp) -> &mut Self {
ffi::op_builder_add(self.inner.pin_mut(), path.as_cpp_ref(), op);
self
}
pub fn resolve(&mut self) -> Option<Path> {
let mut result = Path::new();
let ok = ffi::op_builder_resolve(self.inner.pin_mut(), result.pin_cpp_mut());
if ok {
Some(result)
} else {
None
}
}
}