I noticed some functions return Box<dyn Error>, when they can just return the error code. Is this intentional?
|
/// Start the handle with the given callback, which will watch the specified path for changes. |
|
/// |
|
/// Note: Currently the only supported flag is RECURSIVE and only on OSX and Windows. |
|
pub fn start<CB: Into<FsEventCB<'static>>>( |
|
&mut self, |
|
path: &str, |
|
flags: FsEventFlags, |
|
cb: CB, |
|
) -> Result<(), Box<dyn std::error::Error>> { |
|
let path = CString::new(path)?; |
|
|
|
// uv_cb is either Some(fs_event_cb) or None |
|
let cb = cb.into(); |
|
let uv_cb = use_c_callback!(uv_fs_event_cb, cb); |
|
|
|
// cb is either Some(closure) or None - it is saved into data |
|
let dataptr = crate::Handle::get_data(uv_handle!(self.handle)); |
|
if !dataptr.is_null() { |
|
if let super::FsEventData(d) = unsafe { &mut (*dataptr).addl } { |
|
d.fs_event_cb = cb; |
|
} |
|
} |
|
|
|
crate::uvret(unsafe { uv_fs_event_start(self.handle, uv_cb, path.as_ptr(), flags.bits()) }) |
|
.map_err(|e| Box::new(e) as _) |
|
} |
I noticed some functions return
Box<dyn Error>, when they can just return the error code. Is this intentional?libuv-rs/src/handles/fs_event.rs
Lines 136 to 161 in df3f9e1