chiark / gitweb /
Decode a sample Status as well as an Account
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 10:08:41 +0000 (10:08 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 10:08:41 +0000 (10:08 +0000)
src/main.rs

index 2304bb4ad13d149f1bd7704a04dd01fc1ba7e699..84e09554c1cb230cb4deb2c9db434f3f63b7d74a 100644 (file)
@@ -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<Media>,
+    // application: optional Application,
+    // mentions: Vec<Mention>,
+    // tags: Vec<Hashtag>,
+    // emojis: Vec<Emoji>,
+    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);
 }