diff --git a/src/mac/mod.rs b/src/mac/mod.rs index 8b57ece5..739dac56 100644 --- a/src/mac/mod.rs +++ b/src/mac/mod.rs @@ -1,29 +1,7 @@ -macro_rules! output { - ($expression:expr) => { - bytes::Bytes::from(format!("{}\n", $expression)) - }; -} - macro_rules! map { - ($($k:expr => $v:expr),* $(,)?) => {{ - let mut m = ::std::collections::BTreeMap::new(); - $(m.insert($k, $v);)+ - m - }}; -} - -macro_rules! hmap { ($($k:expr => $v:expr),* $(,)?) => {{ let mut m = ::std::collections::HashMap::new(); $(m.insert($k, $v);)+ m }}; } - -macro_rules! bmap { - ($($k:expr => $v:expr),* $(,)?) => {{ - let mut m = ::std::collections::BTreeMap::new(); - $(m.insert($k, $v);)+ - m - }}; -} diff --git a/src/net/key.rs b/src/net/key.rs index 3aa55ba8..81f76d17 100644 --- a/src/net/key.rs +++ b/src/net/key.rs @@ -112,7 +112,7 @@ async fn select_all( l = query.limit.unwrap_or_else(|| String::from("100")), s = query.start.unwrap_or_else(|| String::from("0")), ); - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), }; match surrealdb::execute(db, sql.as_str(), session, Some(vars)).await { @@ -137,7 +137,7 @@ async fn create_all( match surrealdb::sql::json(data) { Ok(data) => { let sql = "CREATE type::table($table) CONTENT $data"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("data") => data, }; @@ -162,7 +162,7 @@ async fn delete_all( ) -> Result { let db = DB.get().unwrap().clone(); let sql = "DELETE type::table($table)"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), }; match surrealdb::execute(db, sql, session, Some(vars)).await { @@ -188,7 +188,7 @@ async fn select_one( ) -> Result { let db = DB.get().unwrap().clone(); let sql = "SELECT * FROM type::thing($table, $id)"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("id") => Value::from(id), }; @@ -215,7 +215,7 @@ async fn create_one( match surrealdb::sql::json(data) { Ok(data) => { let sql = "CREATE type::thing($table, $id) CONTENT $data"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("id") => Value::from(id), String::from("data") => data, @@ -246,7 +246,7 @@ async fn update_one( match surrealdb::sql::json(data) { Ok(data) => { let sql = "UPDATE type::thing($table, $id) CONTENT $data"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("id") => Value::from(id), String::from("data") => data, @@ -277,7 +277,7 @@ async fn modify_one( match surrealdb::sql::json(data) { Ok(data) => { let sql = "UPDATE type::thing($table, $id) MERGE $data"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("id") => Value::from(id), String::from("data") => data, @@ -304,7 +304,7 @@ async fn delete_one( ) -> Result { let db = DB.get().unwrap().clone(); let sql = "DELETE type::thing($table, $id)"; - let vars = hmap! { + let vars = map! { String::from("table") => Value::from(table), String::from("id") => Value::from(id), };