diff --git a/Cargo.lock b/Cargo.lock index b0faa35..b8b9ad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -906,9 +906,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toad" -version = "1.0.0-beta.4" +version = "1.0.0-beta.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7680b4a4868e2527ee0cb58b3850179f9ad9a44532b13fb9e4487a176091b71a" +checksum = "b305d4763b0236558486735374e796a028567a8d6f6a4c94c07096b73573ba0a" dependencies = [ "embedded-time", "log", diff --git a/Cargo.toml b/Cargo.toml index b6350a1..5ebc673 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" publish = false [dependencies] -toad = "1.0.0-beta.3" -toad-msg = "1.0.0-beta.1" +toad = "1.0.0-beta.6" +toad-msg = "1.0.0-beta.2" simple_logger = "4.2" nb = "1.1.0" serde = {version = "1", features = ["derive"]} diff --git a/src/env.rs b/src/env.rs index c2aa47b..e2ddaf4 100644 --- a/src/env.rs +++ b/src/env.rs @@ -33,13 +33,12 @@ pub enum Error { impl Env { pub fn try_read() -> Result { fn get(k: &'static str) -> Result, Error> { - std::env::var("POSTGRES_USER").map(Some) - .recover(|e| match e { - | std::env::VarError::NotPresent => Ok(None), - | std::env::VarError::NotUnicode(os) => { - Err(Error::VarNotUnicode(k.into(), os)) - }, - }) + std::env::var(k).map(Some).recover(|e| match e { + | std::env::VarError::NotPresent => Ok(None), + | std::env::VarError::NotUnicode(os) => { + Err(Error::VarNotUnicode(k.into(), os)) + }, + }) } fn get_required(k: &'static str) -> Result { @@ -53,7 +52,8 @@ impl Env { let api_addr = get("API_ADDR")?.unwrap_or("127.0.0.1:4444".into()); - let api = Api { addr: api_addr.trim().parse() + let api = Api { addr: api_addr.trim() + .parse() .map_err(|e| Error::VarNotSocketAddr("API_ADDR".into(), e))? }; Ok(Env { postgres, api }) diff --git a/src/main.rs b/src/main.rs index 6df1927..1f0dad0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,15 +77,30 @@ newtype!( pub struct Email(String); ); -type Dtls = toad::std::dtls::N; -type ToadT = toad::std::PlatformTypes; -type Toad = toad::std::Platform>; - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, serde::Serialize, serde::Deserialize)] -struct Foo { - id: String, +mod __toad_aliases { + use naan::hkt; + use toad::std::dtls; + use toad::step::parse::Parse; + use toad::step::provision_tokens::ProvisionTokens; + use toad::step::runtime::{BufferResponses, HandleAcks, Observe, ProvisionIds, Retry}; + pub type ToadT = toad::std::PlatformTypes; + pub type Runtime = + Observe>>>>>>; + pub type Toad = toad::std::Platform; } +use __toad_aliases::*; + fn handle_request(req: Addrd>) -> Result, String> { let path = req.data() .path() @@ -97,10 +112,14 @@ fn handle_request(req: Addrd>) -> Result, String> { if path_segments.peek() == Some(&"users") { let mut path_segments = path_segments.clone(); let _id = path_segments.nth(2); - let msg = Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).build(); + let msg = + Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).token(req.data().msg().token) + .build(); Ok(Addrd(msg, req.addr())) } else { - let msg = Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).build(); + let msg = + Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).token(req.data().msg().token) + .build(); Ok(Addrd(msg, req.addr())) } }