1use bytestring::ByteString;
2
3#[must_use]
5#[derive(Debug, Clone)]
6pub struct Data {
7 pub(crate) id: Option<ByteString>,
8 pub(crate) event: Option<ByteString>,
9 pub(crate) data: ByteString,
10}
11
12impl Data {
13 pub fn new<T: Into<ByteString>>(data: T) -> Self {
20 Self {
21 id: None,
22 event: None,
23 data: data.into(),
24 }
25 }
26
27 pub fn id(mut self, id: impl Into<ByteString>) -> Self {
29 self.id = Some(id.into());
30 self
31 }
32
33 pub fn event(mut self, event: impl Into<ByteString>) -> Self {
35 self.event = Some(event.into());
36 self
37 }
38}