Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm
0

Configure Feed

Select the types of activity you want to include in your feed.

json from reader

+4 -14
+4 -14
jetstream/src/lib.rs
··· 3 3 pub mod exports; 4 4 5 5 use std::{ 6 - io::{ 7 - Cursor as IoCursor, 8 - Read, 9 - }, 6 + io::Cursor as IoCursor, 10 7 time::{ 11 8 Duration, 12 9 Instant, ··· 453 450 } 454 451 Message::Binary(zstd_json) => { 455 452 let mut cursor = IoCursor::new(zstd_json); 456 - let mut decoder = zstd::stream::Decoder::with_prepared_dictionary( 453 + let decoder = zstd::stream::Decoder::with_prepared_dictionary( 457 454 &mut cursor, 458 455 &dictionary, 459 456 ) 460 457 .map_err(JetstreamEventError::CompressionDictionaryError)?; 461 458 462 - let mut json = String::new(); 463 - decoder 464 - .read_to_string(&mut json) 465 - .map_err(JetstreamEventError::CompressionDecoderError)?; 466 - 467 - let event: JetstreamEvent = serde_json::from_str(&json).map_err(|e| { 468 - eprintln!("lkasjdflkajsd {e:?} {json}"); 469 - JetstreamEventError::ReceivedMalformedJSON(e) 470 - })?; 459 + let event: JetstreamEvent = serde_json::from_reader(decoder) 460 + .map_err(JetstreamEventError::ReceivedMalformedJSON)?; 471 461 let event_cursor = event.cursor.clone(); 472 462 473 463 if let Some(last) = last_cursor {