meta: appease clippy

pull/239/head
Jake McGinty 2022-09-23 23:43:33 -04:00
parent eb5b5370df
commit b39b77aa5a
7 changed files with 12 additions and 9 deletions

View File

@ -211,10 +211,12 @@ impl<'a> Api<'a> {
Self { agent, server } Self { agent, server }
} }
#[allow(clippy::result_large_err)]
pub fn http<T: DeserializeOwned>(&self, verb: &str, endpoint: &str) -> Result<T, ureq::Error> { pub fn http<T: DeserializeOwned>(&self, verb: &str, endpoint: &str) -> Result<T, ureq::Error> {
self.request::<(), _>(verb, endpoint, None) self.request::<(), _>(verb, endpoint, None)
} }
#[allow(clippy::result_large_err)]
pub fn http_form<S: Serialize, T: DeserializeOwned>( pub fn http_form<S: Serialize, T: DeserializeOwned>(
&self, &self,
verb: &str, verb: &str,
@ -224,6 +226,7 @@ impl<'a> Api<'a> {
self.request(verb, endpoint, Some(form)) self.request(verb, endpoint, Some(form))
} }
#[allow(clippy::result_large_err)]
fn request<S: Serialize, T: DeserializeOwned>( fn request<S: Serialize, T: DeserializeOwned>(
&self, &self,
verb: &str, verb: &str,

View File

@ -266,7 +266,7 @@ impl HostsBuilder {
fn write_and_swap(temp_path: &Path, hosts_path: &Path, contents: &[u8]) -> io::Result<()> { fn write_and_swap(temp_path: &Path, hosts_path: &Path, contents: &[u8]) -> io::Result<()> {
// Copy the file we plan on modifying so its permissions and metadata are preserved. // Copy the file we plan on modifying so its permissions and metadata are preserved.
std::fs::copy(&hosts_path, &temp_path)?; std::fs::copy(hosts_path, temp_path)?;
Self::write_clobber(temp_path, contents)?; Self::write_clobber(temp_path, contents)?;
std::fs::rename(temp_path, hosts_path)?; std::fs::rename(temp_path, hosts_path)?;
Ok(()) Ok(())

View File

@ -28,7 +28,7 @@ pub fn auto_migrate(conn: &rusqlite::Connection) -> Result<(), rusqlite::Error>
} }
if old_version != CURRENT_VERSION { if old_version != CURRENT_VERSION {
conn.pragma_update(None, "user_version", &CURRENT_VERSION)?; conn.pragma_update(None, "user_version", CURRENT_VERSION)?;
log::info!( log::info!(
"migrated db version from {} to {}", "migrated db version from {} to {}",
old_version, old_version,

View File

@ -16,11 +16,11 @@ fn create_database<P: AsRef<Path>>(
database_path: P, database_path: P,
) -> Result<Connection, Box<dyn std::error::Error>> { ) -> Result<Connection, Box<dyn std::error::Error>> {
let conn = Connection::open(&database_path)?; let conn = Connection::open(&database_path)?;
conn.pragma_update(None, "foreign_keys", &1)?; conn.pragma_update(None, "foreign_keys", 1)?;
conn.execute(db::peer::CREATE_TABLE_SQL, params![])?; conn.execute(db::peer::CREATE_TABLE_SQL, params![])?;
conn.execute(db::association::CREATE_TABLE_SQL, params![])?; conn.execute(db::association::CREATE_TABLE_SQL, params![])?;
conn.execute(db::cidr::CREATE_TABLE_SQL, params![])?; conn.execute(db::cidr::CREATE_TABLE_SQL, params![])?;
conn.pragma_update(None, "user_version", &db::CURRENT_VERSION)?; conn.pragma_update(None, "user_version", db::CURRENT_VERSION)?;
log::debug!("set database version to db::CURRENT_VERSION"); log::debug!("set database version to db::CURRENT_VERSION");
Ok(conn) Ok(conn)

View File

@ -199,7 +199,7 @@ impl ConfigFile {
path.display() path.display()
); );
} }
Ok(toml::from_slice(&std::fs::read(&path).with_path(path)?)?) Ok(toml::from_slice(&std::fs::read(path).with_path(path)?)?)
} }
} }
@ -303,7 +303,7 @@ fn open_database_connection(
let conn = Connection::open(&database_path)?; let conn = Connection::open(&database_path)?;
// Foreign key constraints aren't on in SQLite by default. Enable. // Foreign key constraints aren't on in SQLite by default. Enable.
conn.pragma_update(None, "foreign_keys", &1)?; conn.pragma_update(None, "foreign_keys", 1)?;
db::auto_migrate(&conn)?; db::auto_migrate(&conn)?;
Ok(conn) Ok(conn)
} }
@ -656,7 +656,7 @@ fn get_listener(addr: SocketAddr, interface: &InterfaceName) -> Result<TcpListen
/// See https://github.com/tonarino/innernet/issues/26 for more details. /// See https://github.com/tonarino/innernet/issues/26 for more details.
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
fn get_listener(addr: SocketAddr, _interface: &InterfaceName) -> Result<TcpListener, Error> { fn get_listener(addr: SocketAddr, _interface: &InterfaceName) -> Result<TcpListener, Error> {
let listener = TcpListener::bind(&addr)?; let listener = TcpListener::bind(addr)?;
listener.set_nonblocking(true)?; listener.set_nonblocking(true)?;
Ok(listener) Ok(listener)
} }

View File

@ -282,7 +282,7 @@ fn start_userspace_wireguard(iface: &InterfaceName) -> io::Result<Output> {
"WG_TUN_NAME_FILE", "WG_TUN_NAME_FILE",
&format!("{}/{}.name", VAR_RUN_PATH, iface), &format!("{}/{}.name", VAR_RUN_PATH, iface),
) )
.args(&["utun"]) .args(["utun"])
.output()? .output()?
}; };
if !output.status.success() { if !output.status.success() {

View File

@ -79,7 +79,7 @@ impl Key {
/// Converts the key to a standardized base64 representation, as used by the `wg` utility and `wg-quick`. /// Converts the key to a standardized base64 representation, as used by the `wg` utility and `wg-quick`.
pub fn to_base64(&self) -> String { pub fn to_base64(&self) -> String {
base64::encode(&self.0) base64::encode(self.0)
} }
/// Converts a base64 representation of the key to the raw bytes. /// Converts a base64 representation of the key to the raw bytes.