1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#![allow(dead_code)] extern crate http; use std::time::Duration; use http::{Request, Response}; pub struct AdaClient { pub ada_io_username: String, pub ada_io_key: String, } impl AdaClient { pub fn set(n1:String, n2:String) -> Self { Self{ ada_io_username:n1, ada_io_key:n2, } } pub fn post(&mut self, n3:String, data:String){ let ada_io_feedkey:String = n3; let url:String = format!("https://io.adafruit.com/api/v2/{:}/feeds/{:}/data", self.ada_io_username, ada_io_feedkey); Request::builder() .uri(url) .header("X-AIO-Key: ", &(self.ada_io_key)) .body(data) .unwrap(); } }