Skip to content

Commit

Permalink
Merge pull request #38 from naim94a/add-frames
Browse files Browse the repository at this point in the history
atrium-xrpc-server: parse handle, info, migrate & tombstone messages
  • Loading branch information
sugyan committed Jul 14, 2023
2 parents 068355b + 76ab4f7 commit ac6ee9a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion atrium-xrpc-server/src/stream/frames.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use atrium_api::com::atproto::sync::subscribe_repos::{Commit, Message};
use atrium_api::com::atproto::sync::subscribe_repos::{Commit, Message, Tombstone, Handle, Info, Migrate};
use libipld_core::ipld::Ipld;
use std::io::Cursor;

Expand Down Expand Up @@ -88,6 +88,26 @@ impl TryFrom<&[u8]> for Frame {
right,
)?)),
}))),
Some("#handle") => Ok(Frame::Message(Box::new(MessageFrame {
body: Message::Handle(Box::new(serde_ipld_dagcbor::from_slice::<Handle>(
right
)?))
}))),
Some("#info") => Ok(Frame::Message(Box::new(MessageFrame {
body: Message::Info(Box::new(serde_ipld_dagcbor::from_slice::<Info>(
right
)?))
}))),
Some("#migrate") => Ok(Frame::Message(Box::new(MessageFrame {
body: Message::Migrate(Box::new(serde_ipld_dagcbor::from_slice::<Migrate>(
right
)?))
}))),
Some("#tombstone") => Ok(Frame::Message(Box::new(MessageFrame {
body: Message::Tombstone(Box::new(serde_ipld_dagcbor::from_slice::<Tombstone>(
right
)?))
}))),
_ => {
let tag = t.as_deref();
Err(anyhow::anyhow!("frame not implemented: tag={tag:?}"))
Expand Down

0 comments on commit ac6ee9a

Please sign in to comment.