lolraft/process/
completion.rs1use super::*;
2
3use tokio::sync::oneshot;
4
5pub enum Completion {
6 User(UserCompletion),
7 Kern(KernCompletion),
8}
9
10pub struct UserCompletion(oneshot::Sender<Bytes>);
11impl UserCompletion {
12 pub fn complete_with(self, data: Bytes) -> Result<(), Bytes> {
13 self.0.send(data)
14 }
15}
16
17pub struct KernCompletion(oneshot::Sender<()>);
18impl KernCompletion {
19 pub fn complete(self) {
20 self.0.send(()).ok();
21 }
22}
23
24pub fn prepare_kern_completion() -> (KernCompletion, oneshot::Receiver<()>) {
25 let (tx, rx) = oneshot::channel::<()>();
26 (KernCompletion(tx), rx)
27}
28
29pub fn prepare_user_completion() -> (UserCompletion, oneshot::Receiver<Bytes>) {
30 let (tx, rx) = oneshot::channel::<Bytes>();
31 (UserCompletion(tx), rx)
32}