X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=backend%2Fsrc%2Fdata%2Fasynchronous.rs;fp=backend%2Fsrc%2Fdata%2Fasynchronous.rs;h=a5a5cdf6c0928287bd0cf438a89b094a1d91ee47;hb=642dd8a80ce2e1212b8e30c1edabb32bdb416cfc;hp=4dda8037edf1b6d42fe7c6c68a5a1a46f35cfa79;hpb=d28e765e39e70ad2ab9a42885c786d5d8ba9ba40;p=recipes.git diff --git a/backend/src/data/asynchronous.rs b/backend/src/data/asynchronous.rs index 4dda803..a5a5cdf 100644 --- a/backend/src/data/asynchronous.rs +++ b/backend/src/data/asynchronous.rs @@ -49,17 +49,17 @@ fn combine_errors(error: std::result::Result = std::result::Result; impl Connection { - pub async fn get_all_recipe_titles_async(&self) -> Result> { + pub async fn get_all_recipe_titles_async(&self) -> Result> { let self_copy = self.clone(); web::block(move || { self_copy.get_all_recipe_titles().unwrap_or_default() }).await.map_err(DBAsyncError::from) } - pub async fn get_recipe_async(&self, id: i32) -> Result { + pub async fn get_recipe_async(&self, id: i64) -> Result { let self_copy = self.clone(); combine_errors(web::block(move || { self_copy.get_recipe(id).map_err(DBAsyncError::from) }).await) } - pub async fn load_user_async(&self, user_id: i32) -> Result { + pub async fn load_user_async(&self, user_id: i64) -> Result { let self_copy = self.clone(); combine_errors(web::block(move || { self_copy.load_user(user_id).map_err(DBAsyncError::from) }).await) } @@ -101,4 +101,15 @@ impl Connection { let token_copy = token.to_string(); combine_errors(web::block(move || { self_copy.sign_out(&token_copy).map_err(DBAsyncError::from) }).await) } + + pub async fn create_recipe_async(&self, user_id: i64) -> Result { + let self_copy = self.clone(); + combine_errors(web::block(move || { self_copy.create_recipe(user_id).map_err(DBAsyncError::from) }).await) + } + + pub async fn set_recipe_title_async(&self, recipe_id: i64, title: &str) -> Result<()> { + let self_copy = self.clone(); + let title_copy = title.to_string(); + combine_errors(web::block(move || { self_copy.set_recipe_title(recipe_id, &title_copy).map_err(DBAsyncError::from) }).await) + } } \ No newline at end of file