eureka_mmanager/files_dirs/messages/modify/
modify_data_path.rs1use crate::files_dirs::DirsOptions;
2use actix::prelude::*;
3use std::{fmt::Debug, path::Path};
4
5#[derive(Debug, Message)]
6#[rtype(result = "()")]
7pub struct ModifyDataDirMessage<T>(pub T)
8where
9 T: AsRef<Path> + Debug;
10
11impl<T> Clone for ModifyDataDirMessage<T>
12where
13 T: Clone + Debug + AsRef<Path>,
14{
15 fn clone(&self) -> Self {
16 Self(self.0.clone())
17 }
18}
19
20impl<T> AsRef<Path> for ModifyDataDirMessage<T>
21where
22 T: AsRef<Path> + Debug,
23{
24 fn as_ref(&self) -> &Path {
25 self.0.as_ref()
26 }
27}
28
29impl<T> From<T> for ModifyDataDirMessage<T>
30where
31 T: AsRef<Path> + Debug,
32{
33 fn from(value: T) -> Self {
34 Self(value)
35 }
36}
37
38impl<T> Handler<ModifyDataDirMessage<T>> for DirsOptions
39where
40 T: AsRef<Path> + Debug,
41{
42 type Result = ();
43 fn handle(&mut self, msg: ModifyDataDirMessage<T>, _ctx: &mut Self::Context) -> Self::Result {
44 self.data_dir = msg.as_ref().to_path_buf();
45 if let Err(e) = self.verify_and_init() {
46 log::error!("{e}");
47 }
48 }
49}