zelos_proto/trace/
helpers.rs1use zelos_trace_types::ipc;
2
3use super::TraceMessageBatch;
4use crate::error::Error;
5
6impl super::SubscribeResponse {
7 pub fn from_ipc(messages: Vec<super::TraceMessage>) -> Self {
8 Self {
9 msg: Some(super::subscribe_response::Msg::TraceMessageBatch(
10 TraceMessageBatch { messages },
11 )),
12 }
13 }
14
15 pub fn as_ipc(self) -> Result<Vec<ipc::IpcMessageWithId>, Error> {
16 match self.msg {
17 Some(super::subscribe_response::Msg::TraceMessageBatch(msg)) => {
18 msg.messages.into_iter().map(|msg| msg.try_into()).collect()
19 }
20 None => Err(Error::MissingMessage),
21 }
22 }
23}