From: Simon Tatham Date: Sat, 23 Dec 2023 10:08:41 +0000 (+0000) Subject: Decode a sample Status as well as an Account X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=8873276a98a91a61142b7fc6cf5629dbcb1cd8b8;p=mastodonochrome.git Decode a sample Status as well as an Account --- diff --git a/src/main.rs b/src/main.rs index 2304bb4..84e0955 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,16 +24,57 @@ struct Account { // suspended: optional bool, // limited: optional bool, created_at: String, // FIXME: sort out dates! - last_status_at: String, + last_status_at: String, // FIXME: sort out dates! statuses_count: u64, followers_count: u64, following_count: u64, } +#[derive(Serialize, Deserialize, Debug)] +struct Status { + id: String, + uri: String, + created_at: String, // FIXME: sort out dates! + account: Account, + content: String, + visibility: String, // FIXME: enum + sensitive: bool, + spoiler_text: String, + // media_attachments: Vec, + // application: optional Application, + // mentions: Vec, + // tags: Vec, + // emojis: Vec, + reblogs_count: u64, + favourites_count: u64, + replies_count: u64, + url: String, + // in_reply_to_id: optional String, + // in_reply_to_account_id: optional String, + // reblog: optional Status (!), + // poll: optional Poll, + // card: optional PreviewCard, + // language: optional String, + // text: optional String, + // edited_at: optional String, // FIXME actually a date + // favourited: optional bool, + // reblogged: optional bool, + // muted: optional bool, + // bookmarked: optional bool, + // pinned: optional bool, + // filtered: optional bool, +} + fn main() { let body = reqwest::blocking::get( "https://hachyderm.io/api/v1/accounts/111096602447828617") .unwrap().text().unwrap(); let acc: Account = serde_json::from_str(&body).unwrap(); dbg!(acc); + + let body = reqwest::blocking::get( + "https://hachyderm.io/api/v1/statuses/111602135142646031") + .unwrap().text().unwrap(); + let st: Status = serde_json::from_str(&body).unwrap(); + dbg!(st); }