p2p/channels/
p2p_channels_service.rs1use crate::{
2 identity::{EncryptableType, PublicKey},
3 PeerId,
4};
5
6use super::{ChannelId, ChannelMsg, MsgId};
7
8pub trait P2pChannelsService: redux::Service {
9 fn channel_open(&mut self, peer_id: PeerId, id: ChannelId);
10 fn channel_send(&mut self, peer_id: PeerId, msg_id: MsgId, msg: ChannelMsg);
11 fn encrypt<T: EncryptableType>(
12 &mut self,
13 other_pk: &PublicKey,
14 message: &T,
15 ) -> Result<T::Encrypted, Box<dyn std::error::Error>>;
16 fn decrypt<T: EncryptableType>(
17 &mut self,
18 other_pk: &PublicKey,
19 encrypted: &T::Encrypted,
20 ) -> Result<T, Box<dyn std::error::Error>>;
21}