summaryrefslogtreecommitdiffstats
path: root/rust/src/entity_crud.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-01-10 21:39:25 -0800
committerBryan Newbold <bnewbold@robocracy.org>2019-01-10 21:39:25 -0800
commit9a83067d04c9648416b92fc8d7b8a542b0b9aa96 (patch)
tree4622455b0f694262db5aa77314a3941ab37419fc /rust/src/entity_crud.rs
parentb75aa46db21c6f7a22b6fbbbd00b1e5d93e1d1ae (diff)
downloadfatcat-9a83067d04c9648416b92fc8d7b8a542b0b9aa96.tar.gz
fatcat-9a83067d04c9648416b92fc8d7b8a542b0b9aa96.zip
code docs/comments and rustfmt
Diffstat (limited to 'rust/src/entity_crud.rs')
-rw-r--r--rust/src/entity_crud.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/rust/src/entity_crud.rs b/rust/src/entity_crud.rs
index a0101de8..3d9b5165 100644
--- a/rust/src/entity_crud.rs
+++ b/rust/src/entity_crud.rs
@@ -1,3 +1,10 @@
+//! Create/Update/Read/Delete methods for all entity types
+//!
+//! This module is very large (perhaps it should be split into per-entity files?), but it basically
+//! comes down to implementing the EntityCrud trait for each of the entity types. *All* entity
+//! reads and mutations should go through this file, which defines the mechanics of translation
+//! between the SQL schema and API (swagger) JSON models.
+
use crate::database_models::*;
use crate::database_schema::*;
use crate::editing::EditContext;
@@ -5,7 +12,6 @@ use crate::endpoint_handlers::get_release_files;
use crate::errors::*;
use crate::identifiers::*;
use crate::server::DbConn;
-use chrono;
use diesel::prelude::*;
use diesel::{self, insert_into};
use fatcat_api_spec::models::*;
@@ -295,8 +301,10 @@ macro_rules! generic_db_get_rev {
fn db_get_rev(conn: &DbConn, rev_id: Uuid, hide: HideFlags) -> Result<Self> {
let rev = match $rev_table::table.find(rev_id).first(conn) {
Ok(rev) => rev,
- Err(diesel::result::Error::NotFound) =>
- Err(FatcatError::NotFound(stringify!($rev_table).to_string(), rev_id.to_string()))?,
+ Err(diesel::result::Error::NotFound) => Err(FatcatError::NotFound(
+ stringify!($rev_table).to_string(),
+ rev_id.to_string(),
+ ))?,
Err(e) => Err(e)?,
};