summaryrefslogtreecommitdiffstats
path: root/src/io/io_observer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/io/io_observer.rs')
-rw-r--r--src/io/io_observer.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/io/io_observer.rs b/src/io/io_observer.rs
new file mode 100644
index 0000000..c31b94d
--- /dev/null
+++ b/src/io/io_observer.rs
@@ -0,0 +1,40 @@
+use std::path;
+use std::thread;
+
+#[derive(Debug)]
+pub struct IOWorkerObserver {
+ pub handle: thread::JoinHandle<()>,
+ msg: Option<String>,
+ src: path::PathBuf,
+ dest: path::PathBuf,
+}
+
+impl IOWorkerObserver {
+ pub fn new(handle: thread::JoinHandle<()>, src: path::PathBuf, dest: path::PathBuf) -> Self {
+ Self {
+ handle,
+ src,
+ dest,
+ msg: None,
+ }
+ }
+
+ pub fn join(self) {
+ self.handle.join();
+ }
+ pub fn set_msg(&mut self, msg: String) {
+ self.msg = Some(msg)
+ }
+ pub fn get_msg(&self) -> Option<&String> {
+ self.msg.as_ref()
+ }
+ pub fn clear_msg(&mut self) {
+ self.msg = None
+ }
+ pub fn get_src_path(&self) -> &path::Path {
+ self.src.as_path()
+ }
+ pub fn get_dest_path(&self) -> &path::Path {
+ self.dest.as_path()
+ }
+}