summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fatcat-cli/src/api.rs28
-rw-r--r--fatcat-cli/src/commands.rs6
-rw-r--r--fatcat-cli/src/download.rs4
-rw-r--r--fatcat-cli/src/entities.rs16
-rw-r--r--fatcat-cli/src/lib.rs4
-rw-r--r--fatcat-cli/src/main.rs4
-rw-r--r--fatcat-cli/src/specifier.rs10
7 files changed, 35 insertions, 37 deletions
diff --git a/fatcat-cli/src/api.rs b/fatcat-cli/src/api.rs
index 37e8a51..8a83289 100644
--- a/fatcat-cli/src/api.rs
+++ b/fatcat-cli/src/api.rs
@@ -157,7 +157,7 @@ impl FatcatApiClient {
EntityType::Release => {
match self.rt.block_on(
self.api
- .create_release(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_release(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateReleaseResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -166,7 +166,7 @@ impl FatcatApiClient {
EntityType::Work => {
match self.rt.block_on(
self.api
- .create_work(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_work(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateWorkResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -175,7 +175,7 @@ impl FatcatApiClient {
EntityType::Creator => {
match self.rt.block_on(
self.api
- .create_creator(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_creator(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateCreatorResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -184,7 +184,7 @@ impl FatcatApiClient {
EntityType::Container => {
match self.rt.block_on(
self.api
- .create_container(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_container(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateContainerResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -193,7 +193,7 @@ impl FatcatApiClient {
EntityType::File => {
match self.rt.block_on(
self.api
- .create_file(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_file(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateFileResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -202,7 +202,7 @@ impl FatcatApiClient {
EntityType::FileSet => {
match self.rt.block_on(
self.api
- .create_fileset(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_fileset(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateFilesetResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -211,7 +211,7 @@ impl FatcatApiClient {
EntityType::WebCapture => {
match self.rt.block_on(
self.api
- .create_webcapture(editgroup_id, serde_json::from_str(&json_str)?),
+ .create_webcapture(editgroup_id, serde_json::from_str(json_str)?),
)? {
fatcat_openapi::CreateWebcaptureResponse::CreatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -343,7 +343,7 @@ impl FatcatApiClient {
Release(fcid) => match self.rt.block_on(self.api.update_release(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateReleaseResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -351,7 +351,7 @@ impl FatcatApiClient {
Work(fcid) => match self.rt.block_on(self.api.update_work(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateWorkResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -359,7 +359,7 @@ impl FatcatApiClient {
Container(fcid) => match self.rt.block_on(self.api.update_container(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateContainerResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -367,7 +367,7 @@ impl FatcatApiClient {
Creator(fcid) => match self.rt.block_on(self.api.update_creator(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateCreatorResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -375,7 +375,7 @@ impl FatcatApiClient {
File(fcid) => match self.rt.block_on(self.api.update_file(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateFileResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -383,7 +383,7 @@ impl FatcatApiClient {
FileSet(fcid) => match self.rt.block_on(self.api.update_fileset(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateFilesetResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
@@ -391,7 +391,7 @@ impl FatcatApiClient {
WebCapture(fcid) => match self.rt.block_on(self.api.update_webcapture(
editgroup_id,
fcid,
- serde_json::from_str(&json_str)?,
+ serde_json::from_str(json_str)?,
))? {
fatcat_openapi::UpdateWebcaptureResponse::UpdatedEntity(ee) => Ok(ee),
other => Err(anyhow!("{:?}", other)),
diff --git a/fatcat-cli/src/commands.rs b/fatcat-cli/src/commands.rs
index da23c34..6558d52 100644
--- a/fatcat-cli/src/commands.rs
+++ b/fatcat-cli/src/commands.rs
@@ -211,7 +211,7 @@ pub fn print_changelog_entries(entry_list: Vec<models::ChangelogEntry>, json: bo
tw,
"{}\t{}\t{}\t{}",
entry.index,
- HumanTime::from(entry.timestamp).to_string(),
+ HumanTime::from(entry.timestamp),
entry
.editgroup
.as_ref()
@@ -264,7 +264,7 @@ pub fn print_entity_histories(
"{}\t{}\t{}\t{}\t{}",
history.changelog_entry.index,
state,
- HumanTime::from(history.changelog_entry.timestamp).to_string(),
+ HumanTime::from(history.changelog_entry.timestamp),
history
.editgroup
.editor
@@ -542,7 +542,7 @@ impl BatchGrouper {
.as_str()
.ok_or_else(|| anyhow!("expect entity JSON to have 'ident' field"))?;
let editgroup_id = self.increment_editgroup(api_client)?;
- let mut entity = entity_model_from_json_str(self.entity_type, &json_str)?;
+ let mut entity = entity_model_from_json_str(self.entity_type, json_str)?;
entity.mutate(mutations)?;
api_client.update_entity_from_json(
Specifier::from_ident(self.entity_type, ident.to_string()),
diff --git a/fatcat-cli/src/download.rs b/fatcat-cli/src/download.rs
index d8a6f8c..551d090 100644
--- a/fatcat-cli/src/download.rs
+++ b/fatcat-cli/src/download.rs
@@ -13,7 +13,7 @@ use std::path::PathBuf;
use std::thread;
use url::Url;
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum DownloadStatus {
Exists(String),
Downloaded(String),
@@ -286,7 +286,7 @@ pub fn download_release(
let mut status = DownloadStatus::NoPublicFile;
let specifier = re.specifier();
for fe in file_entities {
- status = download_file(&fe, &specifier, output_path.clone(), show_progress)?;
+ status = download_file(fe, &specifier, output_path.clone(), show_progress)?;
match status {
DownloadStatus::Exists(_) | DownloadStatus::Downloaded(_) => break,
_ => (),
diff --git a/fatcat-cli/src/entities.rs b/fatcat-cli/src/entities.rs
index a2a571f..7f88a8b 100644
--- a/fatcat-cli/src/entities.rs
+++ b/fatcat-cli/src/entities.rs
@@ -8,7 +8,7 @@ use std::io::{BufRead, Read};
use std::path::PathBuf;
use std::str::FromStr;
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Mutation {
field: String,
value: Option<String>,
@@ -99,25 +99,25 @@ pub fn entity_model_from_json_str(
) -> Result<Box<dyn ApiEntityModel>> {
match entity_type {
EntityType::Release => Ok(Box::new(serde_json::from_str::<models::ReleaseEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::Work => Ok(Box::new(serde_json::from_str::<models::WorkEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::Container => Ok(Box::new(serde_json::from_str::<models::ContainerEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::Creator => Ok(Box::new(serde_json::from_str::<models::CreatorEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::File => Ok(Box::new(serde_json::from_str::<models::FileEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::FileSet => Ok(Box::new(serde_json::from_str::<models::FilesetEntity>(
- &json_str,
+ json_str,
)?)),
EntityType::WebCapture => Ok(Box::new(serde_json::from_str::<models::WebcaptureEntity>(
- &json_str,
+ json_str,
)?)),
}
}
diff --git a/fatcat-cli/src/lib.rs b/fatcat-cli/src/lib.rs
index 6c1f449..17b3e0e 100644
--- a/fatcat-cli/src/lib.rs
+++ b/fatcat-cli/src/lib.rs
@@ -24,7 +24,7 @@ pub use entities::{
pub use search::{crude_search, SearchResults};
pub use specifier::{EditgroupSpecifier, Specifier};
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum EntityType {
Release,
Work,
@@ -52,7 +52,7 @@ impl FromStr for EntityType {
}
}
-#[derive(Debug, PartialEq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum SearchEntityType {
Release,
Container,
diff --git a/fatcat-cli/src/main.rs b/fatcat-cli/src/main.rs
index 5441f36..1d51729 100644
--- a/fatcat-cli/src/main.rs
+++ b/fatcat-cli/src/main.rs
@@ -644,9 +644,7 @@ fn run(opt: Opt) -> Result<()> {
let hit = hit?;
match (index_json, entity_json, entity_type) {
(false, false, _) => unreachable!("case handled above"),
- (true, _, _) => {
- writeln!(&mut std::io::stdout(), "{}", hit.to_string())?
- }
+ (true, _, _) => writeln!(&mut std::io::stdout(), "{}", hit)?,
(false, true, SearchEntityType::Release) => {
let specifier =
Specifier::Release(hit["ident"].as_str().unwrap().to_string());
diff --git a/fatcat-cli/src/specifier.rs b/fatcat-cli/src/specifier.rs
index 2b14e31..2b9d6a5 100644
--- a/fatcat-cli/src/specifier.rs
+++ b/fatcat-cli/src/specifier.rs
@@ -5,7 +5,7 @@ use regex::Regex;
use std::fmt;
use std::str::FromStr;
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum ReleaseLookupKey {
DOI,
PMCID,
@@ -27,7 +27,7 @@ impl fmt::Display for ReleaseLookupKey {
}
}
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum ContainerLookupKey {
ISSNL,
ISSNE,
@@ -46,7 +46,7 @@ impl fmt::Display for ContainerLookupKey {
}
}
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum CreatorLookupKey {
Orcid,
}
@@ -59,7 +59,7 @@ impl fmt::Display for CreatorLookupKey {
}
}
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum FileLookupKey {
SHA1,
SHA256,
@@ -76,7 +76,7 @@ impl fmt::Display for FileLookupKey {
}
}
-#[derive(Debug, PartialEq, Clone)]
+#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Specifier {
Release(String),
ReleaseLookup(ReleaseLookupKey, String),