Alternative ATProto PDS implementation

remove repo dir

Changed files
+156 -1553
src
+92
src/actor_store/blob/store.rs
··· 1 + use anyhow::Result; 2 + use atrium_repo::Cid; 3 + use std::fmt::Debug; 4 + 5 + /// BlobStream 6 + /// A stream of blob data. 7 + pub(crate) struct BlobStream(Box<dyn std::io::Read + Send>); 8 + impl Debug for BlobStream { 9 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 10 + f.debug_struct("BlobStream").finish() 11 + } 12 + } 13 + 14 + pub(crate) struct BlobStorePlaceholder; 15 + pub(crate) trait BlobStore { 16 + async fn put_temp(&self, bytes: &[u8]) -> Result<String>; // bytes: Uint8Array | stream.Readable 17 + async fn make_permanent(&self, key: &str, cid: Cid) -> Result<()>; 18 + async fn put_permanent(&self, cid: Cid, bytes: &[u8]) -> Result<()>; 19 + async fn quarantine(&self, cid: Cid) -> Result<()>; 20 + async fn unquarantine(&self, cid: Cid) -> Result<()>; 21 + async fn get_bytes(&self, cid: Cid) -> Result<Vec<u8>>; 22 + async fn get_stream(&self, cid: Cid) -> Result<BlobStream>; // Promise<stream.Readable> 23 + async fn has_temp(&self, key: &str) -> Result<bool>; 24 + async fn has_stored(&self, cid: Cid) -> Result<bool>; 25 + async fn delete(&self, cid: Cid) -> Result<()>; 26 + async fn delete_many(&self, cids: Vec<Cid>) -> Result<()>; 27 + } 28 + impl BlobStore for BlobStorePlaceholder { 29 + async fn put_temp(&self, bytes: &[u8]) -> Result<String> { 30 + // Implementation here 31 + todo!(); 32 + Ok("temp_key".to_string()) 33 + } 34 + 35 + async fn make_permanent(&self, key: &str, cid: Cid) -> Result<()> { 36 + // Implementation here 37 + todo!(); 38 + Ok(()) 39 + } 40 + 41 + async fn put_permanent(&self, cid: Cid, bytes: &[u8]) -> Result<()> { 42 + // Implementation here 43 + todo!(); 44 + Ok(()) 45 + } 46 + 47 + async fn quarantine(&self, cid: Cid) -> Result<()> { 48 + // Implementation here 49 + todo!(); 50 + Ok(()) 51 + } 52 + 53 + async fn unquarantine(&self, cid: Cid) -> Result<()> { 54 + // Implementation here 55 + todo!(); 56 + Ok(()) 57 + } 58 + 59 + async fn get_bytes(&self, cid: Cid) -> Result<Vec<u8>> { 60 + // Implementation here 61 + todo!(); 62 + Ok(vec![]) 63 + } 64 + 65 + async fn get_stream(&self, cid: Cid) -> Result<BlobStream> { 66 + // Implementation here 67 + todo!(); 68 + Ok(BlobStream(Box::new(std::io::empty()))) 69 + } 70 + 71 + async fn has_temp(&self, key: &str) -> Result<bool> { 72 + // Implementation here 73 + todo!(); 74 + Ok(true) 75 + } 76 + 77 + async fn has_stored(&self, cid: Cid) -> Result<bool> { 78 + // Implementation here 79 + todo!(); 80 + Ok(true) 81 + } 82 + async fn delete(&self, cid: Cid) -> Result<()> { 83 + // Implementation here 84 + todo!(); 85 + Ok(()) 86 + } 87 + async fn delete_many(&self, cids: Vec<Cid>) -> Result<()> { 88 + // Implementation here 89 + todo!(); 90 + Ok(()) 91 + } 92 + }
+64
src/actor_store/prepared_write.rs
··· 1 + use rsky_repo::types::{ 2 + CommitAction, PreparedBlobRef, PreparedCreateOrUpdate, PreparedDelete, WriteOpAction, 3 + }; 4 + use serde::{Deserialize, Serialize}; 5 + 6 + #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 7 + pub enum PreparedWrite { 8 + Create(PreparedCreateOrUpdate), 9 + Update(PreparedCreateOrUpdate), 10 + Delete(PreparedDelete), 11 + } 12 + 13 + impl PreparedWrite { 14 + pub fn uri(&self) -> &String { 15 + match self { 16 + PreparedWrite::Create(w) => &w.uri, 17 + PreparedWrite::Update(w) => &w.uri, 18 + PreparedWrite::Delete(w) => &w.uri, 19 + } 20 + } 21 + 22 + pub fn cid(&self) -> Option<Cid> { 23 + match self { 24 + PreparedWrite::Create(w) => Some(w.cid), 25 + PreparedWrite::Update(w) => Some(w.cid), 26 + PreparedWrite::Delete(_) => None, 27 + } 28 + } 29 + 30 + pub fn swap_cid(&self) -> &Option<Cid> { 31 + match self { 32 + PreparedWrite::Create(w) => &w.swap_cid, 33 + PreparedWrite::Update(w) => &w.swap_cid, 34 + PreparedWrite::Delete(w) => &w.swap_cid, 35 + } 36 + } 37 + 38 + pub fn action(&self) -> &WriteOpAction { 39 + match self { 40 + PreparedWrite::Create(w) => &w.action, 41 + PreparedWrite::Update(w) => &w.action, 42 + PreparedWrite::Delete(w) => &w.action, 43 + } 44 + } 45 + 46 + /// TEQ: Add blobs() impl 47 + pub fn blobs(&self) -> Option<&Vec<PreparedBlobRef>> { 48 + match self { 49 + PreparedWrite::Create(w) => Some(&w.blobs), 50 + PreparedWrite::Update(w) => Some(&w.blobs), 51 + PreparedWrite::Delete(_) => None, 52 + } 53 + } 54 + } 55 + 56 + impl From<&PreparedWrite> for CommitAction { 57 + fn from(value: &PreparedWrite) -> Self { 58 + match value { 59 + &PreparedWrite::Create(_) => CommitAction::Create, 60 + &PreparedWrite::Update(_) => CommitAction::Update, 61 + &PreparedWrite::Delete(_) => CommitAction::Delete, 62 + } 63 + } 64 + }
-268
src/repo/block_map.rs
··· 1 - //! BlockMap impl 2 - //! Ref: https://github.com/blacksky-algorithms/rsky/blob/main/rsky-repo/src/block_map.rs 3 - //! blacksky-algorithms/rsky is licensed under the Apache License 2.0 4 - //! Reimplemented here because of conflicting dependencies between atrium and rsky 5 - 6 - use anyhow::Result; 7 - use atrium_repo::Cid; 8 - use serde::{Deserialize, Serialize}; 9 - use sha2::Digest; 10 - use std::collections::{BTreeMap, HashSet}; 11 - use std::str::FromStr; 12 - 13 - /// Ref: https://github.com/blacksky-algorithms/rsky/blob/main/rsky-repo/src/cid_set.rs 14 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 15 - pub(crate) struct CidSet { 16 - pub set: HashSet<String>, 17 - } 18 - impl CidSet { 19 - pub(crate) fn new(arr: Option<Vec<Cid>>) -> Self { 20 - let str_arr: Vec<String> = arr 21 - .unwrap_or(Vec::new()) 22 - .into_iter() 23 - .map(|cid| cid.to_string()) 24 - .collect::<Vec<String>>(); 25 - CidSet { 26 - set: HashSet::from_iter(str_arr), 27 - } 28 - } 29 - 30 - pub(crate) fn add(&mut self, cid: Cid) -> () { 31 - let _ = &self.set.insert(cid.to_string()); 32 - () 33 - } 34 - 35 - pub(crate) fn add_set(&mut self, to_merge: CidSet) -> () { 36 - for cid in to_merge.to_list() { 37 - let _ = &self.add(cid); 38 - } 39 - () 40 - } 41 - 42 - pub(crate) fn subtract_set(&mut self, to_subtract: CidSet) -> () { 43 - for cid in to_subtract.to_list() { 44 - self.delete(cid); 45 - } 46 - () 47 - } 48 - 49 - pub(crate) fn delete(&mut self, cid: Cid) -> () { 50 - self.set.remove(&cid.to_string()); 51 - () 52 - } 53 - 54 - pub(crate) fn has(&self, cid: Cid) -> bool { 55 - self.set.contains(&cid.to_string()) 56 - } 57 - 58 - pub(crate) fn size(&self) -> usize { 59 - self.set.len() 60 - } 61 - 62 - pub(crate) fn clear(mut self) -> () { 63 - self.set.clear(); 64 - () 65 - } 66 - 67 - pub(crate) fn to_list(&self) -> Vec<Cid> { 68 - self.set 69 - .clone() 70 - .into_iter() 71 - .filter_map(|cid| match Cid::from_str(&cid) { 72 - Ok(r) => Some(r), 73 - Err(_) => None, 74 - }) 75 - .collect::<Vec<Cid>>() 76 - } 77 - } 78 - 79 - /// Ref: https://github.com/blacksky-algorithms/rsky/blob/main/rsky-common/src/lib.rs#L57 80 - pub(crate) fn struct_to_cbor<T: Serialize>(obj: &T) -> Result<Vec<u8>> { 81 - Ok(serde_ipld_dagcbor::to_vec(obj)?) 82 - } 83 - 84 - /// Ref: https://github.com/blacksky-algorithms/rsky/blob/37954845d06aaafea2b914d9096a1657abfc8d75/rsky-common/src/ipld.rs 85 - /// Create a CID for CBOR-encoded data 86 - pub(crate) fn cid_for_cbor<T: Serialize>(data: &T) -> Result<Cid> { 87 - let bytes = struct_to_cbor(data)?; 88 - let multihash = atrium_repo::Multihash::wrap( 89 - atrium_repo::blockstore::SHA2_256, 90 - &sha2::Sha256::digest(&bytes), 91 - ) 92 - .expect("valid multihash"); 93 - 94 - // Use the constant for DAG_CBOR (0x71) directly instead of converting from DagCborCodec 95 - Ok(Cid::new_v1(0x71, multihash)) 96 - } 97 - 98 - /// Create a CID from a SHA-256 hash with the specified codec 99 - pub(crate) fn sha256_to_cid(hash: Vec<u8>, codec: u64) -> Cid { 100 - let multihash = atrium_repo::Multihash::wrap(atrium_repo::blockstore::SHA2_256, &hash) 101 - .expect("valid multihash"); 102 - 103 - Cid::new_v1(codec, multihash) 104 - } 105 - 106 - /// Create a CID from a raw SHA-256 hash (using raw codec 0x55) 107 - pub(crate) fn sha256_raw_to_cid(hash: Vec<u8>) -> Cid { 108 - sha256_to_cid(hash, 0x55) // 0x55 is the codec for raw 109 - } 110 - 111 - /// Ref: https://github.com/blacksky-algorithms/rsky/blob/main/rsky-repo/src/types.rs#L436 112 - pub(crate) type CarBlock = CidAndBytes; 113 - pub(crate) struct CidAndBytes { 114 - pub cid: Cid, 115 - pub bytes: Vec<u8>, 116 - } 117 - 118 - // Thinly wraps a Vec<u8> 119 - // The #[serde(transparent)] attribute ensures that during (de)serialization 120 - // this newtype is treated the same as the underlying Vec<u8>. 121 - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 122 - #[serde(transparent)] 123 - pub(crate) struct Bytes(#[serde(with = "serde_bytes")] pub Vec<u8>); 124 - 125 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 126 - pub(crate) struct BlockMap { 127 - pub map: BTreeMap<String, Bytes>, 128 - } 129 - 130 - impl BlockMap { 131 - pub(crate) fn new() -> Self { 132 - BlockMap { 133 - map: BTreeMap::new(), 134 - } 135 - } 136 - 137 - pub(crate) fn add<T: Serialize>(&mut self, value: T) -> Result<Cid> { 138 - let cid = cid_for_cbor(&value)?; 139 - self.set( 140 - cid, 141 - struct_to_cbor(&value)?, //bytes 142 - ); 143 - Ok(cid) 144 - } 145 - 146 - pub(crate) fn set(&mut self, cid: Cid, bytes: Vec<u8>) -> () { 147 - self.map.insert(cid.to_string(), Bytes(bytes)); 148 - () 149 - } 150 - 151 - pub(crate) fn get(&self, cid: Cid) -> Option<&Vec<u8>> { 152 - self.map.get(&cid.to_string()).map(|bytes| &bytes.0) 153 - } 154 - pub(crate) fn delete(&mut self, cid: Cid) -> Result<()> { 155 - self.map.remove(&cid.to_string()); 156 - Ok(()) 157 - } 158 - 159 - pub(crate) fn get_many(&mut self, cids: Vec<Cid>) -> Result<BlocksAndMissing> { 160 - let mut missing: Vec<Cid> = Vec::new(); 161 - let mut blocks = BlockMap::new(); 162 - for cid in cids { 163 - let got = self.map.get(&cid.to_string()).map(|bytes| &bytes.0); 164 - if let Some(bytes) = got { 165 - blocks.set(cid, bytes.clone()); 166 - } else { 167 - missing.push(cid); 168 - } 169 - } 170 - Ok(BlocksAndMissing { blocks, missing }) 171 - } 172 - 173 - pub(crate) fn has(&self, cid: Cid) -> bool { 174 - self.map.contains_key(&cid.to_string()) 175 - } 176 - 177 - pub(crate) fn clear(&mut self) -> () { 178 - self.map.clear() 179 - } 180 - 181 - // Not really using. Issues with closures 182 - pub(crate) fn for_each(&self, cb: impl Fn(&Vec<u8>, Cid) -> ()) -> Result<()> { 183 - for (key, val) in self.map.iter() { 184 - cb(&val.0, Cid::from_str(&key)?); 185 - } 186 - Ok(()) 187 - } 188 - 189 - pub(crate) fn entries(&self) -> Result<Vec<CidAndBytes>> { 190 - let mut entries: Vec<CidAndBytes> = Vec::new(); 191 - for (cid, bytes) in self.map.iter() { 192 - entries.push(CidAndBytes { 193 - cid: Cid::from_str(cid)?, 194 - bytes: bytes.0.clone(), 195 - }); 196 - } 197 - Ok(entries) 198 - } 199 - 200 - pub(crate) fn cids(&self) -> Result<Vec<Cid>> { 201 - Ok(self.entries()?.into_iter().map(|e| e.cid).collect()) 202 - } 203 - 204 - pub(crate) fn add_map(&mut self, to_add: BlockMap) -> Result<()> { 205 - let results = for (cid, bytes) in to_add.map.iter() { 206 - self.set(Cid::from_str(cid)?, bytes.0.clone()); 207 - }; 208 - Ok(results) 209 - } 210 - 211 - pub(crate) fn size(&self) -> usize { 212 - self.map.len() 213 - } 214 - 215 - pub(crate) fn byte_size(&self) -> Result<usize> { 216 - let mut size = 0; 217 - for (_, bytes) in self.map.iter() { 218 - size += bytes.0.len(); 219 - } 220 - Ok(size) 221 - } 222 - 223 - pub(crate) fn equals(&self, other: BlockMap) -> Result<bool> { 224 - if self.size() != other.size() { 225 - return Ok(false); 226 - } 227 - for entry in self.entries()? { 228 - let other_bytes = other.get(entry.cid); 229 - if let Some(o) = other_bytes { 230 - if &entry.bytes != o { 231 - return Ok(false); 232 - } 233 - } else { 234 - return Ok(false); 235 - } 236 - } 237 - Ok(true) 238 - } 239 - } 240 - 241 - // Helper function for the iterator conversion. 242 - fn to_cid_and_bytes((cid_str, bytes): (String, Bytes)) -> CidAndBytes { 243 - // We assume the key is always valid; otherwise, you could handle the error. 244 - let cid = Cid::from_str(&cid_str).expect("BlockMap contains an invalid CID string"); 245 - CidAndBytes { 246 - cid, 247 - bytes: bytes.0, 248 - } 249 - } 250 - 251 - impl IntoIterator for BlockMap { 252 - type Item = CidAndBytes; 253 - // Using the iterator returned by BTreeMap's into_iter, then mapping with a function pointer. 254 - type IntoIter = std::iter::Map< 255 - std::collections::btree_map::IntoIter<String, Bytes>, 256 - fn((String, Bytes)) -> CidAndBytes, 257 - >; 258 - 259 - fn into_iter(self) -> Self::IntoIter { 260 - self.map.into_iter().map(to_cid_and_bytes) 261 - } 262 - } 263 - 264 - #[derive(Debug)] 265 - pub(crate) struct BlocksAndMissing { 266 - pub blocks: BlockMap, 267 - pub missing: Vec<Cid>, 268 - }
-3
src/repo/mod.rs
··· 1 - pub(crate) mod block_map; 2 - pub(crate) mod storage; 3 - pub(crate) mod types;
-131
src/repo/storage/mod.rs
··· 1 - //! ReadableBlockstore for managing blocks in the repository. 2 - 3 - use crate::repo::block_map::{BlockMap, MissingBlockError}; 4 - use crate::repo::util::{cbor_to_lex_record, parse_obj_by_def}; 5 - use anyhow::{Context, Result}; 6 - use atrium_repo::Cid; 7 - use std::collections::HashMap; 8 - use std::sync::Arc; 9 - 10 - /// Trait for a readable blockstore. 11 - pub(crate) trait ReadableBlockstore { 12 - /// Get the raw bytes for a given CID. 13 - fn get_bytes(&self, cid: &Cid) -> Result<Option<Vec<u8>>>; 14 - 15 - /// Check if a block exists for a given CID. 16 - fn has(&self, cid: &Cid) -> Result<bool>; 17 - 18 - /// Get multiple blocks for a list of CIDs. 19 - fn get_blocks(&self, cids: &[Cid]) -> Result<(BlockMap, Vec<Cid>)>; 20 - 21 - /// Attempt to read an object by CID and definition. 22 - fn attempt_read<T>(&self, cid: &Cid, def: &str) -> Result<Option<(T, Vec<u8>)>> 23 - where 24 - T: serde::de::DeserializeOwned; 25 - 26 - /// Read an object and its raw bytes by CID and definition. 27 - fn read_obj_and_bytes<T>(&self, cid: &Cid, def: &str) -> Result<(T, Vec<u8>)> 28 - where 29 - T: serde::de::DeserializeOwned; 30 - 31 - /// Read an object by CID and definition. 32 - fn read_obj<T>(&self, cid: &Cid, def: &str) -> Result<T> 33 - where 34 - T: serde::de::DeserializeOwned; 35 - 36 - /// Attempt to read a record by CID. 37 - fn attempt_read_record(&self, cid: &Cid) -> Result<Option<RepoRecord>>; 38 - 39 - /// Read a record by CID. 40 - fn read_record(&self, cid: &Cid) -> Result<RepoRecord>; 41 - } 42 - 43 - /// Concrete implementation of the ReadableBlockstore. 44 - pub(crate) struct InMemoryBlockstore { 45 - blocks: HashMap<Cid, Vec<u8>>, 46 - } 47 - 48 - impl InMemoryBlockstore { 49 - /// Create a new in-memory blockstore. 50 - pub fn new() -> Self { 51 - Self { 52 - blocks: HashMap::new(), 53 - } 54 - } 55 - 56 - /// Add a block to the blockstore. 57 - pub fn add_block(&mut self, cid: Cid, bytes: Vec<u8>) { 58 - self.blocks.insert(cid, bytes); 59 - } 60 - } 61 - 62 - impl ReadableBlockstore for InMemoryBlockstore { 63 - fn get_bytes(&self, cid: &Cid) -> Result<Option<Vec<u8>>> { 64 - Ok(self.blocks.get(cid).cloned()) 65 - } 66 - 67 - fn has(&self, cid: &Cid) -> Result<bool> { 68 - Ok(self.blocks.contains_key(cid)) 69 - } 70 - 71 - fn get_blocks(&self, cids: &[Cid]) -> Result<(BlockMap, Vec<Cid>)> { 72 - let mut blocks = BlockMap::new(); 73 - let mut missing = Vec::new(); 74 - 75 - for cid in cids { 76 - if let Some(bytes) = self.blocks.get(cid) { 77 - blocks.insert(*cid, bytes.clone()); 78 - } else { 79 - missing.push(*cid); 80 - } 81 - } 82 - 83 - Ok((blocks, missing)) 84 - } 85 - 86 - fn attempt_read<T>(&self, cid: &Cid, def: &str) -> Result<Option<(T, Vec<u8>)>> 87 - where 88 - T: serde::de::DeserializeOwned, 89 - { 90 - if let Some(bytes) = self.get_bytes(cid)? { 91 - let obj = parse_obj_by_def(&bytes, cid, def)?; 92 - Ok(Some((obj, bytes))) 93 - } else { 94 - Ok(None) 95 - } 96 - } 97 - 98 - fn read_obj_and_bytes<T>(&self, cid: &Cid, def: &str) -> Result<(T, Vec<u8>)> 99 - where 100 - T: serde::de::DeserializeOwned, 101 - { 102 - if let Some((obj, bytes)) = self.attempt_read(cid, def)? { 103 - Ok((obj, bytes)) 104 - } else { 105 - Err(MissingBlockError::new(*cid, def).into()) 106 - } 107 - } 108 - 109 - fn read_obj<T>(&self, cid: &Cid, def: &str) -> Result<T> 110 - where 111 - T: serde::de::DeserializeOwned, 112 - { 113 - let (obj, _) = self.read_obj_and_bytes(cid, def)?; 114 - Ok(obj) 115 - } 116 - 117 - fn attempt_read_record(&self, cid: &Cid) -> Result<Option<RepoRecord>> { 118 - match self.read_record(cid) { 119 - Ok(record) => Ok(Some(record)), 120 - Err(_) => Ok(None), 121 - } 122 - } 123 - 124 - fn read_record(&self, cid: &Cid) -> Result<RepoRecord> { 125 - if let Some(bytes) = self.get_bytes(cid)? { 126 - cbor_to_lex_record(&bytes) 127 - } else { 128 - Err(MissingBlockError::new(*cid, "RepoRecord").into()) 129 - } 130 - } 131 - }
-1151
src/repo/types.rs
··· 1 - //! Ref: https://github.com/blacksky-algorithms/rsky/blob/main/rsky-repo/src/types.rs 2 - //! blacksky-algorithms/rsky is licensed under the Apache License 2.0 3 - //! Reimplemented here because of conflicting dependencies between atrium and rsky 4 - 5 - use crate::repo::block_map::{BlockMap, CidSet}; 6 - use anyhow::{Result, bail}; 7 - use atrium_api::types::BlobRef; 8 - use atrium_repo::Cid; 9 - use ipld_core::ipld::Ipld; 10 - use rsky_syntax::aturi::AtUri; 11 - use serde::{Deserialize, Serialize}; 12 - use std::collections::BTreeMap; 13 - use std::fmt; 14 - use std::fmt::Debug; 15 - 16 - // Repo nodes 17 - // --------------- 18 - 19 - // IMPORTANT: Ordering of these fields must not be changed 20 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 21 - pub struct UnsignedCommit { 22 - pub did: String, 23 - pub rev: String, 24 - pub data: Cid, 25 - // `prev` added for backwards compatibility with v2, no requirement of keeping around history 26 - pub prev: Option<Cid>, 27 - pub version: u8, // Should be 3 28 - } 29 - 30 - // IMPORTANT: Ordering of these fields must not be changed 31 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 32 - pub struct Commit { 33 - pub did: String, 34 - pub rev: String, 35 - pub data: Cid, 36 - pub prev: Option<Cid>, 37 - pub version: u8, // Should be 3 38 - #[serde(with = "serde_bytes")] 39 - pub sig: Vec<u8>, 40 - } 41 - 42 - // IMPORTANT: Ordering of these fields must not be changed 43 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 44 - pub struct LegacyV2Commit { 45 - pub did: String, 46 - pub rev: Option<String>, 47 - pub data: Cid, 48 - pub prev: Option<Cid>, 49 - pub version: u8, // Should be 2 50 - #[serde(with = "serde_bytes")] 51 - pub sig: Vec<u8>, 52 - } 53 - 54 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 55 - #[serde(untagged)] 56 - pub enum VersionedCommit { 57 - Commit(Commit), 58 - LegacyV2Commit(LegacyV2Commit), 59 - } 60 - 61 - impl VersionedCommit { 62 - pub fn data(&self) -> Cid { 63 - match self { 64 - VersionedCommit::Commit(c) => c.data, 65 - VersionedCommit::LegacyV2Commit(c) => c.data, 66 - } 67 - } 68 - 69 - pub fn did(&self) -> &String { 70 - match self { 71 - VersionedCommit::Commit(c) => &c.did, 72 - VersionedCommit::LegacyV2Commit(c) => &c.did, 73 - } 74 - } 75 - 76 - pub fn version(&self) -> u8 { 77 - match self { 78 - VersionedCommit::Commit(c) => c.version, 79 - VersionedCommit::LegacyV2Commit(c) => c.version, 80 - } 81 - } 82 - } 83 - 84 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 85 - #[serde(untagged)] 86 - pub enum Lex { 87 - Ipld(Ipld), 88 - Blob(BlobRef), 89 - List(Vec<Lex>), 90 - Map(BTreeMap<String, Lex>), 91 - } 92 - 93 - // Repo Operations 94 - // --------------- 95 - 96 - pub type RepoRecord = BTreeMap<String, Lex>; 97 - 98 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 99 - pub struct BlobConstraint { 100 - pub max_size: Option<usize>, 101 - pub accept: Option<Vec<String>>, 102 - } 103 - 104 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 105 - pub struct PreparedBlobRef { 106 - pub cid: Cid, 107 - pub mime_type: String, 108 - pub constraints: BlobConstraint, 109 - } 110 - 111 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 112 - pub struct PreparedCreateOrUpdate { 113 - pub action: WriteOpAction, 114 - pub uri: String, 115 - pub cid: Cid, 116 - pub swap_cid: Option<Cid>, 117 - pub record: RepoRecord, 118 - pub blobs: Vec<PreparedBlobRef>, 119 - } 120 - 121 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 122 - pub struct PreparedDelete { 123 - pub action: WriteOpAction, 124 - pub uri: String, 125 - pub swap_cid: Option<Cid>, 126 - } 127 - 128 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 129 - pub enum PreparedWrite { 130 - Create(PreparedCreateOrUpdate), 131 - Update(PreparedCreateOrUpdate), 132 - Delete(PreparedDelete), 133 - } 134 - 135 - impl PreparedWrite { 136 - pub fn uri(&self) -> &String { 137 - match self { 138 - PreparedWrite::Create(w) => &w.uri, 139 - PreparedWrite::Update(w) => &w.uri, 140 - PreparedWrite::Delete(w) => &w.uri, 141 - } 142 - } 143 - 144 - pub fn cid(&self) -> Option<Cid> { 145 - match self { 146 - PreparedWrite::Create(w) => Some(w.cid), 147 - PreparedWrite::Update(w) => Some(w.cid), 148 - PreparedWrite::Delete(_) => None, 149 - } 150 - } 151 - 152 - pub fn swap_cid(&self) -> &Option<Cid> { 153 - match self { 154 - PreparedWrite::Create(w) => &w.swap_cid, 155 - PreparedWrite::Update(w) => &w.swap_cid, 156 - PreparedWrite::Delete(w) => &w.swap_cid, 157 - } 158 - } 159 - 160 - pub fn action(&self) -> &WriteOpAction { 161 - match self { 162 - PreparedWrite::Create(w) => &w.action, 163 - PreparedWrite::Update(w) => &w.action, 164 - PreparedWrite::Delete(w) => &w.action, 165 - } 166 - } 167 - 168 - /// TEQ: Add blobs() impl 169 - pub fn blobs(&self) -> Option<&Vec<PreparedBlobRef>> { 170 - match self { 171 - PreparedWrite::Create(w) => Some(&w.blobs), 172 - PreparedWrite::Update(w) => Some(&w.blobs), 173 - PreparedWrite::Delete(_) => None, 174 - } 175 - } 176 - } 177 - 178 - impl From<&PreparedWrite> for CommitAction { 179 - fn from(value: &PreparedWrite) -> Self { 180 - match value { 181 - &PreparedWrite::Create(_) => CommitAction::Create, 182 - &PreparedWrite::Update(_) => CommitAction::Update, 183 - &PreparedWrite::Delete(_) => CommitAction::Delete, 184 - } 185 - } 186 - } 187 - 188 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 189 - #[serde(rename_all = "lowercase")] 190 - pub enum WriteOpAction { 191 - Create, 192 - Update, 193 - Delete, 194 - } 195 - 196 - impl fmt::Display for WriteOpAction { 197 - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 198 - // Match each variant and write its lowercase representation. 199 - match self { 200 - WriteOpAction::Create => write!(f, "create"), 201 - WriteOpAction::Update => write!(f, "update"), 202 - WriteOpAction::Delete => write!(f, "delete"), 203 - } 204 - } 205 - } 206 - 207 - impl From<WriteOpAction> for CommitAction { 208 - fn from(value: WriteOpAction) -> Self { 209 - match value { 210 - WriteOpAction::Create => CommitAction::Create, 211 - WriteOpAction::Update => CommitAction::Update, 212 - WriteOpAction::Delete => CommitAction::Delete, 213 - } 214 - } 215 - } 216 - 217 - impl From<&WriteOpAction> for CommitAction { 218 - fn from(value: &WriteOpAction) -> Self { 219 - match value { 220 - &WriteOpAction::Create => CommitAction::Create, 221 - &WriteOpAction::Update => CommitAction::Update, 222 - &WriteOpAction::Delete => CommitAction::Delete, 223 - } 224 - } 225 - } 226 - 227 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 228 - pub struct RecordCreateOrUpdateOp { 229 - pub action: WriteOpAction, 230 - pub collection: String, 231 - pub rkey: String, 232 - pub record: RepoRecord, 233 - } 234 - 235 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 236 - pub struct RecordDeleteOp { 237 - pub action: WriteOpAction, 238 - pub collection: String, 239 - pub rkey: String, 240 - } 241 - 242 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 243 - pub enum RecordWriteOp { 244 - Create(RecordCreateOrUpdateOp), 245 - Update(RecordCreateOrUpdateOp), 246 - Delete(RecordDeleteOp), 247 - } 248 - 249 - impl RecordWriteOp { 250 - pub fn collection(&self) -> String { 251 - match self { 252 - RecordWriteOp::Create(r) => r.collection.clone(), 253 - RecordWriteOp::Update(r) => r.collection.clone(), 254 - RecordWriteOp::Delete(r) => r.collection.clone(), 255 - } 256 - } 257 - 258 - pub fn rkey(&self) -> String { 259 - match self { 260 - RecordWriteOp::Create(r) => r.rkey.clone(), 261 - RecordWriteOp::Update(r) => r.rkey.clone(), 262 - RecordWriteOp::Delete(r) => r.rkey.clone(), 263 - } 264 - } 265 - } 266 - 267 - pub fn create_write_to_op(write: PreparedCreateOrUpdate) -> Result<RecordWriteOp> { 268 - let write_at_uri: AtUri = write.uri.try_into()?; 269 - Ok(RecordWriteOp::Create { 270 - 0: RecordCreateOrUpdateOp { 271 - action: WriteOpAction::Create, 272 - collection: write_at_uri.get_collection(), 273 - rkey: write_at_uri.get_rkey(), 274 - record: write.record, 275 - }, 276 - }) 277 - } 278 - 279 - pub fn update_write_to_op(write: PreparedCreateOrUpdate) -> Result<RecordWriteOp> { 280 - let write_at_uri: AtUri = write.uri.try_into()?; 281 - Ok(RecordWriteOp::Update { 282 - 0: RecordCreateOrUpdateOp { 283 - action: WriteOpAction::Update, 284 - collection: write_at_uri.get_collection(), 285 - rkey: write_at_uri.get_rkey(), 286 - record: write.record, 287 - }, 288 - }) 289 - } 290 - 291 - pub fn delete_write_to_op(write: PreparedDelete) -> Result<RecordWriteOp> { 292 - let write_at_uri: AtUri = write.uri.try_into()?; 293 - Ok(RecordWriteOp::Delete { 294 - 0: RecordDeleteOp { 295 - action: WriteOpAction::Delete, 296 - collection: write_at_uri.get_collection(), 297 - rkey: write_at_uri.get_rkey(), 298 - }, 299 - }) 300 - } 301 - 302 - pub fn write_to_op(write: PreparedWrite) -> Result<RecordWriteOp> { 303 - match write { 304 - PreparedWrite::Create(c) => create_write_to_op(c), 305 - PreparedWrite::Update(u) => update_write_to_op(u), 306 - PreparedWrite::Delete(d) => delete_write_to_op(d), 307 - } 308 - } 309 - 310 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 311 - pub enum RecordWriteEnum { 312 - List(Vec<RecordWriteOp>), 313 - Single(RecordWriteOp), 314 - } 315 - 316 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 317 - pub struct RecordCreateOrDeleteDescript { 318 - pub action: WriteOpAction, 319 - pub collection: String, 320 - pub rkey: String, 321 - pub cid: Cid, 322 - } 323 - 324 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 325 - pub struct RecordUpdateDescript { 326 - pub action: WriteOpAction, 327 - pub collection: String, 328 - pub rkey: String, 329 - pub prev: Cid, 330 - pub cid: Cid, 331 - } 332 - 333 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 334 - pub enum RecordWriteDescript { 335 - Create(RecordCreateOrDeleteDescript), 336 - Update(RecordUpdateDescript), 337 - Delete(RecordCreateOrDeleteDescript), 338 - } 339 - 340 - impl RecordWriteDescript { 341 - pub fn action(&self) -> String { 342 - match self { 343 - RecordWriteDescript::Create(r) => r.action.to_string(), 344 - RecordWriteDescript::Update(r) => r.action.to_string(), 345 - RecordWriteDescript::Delete(r) => r.action.to_string(), 346 - } 347 - } 348 - } 349 - 350 - pub type WriteLog = Vec<Vec<RecordWriteDescript>>; 351 - 352 - // Updates/Commits 353 - // --------------- 354 - 355 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 356 - pub struct CommitData { 357 - pub cid: Cid, 358 - pub rev: String, 359 - pub since: Option<String>, 360 - pub prev: Option<Cid>, 361 - pub new_blocks: BlockMap, 362 - pub relevant_blocks: BlockMap, 363 - pub removed_cids: CidSet, 364 - } 365 - 366 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 367 - pub enum CommitAction { 368 - Create, 369 - Update, 370 - Delete, 371 - } 372 - 373 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 374 - pub struct CommitOp { 375 - pub action: CommitAction, 376 - pub path: String, 377 - pub cid: Option<Cid>, 378 - pub prev: Option<Cid>, 379 - } 380 - 381 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 382 - pub struct CommitDataWithOps { 383 - #[serde(flatten)] 384 - pub commit_data: CommitData, 385 - pub ops: Vec<CommitOp>, 386 - pub prev_data: Option<Cid>, 387 - } 388 - 389 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 390 - pub struct SyncEvtData { 391 - pub cid: Cid, 392 - pub rev: String, 393 - pub blocks: BlockMap, 394 - } 395 - 396 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 397 - pub struct RepoUpdate { 398 - pub cid: Cid, 399 - pub rev: String, 400 - pub since: Option<String>, 401 - pub prev: Option<Cid>, 402 - pub new_blocks: BlockMap, 403 - pub removed_cids: CidSet, 404 - pub ops: Vec<RecordWriteOp>, 405 - } 406 - 407 - pub type CollectionContents = BTreeMap<String, RepoRecord>; 408 - pub type RepoContents = BTreeMap<String, CollectionContents>; 409 - 410 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 411 - pub struct RepoRecordWithCid { 412 - pub cid: Cid, 413 - pub value: RepoRecord, 414 - } 415 - pub type CollectionContentsWithCids = BTreeMap<String, RepoRecordWithCid>; 416 - pub type RepoContentsWithCids = BTreeMap<String, CollectionContentsWithCids>; 417 - 418 - pub type DatastoreContents = BTreeMap<String, Cid>; 419 - 420 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 421 - pub struct RecordPath { 422 - pub collection: String, 423 - pub rkey: String, 424 - } 425 - 426 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 427 - pub struct RecordClaim { 428 - pub collection: String, 429 - pub rkey: String, 430 - pub record: Option<RepoRecord>, 431 - } 432 - 433 - // Sync 434 - // --------------- 435 - 436 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 437 - pub struct VerifiedDiff { 438 - pub writes: Vec<RecordWriteDescript>, 439 - pub commit: CommitData, 440 - } 441 - 442 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 443 - pub struct VerifiedRepo { 444 - pub creates: Vec<RecordCreateOrDeleteDescript>, 445 - pub commit: CommitData, 446 - } 447 - 448 - pub type CarBlock = CidAndBytes; 449 - 450 - pub struct CidAndBytes { 451 - pub cid: Cid, 452 - pub bytes: Vec<u8>, 453 - } 454 - 455 - #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] 456 - pub enum Ids { 457 - ComAtprotoAdminDefs, 458 - ComAtprotoAdminDeleteAccount, 459 - ComAtprotoAdminDisableAccountInvites, 460 - ComAtprotoAdminDisableInviteCodes, 461 - ComAtprotoAdminEnableAccountInvites, 462 - ComAtprotoAdminGetAccountInfo, 463 - ComAtprotoAdminGetAccountInfos, 464 - ComAtprotoAdminGetInviteCodes, 465 - ComAtprotoAdminGetSubjectStatus, 466 - ComAtprotoAdminSendEmail, 467 - ComAtprotoAdminUpdateAccountEmail, 468 - ComAtprotoAdminUpdateAccountHandle, 469 - ComAtprotoAdminUpdateAccountPassword, 470 - ComAtprotoAdminUpdateSubjectStatus, 471 - ComAtprotoIdentityGetRecommendedDidCredentials, 472 - ComAtprotoIdentityRequestPlcOperationSignature, 473 - ComAtprotoIdentityResolveHandle, 474 - ComAtprotoIdentitySignPlcOperation, 475 - ComAtprotoIdentitySubmitPlcOperation, 476 - ComAtprotoIdentityUpdateHandle, 477 - ComAtprotoLabelDefs, 478 - ComAtprotoLabelQueryLabels, 479 - ComAtprotoLabelSubscribeLabels, 480 - ComAtprotoModerationCreateReport, 481 - ComAtprotoModerationDefs, 482 - ComAtprotoRepoApplyWrites, 483 - ComAtprotoRepoCreateRecord, 484 - ComAtprotoRepoDeleteRecord, 485 - ComAtprotoRepoDescribeRepo, 486 - ComAtprotoRepoGetRecord, 487 - ComAtprotoRepoImportRepo, 488 - ComAtprotoRepoListMissingBlobs, 489 - ComAtprotoRepoListRecords, 490 - ComAtprotoRepoPutRecord, 491 - ComAtprotoRepoStrongRef, 492 - ComAtprotoRepoUploadBlob, 493 - ComAtprotoServerActivateAccount, 494 - ComAtprotoServerCheckAccountStatus, 495 - ComAtprotoServerConfirmEmail, 496 - ComAtprotoServerCreateAccount, 497 - ComAtprotoServerCreateAppPassword, 498 - ComAtprotoServerCreateInviteCode, 499 - ComAtprotoServerCreateInviteCodes, 500 - ComAtprotoServerCreateSession, 501 - ComAtprotoServerDeactivateAccount, 502 - ComAtprotoServerDefs, 503 - ComAtprotoServerDeleteAccount, 504 - ComAtprotoServerDeleteSession, 505 - ComAtprotoServerDescribeServer, 506 - ComAtprotoServerGetAccountInviteCodes, 507 - ComAtprotoServerGetServiceAuth, 508 - ComAtprotoServerGetSession, 509 - ComAtprotoServerListAppPasswords, 510 - ComAtprotoServerRefreshSession, 511 - ComAtprotoServerRequestAccountDelete, 512 - ComAtprotoServerRequestEmailConfirmation, 513 - ComAtprotoServerRequestEmailUpdate, 514 - ComAtprotoServerRequestPasswordReset, 515 - ComAtprotoServerReserveSigningKey, 516 - ComAtprotoServerResetPassword, 517 - ComAtprotoServerRevokeAppPassword, 518 - ComAtprotoServerUpdateEmail, 519 - ComAtprotoSyncGetBlob, 520 - ComAtprotoSyncGetBlocks, 521 - ComAtprotoSyncGetCheckout, 522 - ComAtprotoSyncGetHead, 523 - ComAtprotoSyncGetLatestCommit, 524 - ComAtprotoSyncGetRecord, 525 - ComAtprotoSyncGetRepo, 526 - ComAtprotoSyncListBlobs, 527 - ComAtprotoSyncListRepos, 528 - ComAtprotoSyncNotifyOfUpdate, 529 - ComAtprotoSyncRequestCrawl, 530 - ComAtprotoSyncSubscribeRepos, 531 - ComAtprotoTempCheckSignupQueue, 532 - ComAtprotoTempFetchLabels, 533 - ComAtprotoTempRequestPhoneVerification, 534 - AppBskyActorDefs, 535 - AppBskyActorGetPreferences, 536 - AppBskyActorGetProfile, 537 - AppBskyActorGetProfiles, 538 - AppBskyActorGetSuggestions, 539 - AppBskyActorProfile, 540 - AppBskyActorPutPreferences, 541 - AppBskyActorSearchActors, 542 - AppBskyActorSearchActorsTypeahead, 543 - AppBskyEmbedExternal, 544 - AppBskyEmbedImages, 545 - AppBskyEmbedRecord, 546 - AppBskyEmbedRecordWithMedia, 547 - AppBskyFeedDefs, 548 - AppBskyFeedDescribeFeedGenerator, 549 - AppBskyFeedGenerator, 550 - AppBskyFeedGetActorFeeds, 551 - AppBskyFeedGetActorLikes, 552 - AppBskyFeedGetAuthorFeed, 553 - AppBskyFeedGetFeed, 554 - AppBskyFeedGetFeedGenerator, 555 - AppBskyFeedGetFeedGenerators, 556 - AppBskyFeedGetFeedSkeleton, 557 - AppBskyFeedGetLikes, 558 - AppBskyFeedGetListFeed, 559 - AppBskyFeedGetPostThread, 560 - AppBskyFeedGetPosts, 561 - AppBskyFeedGetRepostedBy, 562 - AppBskyFeedGetSuggestedFeeds, 563 - AppBskyFeedGetTimeline, 564 - AppBskyFeedLike, 565 - AppBskyFeedPost, 566 - AppBskyFeedRepost, 567 - AppBskyFeedSearchPosts, 568 - AppBskyFeedThreadgate, 569 - AppBskyGraphBlock, 570 - AppBskyGraphDefs, 571 - AppBskyGraphFollow, 572 - AppBskyGraphGetBlocks, 573 - AppBskyGraphGetFollowers, 574 - AppBskyGraphGetFollows, 575 - AppBskyGraphGetList, 576 - AppBskyGraphGetListBlocks, 577 - AppBskyGraphGetListMutes, 578 - AppBskyGraphGetLists, 579 - AppBskyGraphGetMutes, 580 - AppBskyGraphGetRelationships, 581 - AppBskyGraphGetSuggestedFollowsByActor, 582 - AppBskyGraphList, 583 - AppBskyGraphListblock, 584 - AppBskyGraphListitem, 585 - AppBskyGraphMuteActor, 586 - AppBskyGraphMuteActorList, 587 - AppBskyGraphUnmuteActor, 588 - AppBskyGraphUnmuteActorList, 589 - AppBskyLabelerDefs, 590 - AppBskyLabelerGetServices, 591 - AppBskyLabelerService, 592 - AppBskyNotificationGetUnreadCount, 593 - AppBskyNotificationListNotifications, 594 - AppBskyNotificationRegisterPush, 595 - AppBskyNotificationUpdateSeen, 596 - AppBskyRichtextFacet, 597 - AppBskyUnspeccedDefs, 598 - AppBskyUnspeccedGetPopularFeedGenerators, 599 - AppBskyUnspeccedGetTaggedSuggestions, 600 - AppBskyUnspeccedSearchActorsSkeleton, 601 - AppBskyUnspeccedSearchPostsSkeleton, 602 - ToolsOzoneCommunicationCreateTemplate, 603 - ToolsOzoneCommunicationDefs, 604 - ToolsOzoneCommunicationDeleteTemplate, 605 - ToolsOzoneCommunicationListTemplates, 606 - ToolsOzoneCommunicationUpdateTemplate, 607 - ToolsOzoneModerationDefs, 608 - ToolsOzoneModerationEmitEvent, 609 - ToolsOzoneModerationGetEvent, 610 - ToolsOzoneModerationGetRecord, 611 - ToolsOzoneModerationGetRepo, 612 - ToolsOzoneModerationQueryEvents, 613 - ToolsOzoneModerationQueryStatuses, 614 - ToolsOzoneModerationSearchRepos, 615 - ToolsOzoneServerGetConfig, 616 - ToolsOzoneTeamAddMember, 617 - ToolsOzoneTeamDefs, 618 - ToolsOzoneTeamDeleteMember, 619 - ToolsOzoneTeamListMembers, 620 - ToolsOzoneTeamUpdateMember, 621 - ChatBskyActorDeleteAccount, 622 - ChatBskyActorExportAccountData, 623 - ChatBskyConvoDeleteMessageForSelf, 624 - ChatBskyConvoGetConvo, 625 - ChatBskyConvoGetConvoForMembers, 626 - ChatBskyConvoGetLog, 627 - ChatBskyConvoGetMessages, 628 - ChatBskyConvoLeaveConvo, 629 - ChatBskyConvoListConvos, 630 - ChatBskyConvoMuteConvo, 631 - ChatBskyConvoSendMessage, 632 - ChatBskyConvoSendMessageBatch, 633 - ChatBskyConvoUnmuteConvo, 634 - ChatBskyConvoUpdateRead, 635 - } 636 - 637 - impl Ids { 638 - pub fn as_str(&self) -> &'static str { 639 - match self { 640 - Ids::ComAtprotoAdminDefs => "com.atproto.admin.defs", 641 - Ids::ComAtprotoAdminDeleteAccount => "com.atproto.admin.deleteAccount", 642 - Ids::ComAtprotoAdminDisableAccountInvites => "com.atproto.admin.disableAccountInvites", 643 - Ids::ComAtprotoAdminDisableInviteCodes => "com.atproto.admin.disableInviteCodes", 644 - Ids::ComAtprotoAdminEnableAccountInvites => "com.atproto.admin.enableAccountInvites", 645 - Ids::ComAtprotoAdminGetAccountInfo => "com.atproto.admin.getAccountInfo", 646 - Ids::ComAtprotoAdminGetAccountInfos => "com.atproto.admin.getAccountInfos", 647 - Ids::ComAtprotoAdminGetInviteCodes => "com.atproto.admin.getInviteCodes", 648 - Ids::ComAtprotoAdminGetSubjectStatus => "com.atproto.admin.getSubjectStatus", 649 - Ids::ComAtprotoAdminSendEmail => "com.atproto.admin.sendEmail", 650 - Ids::ComAtprotoAdminUpdateAccountEmail => "com.atproto.admin.updateAccountEmail", 651 - Ids::ComAtprotoAdminUpdateAccountHandle => "com.atproto.admin.updateAccountHandle", 652 - Ids::ComAtprotoAdminUpdateAccountPassword => "com.atproto.admin.updateAccountPassword", 653 - Ids::ComAtprotoAdminUpdateSubjectStatus => "com.atproto.admin.updateSubjectStatus", 654 - Ids::ComAtprotoIdentityGetRecommendedDidCredentials => { 655 - "com.atproto.identity.getRecommendedDidCredentials" 656 - } 657 - Ids::ComAtprotoIdentityRequestPlcOperationSignature => { 658 - "com.atproto.identity.requestPlcOperationSignature" 659 - } 660 - Ids::ComAtprotoIdentityResolveHandle => "com.atproto.identity.resolveHandle", 661 - Ids::ComAtprotoIdentitySignPlcOperation => "com.atproto.identity.signPlcOperation", 662 - Ids::ComAtprotoIdentitySubmitPlcOperation => "com.atproto.identity.submitPlcOperation", 663 - Ids::ComAtprotoIdentityUpdateHandle => "com.atproto.identity.updateHandle", 664 - Ids::ComAtprotoLabelDefs => "com.atproto.label.defs", 665 - Ids::ComAtprotoLabelQueryLabels => "com.atproto.label.queryLabels", 666 - Ids::ComAtprotoLabelSubscribeLabels => "com.atproto.label.subscribeLabels", 667 - Ids::ComAtprotoModerationCreateReport => "com.atproto.moderation.createReport", 668 - Ids::ComAtprotoModerationDefs => "com.atproto.moderation.defs", 669 - Ids::ComAtprotoRepoApplyWrites => "com.atproto.repo.applyWrites", 670 - Ids::ComAtprotoRepoCreateRecord => "com.atproto.repo.createRecord", 671 - Ids::ComAtprotoRepoDeleteRecord => "com.atproto.repo.deleteRecord", 672 - Ids::ComAtprotoRepoDescribeRepo => "com.atproto.repo.describeRepo", 673 - Ids::ComAtprotoRepoGetRecord => "com.atproto.repo.getRecord", 674 - Ids::ComAtprotoRepoImportRepo => "com.atproto.repo.importRepo", 675 - Ids::ComAtprotoRepoListMissingBlobs => "com.atproto.repo.listMissingBlobs", 676 - Ids::ComAtprotoRepoListRecords => "com.atproto.repo.listRecords", 677 - Ids::ComAtprotoRepoPutRecord => "com.atproto.repo.putRecord", 678 - Ids::ComAtprotoRepoStrongRef => "com.atproto.repo.strongRef", 679 - Ids::ComAtprotoRepoUploadBlob => "com.atproto.repo.uploadBlob", 680 - Ids::ComAtprotoServerActivateAccount => "com.atproto.server.activateAccount", 681 - Ids::ComAtprotoServerCheckAccountStatus => "com.atproto.server.checkAccountStatus", 682 - Ids::ComAtprotoServerConfirmEmail => "com.atproto.server.confirmEmail", 683 - Ids::ComAtprotoServerCreateAccount => "com.atproto.server.createAccount", 684 - Ids::ComAtprotoServerCreateAppPassword => "com.atproto.server.createAppPassword", 685 - Ids::ComAtprotoServerCreateInviteCode => "com.atproto.server.createInviteCode", 686 - Ids::ComAtprotoServerCreateInviteCodes => "com.atproto.server.createInviteCodes", 687 - Ids::ComAtprotoServerCreateSession => "com.atproto.server.createSession", 688 - Ids::ComAtprotoServerDeactivateAccount => "com.atproto.server.deactivateAccount", 689 - Ids::ComAtprotoServerDefs => "com.atproto.server.defs", 690 - Ids::ComAtprotoServerDeleteAccount => "com.atproto.server.deleteAccount", 691 - Ids::ComAtprotoServerDeleteSession => "com.atproto.server.deleteSession", 692 - Ids::ComAtprotoServerDescribeServer => "com.atproto.server.describeServer", 693 - Ids::ComAtprotoServerGetAccountInviteCodes => { 694 - "com.atproto.server.getAccountInviteCodes" 695 - } 696 - Ids::ComAtprotoServerGetServiceAuth => "com.atproto.server.getServiceAuth", 697 - Ids::ComAtprotoServerGetSession => "com.atproto.server.getSession", 698 - Ids::ComAtprotoServerListAppPasswords => "com.atproto.server.listAppPasswords", 699 - Ids::ComAtprotoServerRefreshSession => "com.atproto.server.refreshSession", 700 - Ids::ComAtprotoServerRequestAccountDelete => "com.atproto.server.requestAccountDelete", 701 - Ids::ComAtprotoServerRequestEmailConfirmation => { 702 - "com.atproto.server.requestEmailConfirmation" 703 - } 704 - Ids::ComAtprotoServerRequestEmailUpdate => "com.atproto.server.requestEmailUpdate", 705 - Ids::ComAtprotoServerRequestPasswordReset => "com.atproto.server.requestPasswordReset", 706 - Ids::ComAtprotoServerReserveSigningKey => "com.atproto.server.reserveSigningKey", 707 - Ids::ComAtprotoServerResetPassword => "com.atproto.server.resetPassword", 708 - Ids::ComAtprotoServerRevokeAppPassword => "com.atproto.server.revokeAppPassword", 709 - Ids::ComAtprotoServerUpdateEmail => "com.atproto.server.updateEmail", 710 - Ids::ComAtprotoSyncGetBlob => "com.atproto.sync.getBlob", 711 - Ids::ComAtprotoSyncGetBlocks => "com.atproto.sync.getBlocks", 712 - Ids::ComAtprotoSyncGetCheckout => "com.atproto.sync.getCheckout", 713 - Ids::ComAtprotoSyncGetHead => "com.atproto.sync.getHead", 714 - Ids::ComAtprotoSyncGetLatestCommit => "com.atproto.sync.getLatestCommit", 715 - Ids::ComAtprotoSyncGetRecord => "com.atproto.sync.getRecord", 716 - Ids::ComAtprotoSyncGetRepo => "com.atproto.sync.getRepo", 717 - Ids::ComAtprotoSyncListBlobs => "com.atproto.sync.listBlobs", 718 - Ids::ComAtprotoSyncListRepos => "com.atproto.sync.listRepos", 719 - Ids::ComAtprotoSyncNotifyOfUpdate => "com.atproto.sync.notifyOfUpdate", 720 - Ids::ComAtprotoSyncRequestCrawl => "com.atproto.sync.requestCrawl", 721 - Ids::ComAtprotoSyncSubscribeRepos => "com.atproto.sync.subscribeRepos", 722 - Ids::ComAtprotoTempCheckSignupQueue => "com.atproto.temp.checkSignupQueue", 723 - Ids::ComAtprotoTempFetchLabels => "com.atproto.temp.fetchLabels", 724 - Ids::ComAtprotoTempRequestPhoneVerification => { 725 - "com.atproto.temp.requestPhoneVerification" 726 - } 727 - Ids::AppBskyActorDefs => "app.bsky.actor.defs", 728 - Ids::AppBskyActorGetPreferences => "app.bsky.actor.getPreferences", 729 - Ids::AppBskyActorGetProfile => "app.bsky.actor.getProfile", 730 - Ids::AppBskyActorGetProfiles => "app.bsky.actor.getProfiles", 731 - Ids::AppBskyActorGetSuggestions => "app.bsky.actor.getSuggestions", 732 - Ids::AppBskyActorProfile => "app.bsky.actor.profile", 733 - Ids::AppBskyActorPutPreferences => "app.bsky.actor.putPreferences", 734 - Ids::AppBskyActorSearchActors => "app.bsky.actor.searchActors", 735 - Ids::AppBskyActorSearchActorsTypeahead => "app.bsky.actor.searchActorsTypeahead", 736 - Ids::AppBskyEmbedExternal => "app.bsky.embed.external", 737 - Ids::AppBskyEmbedImages => "app.bsky.embed.images", 738 - Ids::AppBskyEmbedRecord => "app.bsky.embed.record", 739 - Ids::AppBskyEmbedRecordWithMedia => "app.bsky.embed.recordWithMedia", 740 - Ids::AppBskyFeedDefs => "app.bsky.feed.defs", 741 - Ids::AppBskyFeedDescribeFeedGenerator => "app.bsky.feed.describeFeedGenerator", 742 - Ids::AppBskyFeedGenerator => "app.bsky.feed.generator", 743 - Ids::AppBskyFeedGetActorFeeds => "app.bsky.feed.getActorFeeds", 744 - Ids::AppBskyFeedGetActorLikes => "app.bsky.feed.getActorLikes", 745 - Ids::AppBskyFeedGetAuthorFeed => "app.bsky.feed.getAuthorFeed", 746 - Ids::AppBskyFeedGetFeed => "app.bsky.feed.getFeed", 747 - Ids::AppBskyFeedGetFeedGenerator => "app.bsky.feed.getFeedGenerator", 748 - Ids::AppBskyFeedGetFeedGenerators => "app.bsky.feed.getFeedGenerators", 749 - Ids::AppBskyFeedGetFeedSkeleton => "app.bsky.feed.getFeedSkeleton", 750 - Ids::AppBskyFeedGetLikes => "app.bsky.feed.getLikes", 751 - Ids::AppBskyFeedGetListFeed => "app.bsky.feed.getListFeed", 752 - Ids::AppBskyFeedGetPostThread => "app.bsky.feed.getPostThread", 753 - Ids::AppBskyFeedGetPosts => "app.bsky.feed.getPosts", 754 - Ids::AppBskyFeedGetRepostedBy => "app.bsky.feed.getRepostedBy", 755 - Ids::AppBskyFeedGetSuggestedFeeds => "app.bsky.feed.getSuggestedFeeds", 756 - Ids::AppBskyFeedGetTimeline => "app.bsky.feed.getTimeline", 757 - Ids::AppBskyFeedLike => "app.bsky.feed.like", 758 - Ids::AppBskyFeedPost => "app.bsky.feed.post", 759 - Ids::AppBskyFeedRepost => "app.bsky.feed.repost", 760 - Ids::AppBskyFeedSearchPosts => "app.bsky.feed.searchPosts", 761 - Ids::AppBskyFeedThreadgate => "app.bsky.feed.threadgate", 762 - Ids::AppBskyGraphBlock => "app.bsky.graph.block", 763 - Ids::AppBskyGraphDefs => "app.bsky.graph.defs", 764 - Ids::AppBskyGraphFollow => "app.bsky.graph.follow", 765 - Ids::AppBskyGraphGetBlocks => "app.bsky.graph.getBlocks", 766 - Ids::AppBskyGraphGetFollowers => "app.bsky.graph.getFollowers", 767 - Ids::AppBskyGraphGetFollows => "app.bsky.graph.getFollows", 768 - Ids::AppBskyGraphGetList => "app.bsky.graph.getList", 769 - Ids::AppBskyGraphGetListBlocks => "app.bsky.graph.getListBlocks", 770 - Ids::AppBskyGraphGetListMutes => "app.bsky.graph.getListMutes", 771 - Ids::AppBskyGraphGetLists => "app.bsky.graph.getLists", 772 - Ids::AppBskyGraphGetMutes => "app.bsky.graph.getMutes", 773 - Ids::AppBskyGraphGetRelationships => "app.bsky.graph.getRelationships", 774 - Ids::AppBskyGraphGetSuggestedFollowsByActor => { 775 - "app.bsky.graph.getSuggestedFollowsByActor" 776 - } 777 - Ids::AppBskyGraphList => "app.bsky.graph.list", 778 - Ids::AppBskyGraphListblock => "app.bsky.graph.listblock", 779 - Ids::AppBskyGraphListitem => "app.bsky.graph.listitem", 780 - Ids::AppBskyGraphMuteActor => "app.bsky.graph.muteActor", 781 - Ids::AppBskyGraphMuteActorList => "app.bsky.graph.muteActorList", 782 - Ids::AppBskyGraphUnmuteActor => "app.bsky.graph.unmuteActor", 783 - Ids::AppBskyGraphUnmuteActorList => "app.bsky.graph.unmuteActorList", 784 - Ids::AppBskyLabelerDefs => "app.bsky.labeler.defs", 785 - Ids::AppBskyLabelerGetServices => "app.bsky.labeler.getServices", 786 - Ids::AppBskyLabelerService => "app.bsky.labeler.service", 787 - Ids::AppBskyNotificationGetUnreadCount => "app.bsky.notification.getUnreadCount", 788 - Ids::AppBskyNotificationListNotifications => "app.bsky.notification.listNotifications", 789 - Ids::AppBskyNotificationRegisterPush => "app.bsky.notification.registerPush", 790 - Ids::AppBskyNotificationUpdateSeen => "app.bsky.notification.updateSeen", 791 - Ids::AppBskyRichtextFacet => "app.bsky.richtext.facet", 792 - Ids::AppBskyUnspeccedDefs => "app.bsky.unspecced.defs", 793 - Ids::AppBskyUnspeccedGetPopularFeedGenerators => { 794 - "app.bsky.unspecced.getPopularFeedGenerators" 795 - } 796 - Ids::AppBskyUnspeccedGetTaggedSuggestions => "app.bsky.unspecced.getTaggedSuggestions", 797 - Ids::AppBskyUnspeccedSearchActorsSkeleton => "app.bsky.unspecced.searchActorsSkeleton", 798 - Ids::AppBskyUnspeccedSearchPostsSkeleton => "app.bsky.unspecced.searchPostsSkeleton", 799 - Ids::ToolsOzoneCommunicationCreateTemplate => { 800 - "tools.ozone.communication.createTemplate" 801 - } 802 - Ids::ToolsOzoneCommunicationDefs => "tools.ozone.communication.defs", 803 - Ids::ToolsOzoneCommunicationDeleteTemplate => { 804 - "tools.ozone.communication.deleteTemplate" 805 - } 806 - Ids::ToolsOzoneCommunicationListTemplates => "tools.ozone.communication.listTemplates", 807 - Ids::ToolsOzoneCommunicationUpdateTemplate => { 808 - "tools.ozone.communication.updateTemplate" 809 - } 810 - Ids::ToolsOzoneModerationDefs => "tools.ozone.moderation.defs", 811 - Ids::ToolsOzoneModerationEmitEvent => "tools.ozone.moderation.emitEvent", 812 - Ids::ToolsOzoneModerationGetEvent => "tools.ozone.moderation.getEvent", 813 - Ids::ToolsOzoneModerationGetRecord => "tools.ozone.moderation.getRecord", 814 - Ids::ToolsOzoneModerationGetRepo => "tools.ozone.moderation.getRepo", 815 - Ids::ToolsOzoneModerationQueryEvents => "tools.ozone.moderation.queryEvents", 816 - Ids::ToolsOzoneModerationQueryStatuses => "tools.ozone.moderation.queryStatuses", 817 - Ids::ToolsOzoneModerationSearchRepos => "tools.ozone.moderation.searchRepos", 818 - Ids::ToolsOzoneServerGetConfig => "tools.ozone.server.getConfig", 819 - Ids::ToolsOzoneTeamAddMember => "tools.ozone.team.addMember", 820 - Ids::ToolsOzoneTeamDefs => "tools.ozone.team.defs", 821 - Ids::ToolsOzoneTeamDeleteMember => "tools.ozone.team.deleteMember", 822 - Ids::ToolsOzoneTeamListMembers => "tools.ozone.team.listMembers", 823 - Ids::ToolsOzoneTeamUpdateMember => "tools.ozone.team.updateMember", 824 - Ids::ChatBskyActorDeleteAccount => "chat.bsky.actor.deleteAccount", 825 - Ids::ChatBskyActorExportAccountData => "chat.bsky.actor.exportAccountData", 826 - Ids::ChatBskyConvoDeleteMessageForSelf => "chat.bsky.convo.deleteMessageForSelf", 827 - Ids::ChatBskyConvoGetConvo => "chat.bsky.convo.getConvo", 828 - Ids::ChatBskyConvoGetConvoForMembers => "chat.bsky.convo.getConvoForMembers", 829 - Ids::ChatBskyConvoGetLog => "chat.bsky.convo.getLog", 830 - Ids::ChatBskyConvoGetMessages => "chat.bsky.convo.getMessages", 831 - Ids::ChatBskyConvoLeaveConvo => "chat.bsky.convo.leaveConvo", 832 - Ids::ChatBskyConvoListConvos => "chat.bsky.convo.listConvos", 833 - Ids::ChatBskyConvoMuteConvo => "chat.bsky.convo.muteConvo", 834 - Ids::ChatBskyConvoSendMessage => "chat.bsky.convo.sendMessage", 835 - Ids::ChatBskyConvoSendMessageBatch => "chat.bsky.convo.sendMessageBatch", 836 - Ids::ChatBskyConvoUnmuteConvo => "chat.bsky.convo.unmuteConvo", 837 - Ids::ChatBskyConvoUpdateRead => "chat.bsky.convo.updateRead", 838 - } 839 - } 840 - 841 - pub fn from_str(s: &str) -> Result<Self> { 842 - match s { 843 - "com.atproto.admin.defs" => Ok(Ids::ComAtprotoAdminDefs), 844 - "com.atproto.admin.deleteAccount" => Ok(Ids::ComAtprotoAdminDeleteAccount), 845 - "com.atproto.admin.disableAccountInvites" => { 846 - Ok(Ids::ComAtprotoAdminDisableAccountInvites) 847 - } 848 - "com.atproto.admin.disableInviteCodes" => Ok(Ids::ComAtprotoAdminDisableInviteCodes), 849 - "com.atproto.admin.enableAccountInvites" => { 850 - Ok(Ids::ComAtprotoAdminEnableAccountInvites) 851 - } 852 - "com.atproto.admin.getAccountInfo" => Ok(Ids::ComAtprotoAdminGetAccountInfo), 853 - "com.atproto.admin.getAccountInfos" => Ok(Ids::ComAtprotoAdminGetAccountInfos), 854 - "com.atproto.admin.getInviteCodes" => Ok(Ids::ComAtprotoAdminGetInviteCodes), 855 - "com.atproto.admin.getSubjectStatus" => Ok(Ids::ComAtprotoAdminGetSubjectStatus), 856 - "com.atproto.admin.sendEmail" => Ok(Ids::ComAtprotoAdminSendEmail), 857 - "com.atproto.admin.updateAccountEmail" => Ok(Ids::ComAtprotoAdminUpdateAccountEmail), 858 - "com.atproto.admin.updateAccountHandle" => Ok(Ids::ComAtprotoAdminUpdateAccountHandle), 859 - "com.atproto.admin.updateAccountPassword" => { 860 - Ok(Ids::ComAtprotoAdminUpdateAccountPassword) 861 - } 862 - "com.atproto.admin.updateSubjectStatus" => Ok(Ids::ComAtprotoAdminUpdateSubjectStatus), 863 - "com.atproto.identity.getRecommendedDidCredentials" => { 864 - Ok(Ids::ComAtprotoIdentityGetRecommendedDidCredentials) 865 - } 866 - "com.atproto.identity.requestPlcOperationSignature" => { 867 - Ok(Ids::ComAtprotoIdentityRequestPlcOperationSignature) 868 - } 869 - "com.atproto.identity.resolveHandle" => Ok(Ids::ComAtprotoIdentityResolveHandle), 870 - "com.atproto.identity.signPlcOperation" => Ok(Ids::ComAtprotoIdentitySignPlcOperation), 871 - "com.atproto.identity.submitPlcOperation" => { 872 - Ok(Ids::ComAtprotoIdentitySubmitPlcOperation) 873 - } 874 - "com.atproto.identity.updateHandle" => Ok(Ids::ComAtprotoIdentityUpdateHandle), 875 - "com.atproto.label.defs" => Ok(Ids::ComAtprotoLabelDefs), 876 - "com.atproto.label.queryLabels" => Ok(Ids::ComAtprotoLabelQueryLabels), 877 - "com.atproto.label.subscribeLabels" => Ok(Ids::ComAtprotoLabelSubscribeLabels), 878 - "com.atproto.moderation.createReport" => Ok(Ids::ComAtprotoModerationCreateReport), 879 - "com.atproto.moderation.defs" => Ok(Ids::ComAtprotoModerationDefs), 880 - "com.atproto.repo.applyWrites" => Ok(Ids::ComAtprotoRepoApplyWrites), 881 - "com.atproto.repo.createRecord" => Ok(Ids::ComAtprotoRepoCreateRecord), 882 - "com.atproto.repo.deleteRecord" => Ok(Ids::ComAtprotoRepoDeleteRecord), 883 - "com.atproto.repo.describeRepo" => Ok(Ids::ComAtprotoRepoDescribeRepo), 884 - "com.atproto.repo.getRecord" => Ok(Ids::ComAtprotoRepoGetRecord), 885 - "com.atproto.repo.importRepo" => Ok(Ids::ComAtprotoRepoImportRepo), 886 - "com.atproto.repo.listMissingBlobs" => Ok(Ids::ComAtprotoRepoListMissingBlobs), 887 - "com.atproto.repo.listRecords" => Ok(Ids::ComAtprotoRepoListRecords), 888 - "com.atproto.repo.putRecord" => Ok(Ids::ComAtprotoRepoPutRecord), 889 - "com.atproto.repo.strongRef" => Ok(Ids::ComAtprotoRepoStrongRef), 890 - "com.atproto.repo.uploadBlob" => Ok(Ids::ComAtprotoRepoUploadBlob), 891 - "com.atproto.server.activateAccount" => Ok(Ids::ComAtprotoServerActivateAccount), 892 - "com.atproto.server.checkAccountStatus" => Ok(Ids::ComAtprotoServerCheckAccountStatus), 893 - "com.atproto.server.confirmEmail" => Ok(Ids::ComAtprotoServerConfirmEmail), 894 - "com.atproto.server.createAccount" => Ok(Ids::ComAtprotoServerCreateAccount), 895 - "com.atproto.server.createAppPassword" => Ok(Ids::ComAtprotoServerCreateAppPassword), 896 - "com.atproto.server.createInviteCode" => Ok(Ids::ComAtprotoServerCreateInviteCode), 897 - "com.atproto.server.createInviteCodes" => Ok(Ids::ComAtprotoServerCreateInviteCodes), 898 - "com.atproto.server.createSession" => Ok(Ids::ComAtprotoServerCreateSession), 899 - "com.atproto.server.deactivateAccount" => Ok(Ids::ComAtprotoServerDeactivateAccount), 900 - "com.atproto.server.defs" => Ok(Ids::ComAtprotoServerDefs), 901 - "com.atproto.server.deleteAccount" => Ok(Ids::ComAtprotoServerDeleteAccount), 902 - "com.atproto.server.deleteSession" => Ok(Ids::ComAtprotoServerDeleteSession), 903 - "com.atproto.server.describeServer" => Ok(Ids::ComAtprotoServerDescribeServer), 904 - "com.atproto.server.getAccountInviteCodes" => { 905 - Ok(Ids::ComAtprotoServerGetAccountInviteCodes) 906 - } 907 - "com.atproto.server.getServiceAuth" => Ok(Ids::ComAtprotoServerGetServiceAuth), 908 - "com.atproto.server.getSession" => Ok(Ids::ComAtprotoServerGetSession), 909 - "com.atproto.server.listAppPasswords" => Ok(Ids::ComAtprotoServerListAppPasswords), 910 - "com.atproto.server.refreshSession" => Ok(Ids::ComAtprotoServerRefreshSession), 911 - "com.atproto.server.requestAccountDelete" => { 912 - Ok(Ids::ComAtprotoServerRequestAccountDelete) 913 - } 914 - "com.atproto.server.requestEmailConfirmation" => { 915 - Ok(Ids::ComAtprotoServerRequestEmailConfirmation) 916 - } 917 - "com.atproto.server.requestEmailUpdate" => Ok(Ids::ComAtprotoServerRequestEmailUpdate), 918 - "com.atproto.server.requestPasswordReset" => { 919 - Ok(Ids::ComAtprotoServerRequestPasswordReset) 920 - } 921 - "com.atproto.server.reserveSigningKey" => Ok(Ids::ComAtprotoServerReserveSigningKey), 922 - "com.atproto.server.resetPassword" => Ok(Ids::ComAtprotoServerResetPassword), 923 - "com.atproto.server.revokeAppPassword" => Ok(Ids::ComAtprotoServerRevokeAppPassword), 924 - "com.atproto.server.updateEmail" => Ok(Ids::ComAtprotoServerUpdateEmail), 925 - "com.atproto.sync.getBlob" => Ok(Ids::ComAtprotoSyncGetBlob), 926 - "com.atproto.sync.getBlocks" => Ok(Ids::ComAtprotoSyncGetBlocks), 927 - "com.atproto.sync.getCheckout" => Ok(Ids::ComAtprotoSyncGetCheckout), 928 - "com.atproto.sync.getHead" => Ok(Ids::ComAtprotoSyncGetHead), 929 - "com.atproto.sync.getLatestCommit" => Ok(Ids::ComAtprotoSyncGetLatestCommit), 930 - "com.atproto.sync.getRecord" => Ok(Ids::ComAtprotoSyncGetRecord), 931 - "com.atproto.sync.getRepo" => Ok(Ids::ComAtprotoSyncGetRepo), 932 - "com.atproto.sync.listBlobs" => Ok(Ids::ComAtprotoSyncListBlobs), 933 - "com.atproto.sync.listRepos" => Ok(Ids::ComAtprotoSyncListRepos), 934 - "com.atproto.sync.notifyOfUpdate" => Ok(Ids::ComAtprotoSyncNotifyOfUpdate), 935 - "com.atproto.sync.requestCrawl" => Ok(Ids::ComAtprotoSyncRequestCrawl), 936 - "com.atproto.sync.subscribeRepos" => Ok(Ids::ComAtprotoSyncSubscribeRepos), 937 - "com.atproto.temp.checkSignupQueue" => Ok(Ids::ComAtprotoTempCheckSignupQueue), 938 - "com.atproto.temp.fetchLabels" => Ok(Ids::ComAtprotoTempFetchLabels), 939 - "com.atproto.temp.requestPhoneVerification" => { 940 - Ok(Ids::ComAtprotoTempRequestPhoneVerification) 941 - } 942 - "app.bsky.actor.defs" => Ok(Ids::AppBskyActorDefs), 943 - "app.bsky.actor.getPreferences" => Ok(Ids::AppBskyActorGetPreferences), 944 - "app.bsky.actor.getProfile" => Ok(Ids::AppBskyActorGetProfile), 945 - "app.bsky.actor.getProfiles" => Ok(Ids::AppBskyActorGetProfiles), 946 - "app.bsky.actor.getSuggestions" => Ok(Ids::AppBskyActorGetSuggestions), 947 - "app.bsky.actor.profile" => Ok(Ids::AppBskyActorProfile), 948 - "app.bsky.actor.putPreferences" => Ok(Ids::AppBskyActorPutPreferences), 949 - "app.bsky.actor.searchActors" => Ok(Ids::AppBskyActorSearchActors), 950 - "app.bsky.actor.searchActorsTypeahead" => Ok(Ids::AppBskyActorSearchActorsTypeahead), 951 - "app.bsky.embed.external" => Ok(Ids::AppBskyEmbedExternal), 952 - "app.bsky.embed.images" => Ok(Ids::AppBskyEmbedImages), 953 - "app.bsky.embed.record" => Ok(Ids::AppBskyEmbedRecord), 954 - "app.bsky.embed.recordWithMedia" => Ok(Ids::AppBskyEmbedRecordWithMedia), 955 - "app.bsky.feed.defs" => Ok(Ids::AppBskyFeedDefs), 956 - "app.bsky.feed.describeFeedGenerator" => Ok(Ids::AppBskyFeedDescribeFeedGenerator), 957 - "app.bsky.feed.generator" => Ok(Ids::AppBskyFeedGenerator), 958 - "app.bsky.feed.getActorFeeds" => Ok(Ids::AppBskyFeedGetActorFeeds), 959 - "app.bsky.feed.getActorLikes" => Ok(Ids::AppBskyFeedGetActorLikes), 960 - "app.bsky.feed.getAuthorFeed" => Ok(Ids::AppBskyFeedGetAuthorFeed), 961 - "app.bsky.feed.getFeed" => Ok(Ids::AppBskyFeedGetFeed), 962 - "app.bsky.feed.getFeedGenerator" => Ok(Ids::AppBskyFeedGetFeedGenerator), 963 - "app.bsky.feed.getFeedGenerators" => Ok(Ids::AppBskyFeedGetFeedGenerators), 964 - "app.bsky.feed.getFeedSkeleton" => Ok(Ids::AppBskyFeedGetFeedSkeleton), 965 - "app.bsky.feed.getLikes" => Ok(Ids::AppBskyFeedGetLikes), 966 - "app.bsky.feed.getListFeed" => Ok(Ids::AppBskyFeedGetListFeed), 967 - "app.bsky.feed.getPostThread" => Ok(Ids::AppBskyFeedGetPostThread), 968 - "app.bsky.feed.getPosts" => Ok(Ids::AppBskyFeedGetPosts), 969 - "app.bsky.feed.getRepostedBy" => Ok(Ids::AppBskyFeedGetRepostedBy), 970 - "app.bsky.feed.getSuggestedFeeds" => Ok(Ids::AppBskyFeedGetSuggestedFeeds), 971 - "app.bsky.feed.getTimeline" => Ok(Ids::AppBskyFeedGetTimeline), 972 - "app.bsky.feed.like" => Ok(Ids::AppBskyFeedLike), 973 - "app.bsky.feed.post" => Ok(Ids::AppBskyFeedPost), 974 - "app.bsky.feed.repost" => Ok(Ids::AppBskyFeedRepost), 975 - "app.bsky.feed.searchPosts" => Ok(Ids::AppBskyFeedSearchPosts), 976 - "app.bsky.feed.threadgate" => Ok(Ids::AppBskyFeedThreadgate), 977 - "app.bsky.graph.block" => Ok(Ids::AppBskyGraphBlock), 978 - "app.bsky.graph.defs" => Ok(Ids::AppBskyGraphDefs), 979 - "app.bsky.graph.follow" => Ok(Ids::AppBskyGraphFollow), 980 - "app.bsky.graph.getBlocks" => Ok(Ids::AppBskyGraphGetBlocks), 981 - "app.bsky.graph.getFollowers" => Ok(Ids::AppBskyGraphGetFollowers), 982 - "app.bsky.graph.getFollows" => Ok(Ids::AppBskyGraphGetFollows), 983 - "app.bsky.graph.getList" => Ok(Ids::AppBskyGraphGetList), 984 - "app.bsky.graph.getListBlocks" => Ok(Ids::AppBskyGraphGetListBlocks), 985 - "app.bsky.graph.getListMutes" => Ok(Ids::AppBskyGraphGetListMutes), 986 - "app.bsky.graph.getLists" => Ok(Ids::AppBskyGraphGetLists), 987 - "app.bsky.graph.getMutes" => Ok(Ids::AppBskyGraphGetMutes), 988 - "app.bsky.graph.getRelationships" => Ok(Ids::AppBskyGraphGetRelationships), 989 - "app.bsky.graph.getSuggestedFollowsByActor" => { 990 - Ok(Ids::AppBskyGraphGetSuggestedFollowsByActor) 991 - } 992 - "app.bsky.graph.list" => Ok(Ids::AppBskyGraphList), 993 - "app.bsky.graph.listblock" => Ok(Ids::AppBskyGraphListblock), 994 - "app.bsky.graph.listitem" => Ok(Ids::AppBskyGraphListitem), 995 - "app.bsky.graph.muteActor" => Ok(Ids::AppBskyGraphMuteActor), 996 - "app.bsky.graph.muteActorList" => Ok(Ids::AppBskyGraphMuteActorList), 997 - "app.bsky.graph.unmuteActor" => Ok(Ids::AppBskyGraphUnmuteActor), 998 - "app.bsky.graph.unmuteActorList" => Ok(Ids::AppBskyGraphUnmuteActorList), 999 - "app.bsky.labeler.defs" => Ok(Ids::AppBskyLabelerDefs), 1000 - "app.bsky.labeler.getServices" => Ok(Ids::AppBskyLabelerGetServices), 1001 - "app.bsky.labeler.service" => Ok(Ids::AppBskyLabelerService), 1002 - "app.bsky.notification.getUnreadCount" => Ok(Ids::AppBskyNotificationGetUnreadCount), 1003 - "app.bsky.notification.listNotifications" => { 1004 - Ok(Ids::AppBskyNotificationListNotifications) 1005 - } 1006 - "app.bsky.notification.registerPush" => Ok(Ids::AppBskyNotificationRegisterPush), 1007 - "app.bsky.notification.updateSeen" => Ok(Ids::AppBskyNotificationUpdateSeen), 1008 - "app.bsky.richtext.facet" => Ok(Ids::AppBskyRichtextFacet), 1009 - "app.bsky.unspecced.defs" => Ok(Ids::AppBskyUnspeccedDefs), 1010 - "app.bsky.unspecced.getPopularFeedGenerators" => { 1011 - Ok(Ids::AppBskyUnspeccedGetPopularFeedGenerators) 1012 - } 1013 - "app.bsky.unspecced.getTaggedSuggestions" => { 1014 - Ok(Ids::AppBskyUnspeccedGetTaggedSuggestions) 1015 - } 1016 - "app.bsky.unspecced.searchActorsSkeleton" => { 1017 - Ok(Ids::AppBskyUnspeccedSearchActorsSkeleton) 1018 - } 1019 - "app.bsky.unspecced.searchPostsSkeleton" => { 1020 - Ok(Ids::AppBskyUnspeccedSearchPostsSkeleton) 1021 - } 1022 - "tools.ozone.communication.createTemplate" => { 1023 - Ok(Ids::ToolsOzoneCommunicationCreateTemplate) 1024 - } 1025 - "tools.ozone.communication.defs" => Ok(Ids::ToolsOzoneCommunicationDefs), 1026 - "tools.ozone.communication.deleteTemplate" => { 1027 - Ok(Ids::ToolsOzoneCommunicationDeleteTemplate) 1028 - } 1029 - "tools.ozone.communication.listTemplates" => { 1030 - Ok(Ids::ToolsOzoneCommunicationListTemplates) 1031 - } 1032 - "tools.ozone.communication.updateTemplate" => { 1033 - Ok(Ids::ToolsOzoneCommunicationUpdateTemplate) 1034 - } 1035 - "tools.ozone.moderation.defs" => Ok(Ids::ToolsOzoneModerationDefs), 1036 - "tools.ozone.moderation.emitEvent" => Ok(Ids::ToolsOzoneModerationEmitEvent), 1037 - "tools.ozone.moderation.getEvent" => Ok(Ids::ToolsOzoneModerationGetEvent), 1038 - "tools.ozone.moderation.getRecord" => Ok(Ids::ToolsOzoneModerationGetRecord), 1039 - "tools.ozone.moderation.getRepo" => Ok(Ids::ToolsOzoneModerationGetRepo), 1040 - "tools.ozone.moderation.queryEvents" => Ok(Ids::ToolsOzoneModerationQueryEvents), 1041 - "tools.ozone.moderation.queryStatuses" => Ok(Ids::ToolsOzoneModerationQueryStatuses), 1042 - "tools.ozone.moderation.searchRepos" => Ok(Ids::ToolsOzoneModerationSearchRepos), 1043 - "tools.ozone.server.getConfig" => Ok(Ids::ToolsOzoneServerGetConfig), 1044 - "tools.ozone.team.addMember" => Ok(Ids::ToolsOzoneTeamAddMember), 1045 - "tools.ozone.team.defs" => Ok(Ids::ToolsOzoneTeamDefs), 1046 - "tools.ozone.team.deleteMember" => Ok(Ids::ToolsOzoneTeamDeleteMember), 1047 - "tools.ozone.team.listMembers" => Ok(Ids::ToolsOzoneTeamListMembers), 1048 - "tools.ozone.team.updateMember" => Ok(Ids::ToolsOzoneTeamUpdateMember), 1049 - "chat.bsky.actor.deleteAccount" => Ok(Ids::ChatBskyActorDeleteAccount), 1050 - "chat.bsky.actor.exportAccountData" => Ok(Ids::ChatBskyActorExportAccountData), 1051 - "chat.bsky.convo.deleteMessageForSelf" => Ok(Ids::ChatBskyConvoDeleteMessageForSelf), 1052 - "chat.bsky.convo.getConvo" => Ok(Ids::ChatBskyConvoGetConvo), 1053 - "chat.bsky.convo.getConvoForMembers" => Ok(Ids::ChatBskyConvoGetConvoForMembers), 1054 - "chat.bsky.convo.getLog" => Ok(Ids::ChatBskyConvoGetLog), 1055 - "chat.bsky.convo.getMessages" => Ok(Ids::ChatBskyConvoGetMessages), 1056 - "chat.bsky.convo.leaveConvo" => Ok(Ids::ChatBskyConvoLeaveConvo), 1057 - "chat.bsky.convo.listConvos" => Ok(Ids::ChatBskyConvoListConvos), 1058 - "chat.bsky.convo.muteConvo" => Ok(Ids::ChatBskyConvoMuteConvo), 1059 - "chat.bsky.convo.sendMessage" => Ok(Ids::ChatBskyConvoSendMessage), 1060 - "chat.bsky.convo.sendMessageBatch" => Ok(Ids::ChatBskyConvoSendMessageBatch), 1061 - "chat.bsky.convo.unmuteConvo" => Ok(Ids::ChatBskyConvoUnmuteConvo), 1062 - "chat.bsky.convo.updateRead" => Ok(Ids::ChatBskyConvoUpdateRead), 1063 - _ => bail!("Invalid NSID: `{s:?}` is not a valid nsid"), 1064 - } 1065 - } 1066 - } 1067 - 1068 - #[derive(Debug, Clone, PartialEq)] 1069 - pub struct RecordCidClaim { 1070 - pub collection: String, 1071 - pub rkey: String, 1072 - pub cid: Option<Cid>, 1073 - } 1074 - 1075 - /// BlobStream 1076 - /// A stream of blob data. 1077 - pub(crate) struct BlobStream(Box<dyn std::io::Read + Send>); 1078 - impl Debug for BlobStream { 1079 - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 1080 - f.debug_struct("BlobStream").finish() 1081 - } 1082 - } 1083 - 1084 - pub(crate) struct BlobStore; 1085 - pub(crate) trait BlobStoreTrait { 1086 - async fn put_temp(&self, bytes: &[u8]) -> Result<String>; // bytes: Uint8Array | stream.Readable 1087 - async fn make_permanent(&self, key: &str, cid: Cid) -> Result<()>; 1088 - async fn put_permanent(&self, cid: Cid, bytes: &[u8]) -> Result<()>; 1089 - async fn quarantine(&self, cid: Cid) -> Result<()>; 1090 - async fn unquarantine(&self, cid: Cid) -> Result<()>; 1091 - async fn get_bytes(&self, cid: Cid) -> Result<Vec<u8>>; 1092 - async fn get_stream(&self, cid: Cid) -> Result<BlobStream>; // Promise<stream.Readable> 1093 - async fn has_temp(&self, key: &str) -> Result<bool>; 1094 - async fn has_stored(&self, cid: Cid) -> Result<bool>; 1095 - async fn delete(&self, cid: Cid) -> Result<()>; 1096 - async fn delete_many(&self, cids: Vec<Cid>) -> Result<()>; 1097 - } 1098 - impl BlobStoreTrait for BlobStore { 1099 - async fn put_temp(&self, bytes: &[u8]) -> Result<String> { 1100 - // Implementation here 1101 - Ok("temp_key".to_string()) 1102 - } 1103 - 1104 - async fn make_permanent(&self, key: &str, cid: Cid) -> Result<()> { 1105 - // Implementation here 1106 - Ok(()) 1107 - } 1108 - 1109 - async fn put_permanent(&self, cid: Cid, bytes: &[u8]) -> Result<()> { 1110 - // Implementation here 1111 - Ok(()) 1112 - } 1113 - 1114 - async fn quarantine(&self, cid: Cid) -> Result<()> { 1115 - // Implementation here 1116 - Ok(()) 1117 - } 1118 - 1119 - async fn unquarantine(&self, cid: Cid) -> Result<()> { 1120 - // Implementation here 1121 - Ok(()) 1122 - } 1123 - 1124 - async fn get_bytes(&self, cid: Cid) -> Result<Vec<u8>> { 1125 - // Implementation here 1126 - Ok(vec![]) 1127 - } 1128 - 1129 - async fn get_stream(&self, cid: Cid) -> Result<BlobStream> { 1130 - // Implementation here 1131 - Ok(BlobStream(Box::new(std::io::empty()))) 1132 - } 1133 - 1134 - async fn has_temp(&self, key: &str) -> Result<bool> { 1135 - // Implementation here 1136 - Ok(true) 1137 - } 1138 - 1139 - async fn has_stored(&self, cid: Cid) -> Result<bool> { 1140 - // Implementation here 1141 - Ok(true) 1142 - } 1143 - async fn delete(&self, cid: Cid) -> Result<()> { 1144 - // Implementation here 1145 - Ok(()) 1146 - } 1147 - async fn delete_many(&self, cids: Vec<Cid>) -> Result<()> { 1148 - // Implementation here 1149 - Ok(()) 1150 - } 1151 - }