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
use ockam_core::compat::vec::Vec;
use ockam_core::{Message, ProtocolId};
use serde::{Deserialize, Serialize};
mod parser;
pub use parser::*;
pub mod stream;
#[derive(Debug, Serialize, Deserialize)]
pub struct ProtocolPayload {
pub protocol: ProtocolId,
pub data: Vec<u8>,
}
impl ProtocolPayload {
pub fn new<P: Into<ProtocolId>, S: Message>(p: P, d: S) -> Self {
Self {
protocol: p.into(),
data: d.encode().expect("Failed to serialise protocol payload"),
}
}
}