Skip to main content

eureka_mmanager/download/chapter/task/messages/
wait.rs

1use actix::prelude::*;
2use mangadex_api_schema_rust::v5::ChapterObject as Object;
3
4use crate::download::{
5    chapter::task::{ChapterDownloadTask as Task, ChapterDownloadingState as State},
6    messages::WaitForFinishedMessage,
7    state::{make_wait_for_finish_couple, WaitForFinished},
8    traits::task::CanBeWaited,
9};
10
11pub type WaitForFinishedChapterMessage = WaitForFinishedMessage<Object, State>;
12
13impl Handler<WaitForFinishedChapterMessage> for Task {
14    type Result = <WaitForFinishedChapterMessage as Message>::Result;
15    fn handle(
16        &mut self,
17        _msg: WaitForFinishedMessage<Object, State>,
18        _ctx: &mut Self::Context,
19    ) -> Self::Result {
20        self.wait()
21    }
22}
23
24impl CanBeWaited for Task {
25    type Ok = Object;
26    type Loading = State;
27    fn wait(&mut self) -> WaitForFinished<Self::Ok, Self::Loading> {
28        let (recipient, fut) = make_wait_for_finish_couple::<Self::Ok, Self::Loading>();
29        self.subscribers.push_recipient(recipient.into());
30        fut
31    }
32}