fix: not found fallthru

This commit is contained in:
Orion Kindel 2023-07-12 23:35:44 -05:00
parent 568b248f3e
commit d85bc8c579
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
4 changed files with 49 additions and 30 deletions

26
Cargo.lock generated
View File

@ -906,9 +906,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "toad" name = "toad"
version = "1.0.0-beta.2" version = "1.0.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41fbfaadd52558c4d595bf38fb6942333307c47158abc30c0c3a0bbd1848b65" checksum = "7680b4a4868e2527ee0cb58b3850179f9ad9a44532b13fb9e4487a176091b71a"
dependencies = [ dependencies = [
"embedded-time", "embedded-time",
"log", "log",
@ -922,7 +922,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"tinyvec", "tinyvec",
"toad-array", "toad-array 0.8.0",
"toad-hash", "toad-hash",
"toad-len", "toad-len",
"toad-macros", "toad-macros",
@ -943,6 +943,16 @@ dependencies = [
"toad-len", "toad-len",
] ]
[[package]]
name = "toad-array"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90c89c65763a9ed217a09ea4f43615153e9bccf82f972f3e5914ded7f5658fe6"
dependencies = [
"tinyvec",
"toad-len",
]
[[package]] [[package]]
name = "toad-cursor" name = "toad-cursor"
version = "0.2.0" version = "0.2.0"
@ -990,13 +1000,13 @@ dependencies = [
[[package]] [[package]]
name = "toad-msg" name = "toad-msg"
version = "0.18.1" version = "1.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d78ad790094eefd8146fab35178e23b224285fe9b275132a31872c0f74b1a8ff" checksum = "63f5ff0cb4b95ec5eb83db517a2301d6a5a5917d94124140dff2fafa283a41f5"
dependencies = [ dependencies = [
"blake2", "blake2",
"tinyvec", "tinyvec",
"toad-array", "toad-array 0.8.0",
"toad-cursor", "toad-cursor",
"toad-hash", "toad-hash",
"toad-len", "toad-len",
@ -1017,7 +1027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdad9197bf6974091949a6d3e00946558d69e0d7b3d159283c6c43fffdef59dc" checksum = "fdad9197bf6974091949a6d3e00946558d69e0d7b3d159283c6c43fffdef59dc"
dependencies = [ dependencies = [
"tinyvec", "tinyvec",
"toad-array", "toad-array 0.2.3",
"toad-len", "toad-len",
"toad-writable", "toad-writable",
] ]
@ -1028,7 +1038,7 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebe82c1076c85774b389e86cb2a2dbb846e35e599e9b42c8f2fc6628593cd0a9" checksum = "ebe82c1076c85774b389e86cb2a2dbb846e35e599e9b42c8f2fc6628593cd0a9"
dependencies = [ dependencies = [
"toad-array", "toad-array 0.2.3",
] ]
[[package]] [[package]]

View File

@ -5,8 +5,8 @@ edition = "2021"
publish = false publish = false
[dependencies] [dependencies]
toad = "1.0.0-beta.2" toad = "1.0.0-beta.3"
toad-msg = "0.18.1" toad-msg = "1.0.0-beta.1"
simple_logger = "4.2" simple_logger = "4.2"
nb = "1.1.0" nb = "1.1.0"
serde = {version = "1", features = ["derive"]} serde = {version = "1", features = ["derive"]}

View File

@ -3,6 +3,8 @@ use toad::net::Addrd;
use toad::platform::Platform as _; use toad::platform::Platform as _;
use toad::req::Req; use toad::req::Req;
use toad::resp::Resp; use toad::resp::Resp;
use toad_msg::alloc::Message;
use toad_msg::Type;
mod app; mod app;
mod hashed_text; mod hashed_text;
@ -82,7 +84,7 @@ struct Foo {
id: String, id: String,
} }
fn handle_request(req: Addrd<Req<ToadT>>) -> Result<Addrd<Resp<ToadT>>, String> { fn handle_request(req: Addrd<Req<ToadT>>) -> Result<Addrd<Message>, String> {
let path = req.data() let path = req.data()
.path() .path()
.map_err(|e| format!("{e:?}")) .map_err(|e| format!("{e:?}"))
@ -94,9 +96,12 @@ fn handle_request(req: Addrd<Req<ToadT>>) -> Result<Addrd<Resp<ToadT>>, String>
let mut path_segments = path_segments.clone(); let mut path_segments = path_segments.clone();
path_segments.next(); path_segments.next();
let _id = path_segments.next(); let _id = path_segments.next();
let msg = Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).build();
Ok(Addrd(msg, req.addr()))
} else {
let msg = Message::builder(Type::Ack, toad::resp::code::NOT_FOUND).build();
Ok(Addrd(msg, req.addr()))
} }
Ok(req.map(|r| Resp::for_request(&r).unwrap()))
} }
fn server_worker(p: &'static Toad) { fn server_worker(p: &'static Toad) {

View File

@ -222,16 +222,18 @@ mod tests {
#[test] #[test]
fn user_repo_insert() { fn user_repo_insert() {
let client = let client = || Client::<()> { state: Box::new(vec![UserTag::from("foo")]),
|| Client::<()> { state: Box::new(vec![UserTag::from("foo")]),
query_one: Box::new(|c, q, ps| { query_one: Box::new(|c, q, ps| {
assert_eq!(q.unwrap_str(), assert_eq!(
q.unwrap_str(),
format!( format!(
"insert into public.usr "insert into public.usr
(tag, password, email) (tag, password, email)
values values
($2, $3, $4) ($2, $3, $4)
returning uid;")); returning uid;"
)
);
let tags = c.state_mut::<Vec<UserTag>>(); let tags = c.state_mut::<Vec<UserTag>>();
@ -241,7 +243,9 @@ returning uid;"));
Err(()) Err(())
} else { } else {
tags.push(tag); tags.push(tag);
Ok(Row::new(vec![("", Type::TEXT)]).value(Type::TEXT, tags.len().to_string())) Ok(Row::new(vec![("", Type::TEXT)]).value(Type::TEXT,
tags.len()
.to_string()))
} }
}), }),
..Client::default() }; ..Client::default() };