spark_channel/
callback.rs

1//! # Spark Channel
2//!
3//! This crate is used to send messages between modules. This crate is not specific to any of the traits but a generic implementation to implement them in an event-driven architecture.
4
5use tokio::sync::oneshot;
6
7/// A sender for a callback.
8pub type CallbackSender<V> = oneshot::Sender<V>;
9
10/// A wrapper for a callback.
11pub struct CallbackWrapper<T, V> {
12    /// The message.
13    pub message: T,
14
15    /// The sender for the callback.
16    pub sender: CallbackSender<V>,
17}
18
19impl<T, V> CallbackWrapper<T, V> {
20    /// Get the inner values as owned values.
21    pub(crate) fn inner_owned(self) -> (T, CallbackSender<V>) {
22        return (self.message, self.sender);
23    }
24}