Rust AppView - highly experimental!
at feat-viewer-interactions 126 lines 2.9 kB view raw
1#![allow(unused)] 2 3use chrono::prelude::*; 4use ipld_core::cid::Cid; 5use serde::Deserialize; 6use serde_bytes::ByteBuf; 7 8#[derive(Debug)] 9pub enum FirehoseOutput { 10 Close, 11 Event(Box<FirehoseEvent>), 12 Error(AtpEventStreamError), 13 Continue, 14} 15 16#[derive(Debug, Deserialize)] 17pub struct AtpEventStreamHeader { 18 pub op: i32, 19 pub t: Option<String>, 20} 21 22#[derive(Debug, Deserialize)] 23pub struct AtpEventStreamError { 24 pub error: String, 25 pub message: Option<String>, 26} 27 28#[derive(Debug)] 29pub enum FirehoseEvent { 30 Identity(AtpIdentityEvent), 31 Account(AtpAccountEvent), 32 Commit(AtpCommitEvent), 33 Label(AtpLabelEvent), 34} 35 36#[derive(Debug, Deserialize)] 37pub struct AtpIdentityEvent { 38 pub seq: u64, 39 pub did: String, 40 pub time: DateTime<Utc>, 41 pub handle: Option<String>, 42} 43 44#[derive(Debug, Deserialize)] 45#[serde(rename_all = "lowercase")] 46pub enum AtpAccountStatus { 47 Takendown, 48 Suspended, 49 Deleted, 50 Deactivated, 51} 52 53impl AtpAccountStatus { 54 pub fn as_str(&self) -> &'static str { 55 match self { 56 AtpAccountStatus::Takendown => "takendown", 57 AtpAccountStatus::Suspended => "suspended", 58 AtpAccountStatus::Deleted => "deleted", 59 AtpAccountStatus::Deactivated => "deactivated", 60 } 61 } 62} 63 64impl From<AtpAccountStatus> for parakeet_db::types::ActorStatus { 65 fn from(value: AtpAccountStatus) -> Self { 66 match value { 67 AtpAccountStatus::Takendown => parakeet_db::types::ActorStatus::Takendown, 68 AtpAccountStatus::Suspended => parakeet_db::types::ActorStatus::Suspended, 69 AtpAccountStatus::Deleted => parakeet_db::types::ActorStatus::Deleted, 70 AtpAccountStatus::Deactivated => parakeet_db::types::ActorStatus::Deactivated, 71 } 72 } 73} 74 75#[derive(Debug, Deserialize)] 76pub struct AtpAccountEvent { 77 pub seq: u64, 78 pub did: String, 79 pub time: DateTime<Utc>, 80 pub active: bool, 81 pub status: Option<AtpAccountStatus>, 82} 83 84#[derive(Debug, Deserialize)] 85pub struct AtpCommitEvent { 86 pub seq: u64, 87 pub repo: String, 88 pub time: DateTime<Utc>, 89 pub rev: String, 90 pub since: Option<String>, 91 pub commit: Cid, 92 #[serde(rename = "tooBig")] 93 pub too_big: bool, 94 #[serde(default)] 95 pub blocks: ByteBuf, 96 #[serde(default)] 97 pub ops: Vec<CommitOp>, 98 #[serde(default)] 99 pub blobs: Vec<Cid>, 100} 101 102#[derive(Debug, Deserialize)] 103pub struct CommitOp { 104 pub action: String, 105 pub cid: Option<Cid>, 106 pub path: String, 107} 108 109#[derive(Debug, Deserialize)] 110pub struct AtpLabel { 111 pub ver: i32, 112 pub src: String, 113 pub uri: String, 114 pub cid: Option<String>, 115 pub val: String, 116 pub neg: Option<bool>, 117 pub cts: DateTime<Utc>, 118 pub exp: Option<DateTime<Utc>>, 119 pub sig: Option<ByteBuf>, 120} 121 122#[derive(Debug, Deserialize)] 123pub struct AtpLabelEvent { 124 pub seq: u64, 125 pub labels: Vec<AtpLabel>, 126}