summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/src/api_entity_crud.rs12
-rw-r--r--rust/src/api_helpers.rs3
-rw-r--r--rust/src/api_server.rs12
-rw-r--r--rust/src/api_wrappers.rs2
4 files changed, 15 insertions, 14 deletions
diff --git a/rust/src/api_entity_crud.rs b/rust/src/api_entity_crud.rs
index dd0961d5..4d5caf62 100644
--- a/rust/src/api_entity_crud.rs
+++ b/rust/src/api_entity_crud.rs
@@ -371,7 +371,7 @@ macro_rules! generic_db_accept_edits_each {
macro_rules! generic_db_insert_rev {
() => {
fn db_insert_rev(&self, conn: &DbConn) -> Result<Uuid> {
- Self::db_insert_revs(conn, &vec![self]).map(|id_list| id_list[0])
+ Self::db_insert_revs(conn, &[self]).map(|id_list| id_list[0])
}
}
}
@@ -631,7 +631,7 @@ impl EntityCrud for FileEntity {
.iter()
.map(|r| {
Ok(FileReleaseRow {
- file_rev: rev_id.clone(),
+ file_rev: *rev_id,
target_release_ident_id: FatCatId::from_str(r)?.to_uuid(),
})
})
@@ -646,7 +646,7 @@ impl EntityCrud for FileEntity {
let these_url_rows: Vec<FileRevUrlNewRow> = url_list
.into_iter()
.map(|u| FileRevUrlNewRow {
- file_rev: rev_id.clone(),
+ file_rev: *rev_id,
rel: u.rel.clone(),
url: u.url.clone(),
})
@@ -693,7 +693,7 @@ impl EntityCrud for ReleaseEntity {
generic_db_insert_rev!();
fn db_create(&self, conn: &DbConn, edit_context: &EditContext) -> Result<Self::EditRow> {
- let mut edits = Self::db_create_batch(conn, edit_context, &vec![self])?;
+ let mut edits = Self::db_create_batch(conn, edit_context, &[self])?;
// probably a more elegant way to destroy the vec and take first element
Ok(edits.pop().unwrap())
}
@@ -750,7 +750,7 @@ impl EntityCrud for ReleaseEntity {
rev_ids
.iter()
.map(|rev_id| Self::IdentNewRow {
- rev_id: Some(rev_id.clone()),
+ rev_id: Some(*rev_id),
is_live: edit_context.autoaccept,
redirect_id: None,
})
@@ -1002,7 +1002,7 @@ impl EntityCrud for ReleaseEntity {
.into_iter()
.map(|c| {
Ok(ReleaseRevAbstractNewRow {
- release_rev: rev_id.clone(),
+ release_rev: *rev_id,
abstract_sha1: match c.content {
Some(ref content) => Sha1::from(content).hexdigest(),
None => match c.sha1.clone() {
diff --git a/rust/src/api_helpers.rs b/rust/src/api_helpers.rs
index 6c214223..8ddaf82c 100644
--- a/rust/src/api_helpers.rs
+++ b/rust/src/api_helpers.rs
@@ -117,8 +117,9 @@ impl FatCatId {
pub fn to_uuid(&self) -> Uuid {
self.0
}
+ // TODO: just make it u: Uuid and clone (not by ref)
pub fn from_uuid(u: &Uuid) -> FatCatId {
- FatCatId(u.clone())
+ FatCatId(*u)
}
}
diff --git a/rust/src/api_server.rs b/rust/src/api_server.rs
index 076bc085..449196be 100644
--- a/rust/src/api_server.rs
+++ b/rust/src/api_server.rs
@@ -61,7 +61,7 @@ impl Server {
pub fn get_container_handler(
&self,
id: FatCatId,
- _expand: Option<String>,
+ _expand: &Option<String>,
conn: &DbConn,
) -> Result<ContainerEntity> {
ContainerEntity::db_get(conn, id)
@@ -85,7 +85,7 @@ impl Server {
pub fn get_creator_handler(
&self,
id: FatCatId,
- _expand: Option<String>,
+ _expand: &Option<String>,
conn: &DbConn,
) -> Result<CreatorEntity> {
CreatorEntity::db_get(conn, id)
@@ -129,7 +129,7 @@ impl Server {
pub fn get_file_handler(
&self,
id: FatCatId,
- _expand: Option<String>,
+ _expand: &Option<String>,
conn: &DbConn,
) -> Result<FileEntity> {
FileEntity::db_get(conn, id)
@@ -152,7 +152,7 @@ impl Server {
pub fn get_release_handler(
&self,
id: FatCatId,
- expand: Option<String>,
+ expand: &Option<String>,
conn: &DbConn,
) -> Result<ReleaseEntity> {
let mut release = ReleaseEntity::db_get(conn, id)?;
@@ -162,7 +162,7 @@ impl Server {
release.files = Some(self.get_release_files_handler(id, conn)?);
if let Some(ref cid) = release.container_id {
release.container =
- Some(self.get_container_handler(FatCatId::from_str(&cid)?, None, conn)?);
+ Some(self.get_container_handler(FatCatId::from_str(&cid)?, &None, conn)?);
}
}
Ok(release)
@@ -204,7 +204,7 @@ impl Server {
pub fn get_work_handler(
&self,
id: FatCatId,
- _expand: Option<String>,
+ _expand: &Option<String>,
conn: &DbConn,
) -> Result<WorkEntity> {
WorkEntity::db_get(conn, id)
diff --git a/rust/src/api_wrappers.rs b/rust/src/api_wrappers.rs
index f6425c8c..4d3373e2 100644
--- a/rust/src/api_wrappers.rs
+++ b/rust/src/api_wrappers.rs
@@ -36,7 +36,7 @@ macro_rules! wrap_entity_handlers {
// No transaction for GET
let ret = match conn.transaction(|| {
let entity_id = FatCatId::from_str(&id)?;
- self.$get_handler(entity_id, expand, &conn)
+ self.$get_handler(entity_id, &expand, &conn)
}) {
Ok(entity) =>
$get_resp::FoundEntity(entity),