// use mastodonochrome::types::*;
+use mastodonochrome::OurError;
use mastodonochrome::auth::AuthConfig;
use std::io::Read;
let auth = AuthConfig::load()?;
let client = reqwest::blocking::Client::new();
- let mut req = client.get(auth.instance_url + "/api/v1/streaming/user")
- .bearer_auth(auth.user_token)
- .send().unwrap();
+ let req = client.get(auth.instance_url + "/api/v1/streaming/user")
+ .bearer_auth(auth.user_token);
+
+ let mut rsp = match req.send() {
+ Err(e) => Err(OurError::Fatal(
+ format!("unable to make HTTP request: {}", e))),
+ Ok(d) => Ok(d),
+ }?;
const BUFSIZE: usize = 4096;
let mut buf: [u8; BUFSIZE] = [0; BUFSIZE];
- while let Ok(sz) = req.read(&mut buf) {
+ while let Ok(sz) = rsp.read(&mut buf) {
let read = &buf[..sz];
dbg!(read);
}