Fix future clippy linting warnings (#1423)

This commit is contained in:
George 2022-12-18 18:00:36 +02:00 committed by GitHub
parent cef01ad790
commit a2038f239b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 20 deletions

View file

@ -41,10 +41,10 @@ fn backup_http_to_file(matches: &clap::ArgMatches, from: &str, into: &str) -> Re
// Parse the specified password // Parse the specified password
let pass = matches.value_of("pass").unwrap(); let pass = matches.value_of("pass").unwrap();
// Set the correct source URL // Set the correct source URL
let from = format!("{}/sync", from); let from = format!("{from}/sync");
// Try to open the source http // Try to open the source http
let mut from = Client::new() let mut from = Client::new()
.get(&from) .get(from)
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header(CONTENT_TYPE, TYPE) .header(CONTENT_TYPE, TYPE)
.send()? .send()?
@ -65,10 +65,10 @@ fn backup_file_to_http(matches: &clap::ArgMatches, from: &str, into: &str) -> Re
// Try to open the source file // Try to open the source file
let from = OpenOptions::new().read(true).open(from)?; let from = OpenOptions::new().read(true).open(from)?;
// Set the correct output URL // Set the correct output URL
let into = format!("{}/sync", into); let into = format!("{into}/sync");
// Copy the data to the destination // Copy the data to the destination
Client::new() Client::new()
.post(&into) .post(into)
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header(CONTENT_TYPE, TYPE) .header(CONTENT_TYPE, TYPE)
.body(from) .body(from)
@ -84,19 +84,19 @@ fn backup_http_to_http(matches: &clap::ArgMatches, from: &str, into: &str) -> Re
// Parse the specified password // Parse the specified password
let pass = matches.value_of("pass").unwrap(); let pass = matches.value_of("pass").unwrap();
// Set the correct source URL // Set the correct source URL
let from = format!("{}/sync", from); let from = format!("{from}/sync");
// Set the correct output URL // Set the correct output URL
let into = format!("{}/sync", into); let into = format!("{into}/sync");
// Try to open the source file // Try to open the source file
let from = Client::new() let from = Client::new()
.get(&from) .get(from)
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header(CONTENT_TYPE, TYPE) .header(CONTENT_TYPE, TYPE)
.send()? .send()?
.error_for_status()?; .error_for_status()?;
// Copy the data to the destination // Copy the data to the destination
Client::new() Client::new()
.post(&into) .post(into)
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header(CONTENT_TYPE, TYPE) .header(CONTENT_TYPE, TYPE)
.body(Body::new(from)) .body(Body::new(from))

View file

@ -18,10 +18,10 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
let ns = matches.value_of("ns").unwrap(); let ns = matches.value_of("ns").unwrap();
let db = matches.value_of("db").unwrap(); let db = matches.value_of("db").unwrap();
// Set the correct export URL // Set the correct export URL
let conn = format!("{}/export", conn); let conn = format!("{conn}/export");
// Export the data from the database // Export the data from the database
let mut res = Client::new() let mut res = Client::new()
.get(&conn) .get(conn)
.header(ACCEPT, "application/octet-stream") .header(ACCEPT, "application/octet-stream")
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header("NS", ns) .header("NS", ns)

View file

@ -22,10 +22,10 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
let ns = matches.value_of("ns").unwrap(); let ns = matches.value_of("ns").unwrap();
let db = matches.value_of("db").unwrap(); let db = matches.value_of("db").unwrap();
// Set the correct import URL // Set the correct import URL
let conn = format!("{}/import", conn); let conn = format!("{conn}/import");
// Import the data into the database // Import the data into the database
let res = Client::new() let res = Client::new()
.post(&conn) .post(conn)
.header(ACCEPT, "application/octet-stream") .header(ACCEPT, "application/octet-stream")
.basic_auth(user, Some(pass)) .basic_auth(user, Some(pass))
.header("NS", ns) .header("NS", ns)

View file

@ -19,7 +19,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
// If we should pretty-print responses // If we should pretty-print responses
let pretty = matches.is_present("pretty"); let pretty = matches.is_present("pretty");
// Set the correct import URL // Set the correct import URL
let conn = format!("{}/sql", conn); let conn = format!("{conn}/sql");
// Create a new terminal REPL // Create a new terminal REPL
let mut rl = Editor::<()>::new().unwrap(); let mut rl = Editor::<()>::new().unwrap();
// Load the command-line history // Load the command-line history
@ -57,8 +57,8 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
let res = res.body(line).send(); let res = res.body(line).send();
// Get the request response // Get the request response
match process(pretty, res) { match process(pretty, res) {
Ok(v) => println!("{}", v), Ok(v) => println!("{v}"),
Err(e) => eprintln!("{}", e), Err(e) => eprintln!("{e}"),
} }
} }
// The user types CTRL-C // The user types CTRL-C
@ -71,7 +71,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
} }
// There was en error // There was en error
Err(err) => { Err(err) => {
eprintln!("Error: {:?}", err); eprintln!("Error: {err:?}");
break; break;
} }
} }

View file

@ -19,7 +19,7 @@ pub async fn init(matches: &clap::ArgMatches) -> Result<(), Error> {
_ => unreachable!(), _ => unreachable!(),
}; };
// Output SurrealDB logo // Output SurrealDB logo
println!("{}", LOGO); println!("{LOGO}");
// Setup the cli options // Setup the cli options
config::init(matches); config::init(matches);
// Initiate environment // Initiate environment

View file

@ -9,7 +9,7 @@ const SERVER: &str = "Server";
const VERSION: &str = "Version"; const VERSION: &str = "Version";
pub fn version() -> warp::filters::reply::WithHeader { pub fn version() -> warp::filters::reply::WithHeader {
let val = format!("{}-{}", PKG_NAME, *PKG_VERSION); let val = format!("{PKG_NAME}-{}", *PKG_VERSION);
warp::reply::with::header(VERSION, val) warp::reply::with::header(VERSION, val)
} }

View file

@ -284,7 +284,7 @@ impl Rpc {
}, },
// Get the current server version // Get the current server version
"version" => match params.len() { "version" => match params.len() {
0 => Ok(format!("{}-{}", PKG_NAME, *PKG_VERSION).into()), 0 => Ok(format!("{PKG_NAME}-{}", *PKG_VERSION).into()),
_ => return res::failure(id, Failure::INVALID_PARAMS).send(out, chn).await, _ => return res::failure(id, Failure::INVALID_PARAMS).send(out, chn).await,
}, },
// Run a full SurrealQL query against the database // Run a full SurrealQL query against the database

View file

@ -8,6 +8,6 @@ pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejecti
} }
pub async fn handler() -> Result<impl warp::Reply, warp::Rejection> { pub async fn handler() -> Result<impl warp::Reply, warp::Rejection> {
let val = format!("{}-{}", PKG_NAME, *PKG_VERSION); let val = format!("{PKG_NAME}-{}", *PKG_VERSION);
Ok(warp::reply::with_status(val, http::StatusCode::OK)) Ok(warp::reply::with_status(val, http::StatusCode::OK))
} }