eureka-mmanager 0.2.0

An Actix actor collection for downloading manga, chapters, covers from Mangadex
Documentation
use crate::files_dirs::DirsOptions;
use actix::prelude::*;
use std::{fmt::Debug, path::Path};

#[derive(Debug, Message)]
#[rtype(result = "()")]
pub struct ModifyMangaDirMessage<T>(pub T)
where
    T: AsRef<Path> + Debug;

impl<T> Clone for ModifyMangaDirMessage<T>
where
    T: Clone + Debug + AsRef<Path>,
{
    fn clone(&self) -> Self {
        Self(self.0.clone())
    }
}

impl<T> AsRef<Path> for ModifyMangaDirMessage<T>
where
    T: AsRef<Path> + Debug,
{
    fn as_ref(&self) -> &Path {
        self.0.as_ref()
    }
}

impl<T> From<T> for ModifyMangaDirMessage<T>
where
    T: AsRef<Path> + Debug,
{
    fn from(value: T) -> Self {
        Self(value)
    }
}

impl<T> Handler<ModifyMangaDirMessage<T>> for DirsOptions
where
    T: AsRef<Path> + Debug,
{
    type Result = ();
    fn handle(&mut self, msg: ModifyMangaDirMessage<T>, _ctx: &mut Self::Context) -> Self::Result {
        self.mangas = msg.as_ref().to_path_buf();
        if let Err(e) = self.verify_and_init() {
            log::error!("{e}");
        }
    }
}