Skip to content

Commit

Permalink
update: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Chi committed Oct 30, 2023
1 parent 582d24d commit 0302fa0
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion crates/water/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod wasm_shared_config;

use crate::runtime::version::Version;


pub struct WATERConfig {
pub filepath: String,
Expand Down
4 changes: 2 additions & 2 deletions crates/water/src/runtime/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::thread::JoinHandle;


use crate::runtime::*;
use stream::WATERStreamTrait;
Expand Down Expand Up @@ -71,7 +71,7 @@ impl WATERClient {
match &mut self.stream {
WATERClientType::Dialer(dialer) => dialer.run_entry_fn(&self.config),
_ => {
return Err(anyhow::anyhow!("This client is not a Runner"));
Err(anyhow::anyhow!("This client is not a Runner"))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/water/src/runtime/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl WATERListener<Host> {
Ok(())
}

pub fn init(conf: &WATERConfig, mut core: H2O<Host>) -> Result<Self, anyhow::Error> {
pub fn init(_conf: &WATERConfig, core: H2O<Host>) -> Result<Self, anyhow::Error> {
info!("[HOST] WATERStream init...");

// constructing 2 pairs of UnixStream for communicating between WASM and Host
Expand All @@ -171,8 +171,8 @@ impl WATERListener<Host> {
std::mem::forget(water_writer);
std::mem::forget(water_reader);

let mut reader;
let mut writer;
let reader;
let writer;

{
let mut store = core
Expand Down
2 changes: 1 addition & 1 deletion crates/water/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl WATERRunner<Host> {
Ok(())
}

pub fn init(conf: &WATERConfig, mut core: H2O<Host>) -> Result<Self, anyhow::Error> {
pub fn init(_conf: &WATERConfig, core: H2O<Host>) -> Result<Self, anyhow::Error> {
info!("[HOST] WATERRunner init...");

let runtime = WATERRunner { core };
Expand Down
10 changes: 5 additions & 5 deletions crates/water/src/runtime/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ use crate::runtime::*;
pub trait WATERStreamTrait: Send {
fn connect(&mut self, conf: &WATERConfig, _addr: &str, _port: u16)
-> Result<(), anyhow::Error>;
fn cancel_with(&mut self, conf: &WATERConfig) -> Result<(), anyhow::Error> {
fn cancel_with(&mut self, _conf: &WATERConfig) -> Result<(), anyhow::Error> {
Err(anyhow::anyhow!("Method not supported"))
}
fn cancel(&mut self, conf: &WATERConfig) -> Result<(), anyhow::Error> {
fn cancel(&mut self, _conf: &WATERConfig) -> Result<(), anyhow::Error> {
Err(anyhow::anyhow!("Method not supported"))
}
fn run_entry_fn(
&mut self,
conf: &WATERConfig,
_conf: &WATERConfig,
) -> Result<std::thread::JoinHandle<Result<(), anyhow::Error>>, anyhow::Error> {
Err(anyhow::anyhow!("Method not supported"))
}
fn read(&mut self, buf: &mut Vec<u8>) -> Result<i64, anyhow::Error> {
fn read(&mut self, _buf: &mut Vec<u8>) -> Result<i64, anyhow::Error> {
Err(anyhow::anyhow!("Method not supported"))
}
fn write(&mut self, buf: &[u8]) -> Result<(), anyhow::Error> {
fn write(&mut self, _buf: &[u8]) -> Result<(), anyhow::Error> {
Err(anyhow::anyhow!("Method not supported"))
}
}
2 changes: 1 addition & 1 deletion crates/water/src/runtime/v0/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn export_accept(linker: &mut Linker<Host>, config: Arc<Mutex<V0Config>>) {
// TODO: implement this
pub fn export_defer(linker: &mut Linker<Host>, config: Arc<Mutex<V0Config>>) {
linker
.func_wrap("env", "host_defer", move |mut caller: Caller<'_, Host>| {
.func_wrap("env", "host_defer", move |_caller: Caller<'_, Host>| {
info!("[WASM] invoking Host exported host_defer func...");

let mut config = config.lock().unwrap();
Expand Down
22 changes: 11 additions & 11 deletions crates/water/src/runtime/v0/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl WATERStreamTrait for WATERStream<Host> {
/// Connect to the target address with running the WASM connect function
fn connect(
&mut self,
conf: &WATERConfig,
_conf: &WATERConfig,
_addr: &str,
_port: u16,
) -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -87,7 +87,7 @@ impl WATERStreamTrait for WATERStream<Host> {
Ok(())
}

fn cancel_with(&mut self, conf: &WATERConfig) -> Result<(), anyhow::Error> {
fn cancel_with(&mut self, _conf: &WATERConfig) -> Result<(), anyhow::Error> {
info!("[HOST] WATERStream v0 cancel_with...");

let (caller_io, water_io) = UnixStream::pair()?;
Expand Down Expand Up @@ -147,7 +147,7 @@ impl WATERStreamTrait for WATERStream<Host> {
Ok(())
}

fn cancel(&mut self, conf: &WATERConfig) -> Result<(), anyhow::Error> {
fn cancel(&mut self, _conf: &WATERConfig) -> Result<(), anyhow::Error> {
info!("[HOST] WATERStream v0 cancel...");

match self.cancel_io {
Expand All @@ -156,15 +156,15 @@ impl WATERStreamTrait for WATERStream<Host> {
match cancel_io.write_all(&[0]) {
Ok(_) => Ok(()),
Err(e) => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"failed to write to cancel_io: {}",
e
)))
}
}
}
None => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"cancel function failed: {}",
"cancel_io is None"
)))
Expand Down Expand Up @@ -204,7 +204,7 @@ impl WATERStreamTrait for WATERStream<Host> {
let mut res = vec![Val::I32(0); entry_fn.ty(&mut *store).results().len()];
match entry_fn.call(&mut *store, &[], &mut res) {
Ok(_) => Ok(()),
Err(e) => return Err(anyhow::Error::msg(format!("function failed: {}", e))),
Err(e) => Err(anyhow::Error::msg(format!("function failed: {}", e))),
}
});

Expand All @@ -219,14 +219,14 @@ impl WATERStreamTrait for WATERStream<Host> {
Some(ref mut caller_io) => match caller_io.read(buf) {
Ok(n) => Ok(n as i64),
Err(e) => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"failed to read from caller_reader: {}",
e
)))
}
},
None => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"read function failed: {}",
"caller_io is None"
)))
Expand All @@ -242,14 +242,14 @@ impl WATERStreamTrait for WATERStream<Host> {
Some(ref mut caller_io) => match caller_io.write_all(buf) {
Ok(_) => Ok(()),
Err(e) => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"failed to write to caller_writer: {}",
e
)))
}
},
None => {
return Err(anyhow::Error::msg(format!(
Err(anyhow::Error::msg(format!(
"write function failed: {}",
"caller_io is None"
)))
Expand All @@ -259,7 +259,7 @@ impl WATERStreamTrait for WATERStream<Host> {
}

impl WATERStream<Host> {
pub fn init(conf: &WATERConfig, mut core: H2O<Host>) -> Result<Self, anyhow::Error> {
pub fn init(_conf: &WATERConfig, core: H2O<Host>) -> Result<Self, anyhow::Error> {
info!("[HOST] WATERStream v0_init...");

let runtime = WATERStream {
Expand Down
6 changes: 3 additions & 3 deletions crates/water/src/runtime/v1/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl WATERStreamTrait for WATERStream<Host> {
}

impl WATERStream<Host> {
pub fn init(conf: &WATERConfig, mut core: H2O<Host>) -> Result<Self, anyhow::Error> {
pub fn init(_conf: &WATERConfig, core: H2O<Host>) -> Result<Self, anyhow::Error> {
info!("[HOST] WATERStream v0_init...");

// constructing a pair of UnixStream for communicating between WASM and Host
Expand All @@ -184,8 +184,8 @@ impl WATERStream<Host> {

std::mem::forget(water_io); // forget the water_io, so that it won't be closed

let mut reader;
let mut writer;
let reader;
let writer;

{
let mut store = core
Expand Down
4 changes: 2 additions & 2 deletions crates/water/src/runtime/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Version {
pub fn as_str(&self) -> &'static str {
match self {
Version::Unknown => "_water_setting_up",
Version::V0(v0_conf) => "_water_v0",
Version::V0(_v0_conf) => "_water_v0",
Version::V1 => "_water_v1",
Version::V2 => "_water_v2",
}
Expand All @@ -82,7 +82,7 @@ impl From<&Version> for &'static str {
fn from(v: &Version) -> &'static str {
match v {
Version::Unknown => "_water_setting_up",
Version::V0(v0_conf) => "_water_v0",
Version::V0(_v0_conf) => "_water_v0",
Version::V1 => "_water_v1",
Version::V2 => "_water_v2",
}
Expand Down
2 changes: 1 addition & 1 deletion tests/benches/benchmarking_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn benchmarking_v0_echo() -> Result<(), anyhow::Error> {
config::WaterBinType::Dial,
true,
)?;
let mut water_client = runtime::WATERClient::new(conf)?;
let mut water_client = runtime::client::WATERClient::new(conf)?;
water_client.connect("", 0)?;

// let mut water_client = TcpStream::connect(("127.0.0.1", 8088))?;
Expand Down

0 comments on commit 0302fa0

Please sign in to comment.