1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::error::Error;
use std::sync::mpsc::Sender;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::destination::MessageDestination;
use crate::message::Message;
#[derive(Debug, Clone)]
pub struct RustReceiverDestination {
sender: Sender<Message>
}
impl RustReceiverDestination {
pub fn create(sender: Sender<Message>) -> Self {
Self {
sender,
}
}
}
impl MessageDestination for RustReceiverDestination {
fn send(&self, message: &Message) -> Result<(), Box<dyn Error>> {
self.sender.send(message.clone())?;
Ok(())
}
}
impl Serialize for RustReceiverDestination {
fn serialize<S>(&self, _: S) -> Result<S::Ok, S::Error> where S: Serializer {
panic!("Not possible - testing only.")
}
}
impl<'de> Deserialize<'de> for RustReceiverDestination {
fn deserialize<D>(_: D) -> Result<Self, D::Error> where D: Deserializer<'de> {
panic!("Not possible - testing only")
}
}
impl PartialEq for RustReceiverDestination {
fn eq(&self, _other: &Self) -> bool {
return false;
}
}