Skip to content

Commit

Permalink
Merge pull request #1 from erikziyunchi/jmwample/re-org
Browse files Browse the repository at this point in the history
Reorganize
  • Loading branch information
jmwample authored Oct 18, 2023
2 parents eaefb44 + f6a6b87 commit aad0812
Show file tree
Hide file tree
Showing 76 changed files with 4,335 additions and 640 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,42 @@ env:
CARGO_TERM_COLOR: always

jobs:
format:
name: Verify code Fromatting
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- name: Format
run: cargo fmt --all -- --check

lint:
name: Lint with clippy
needs: format
strategy:
fail-fast: true
runs-on: "ubuntu-latest"
env:
RUSTFLAGS: -Dwarnings

steps:
- uses: actions/checkout@v3
- name: Lint
run: cargo clippy --workspace --all-targets --verbose --all-features

build:
name: Test and Build
needs: format
# needs: [format, lint]
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ "ubuntu-latest", "macos-latest" ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Test
run: cargo test --verbose --workspace --all-features
- name: Build
run: cargo build --verbose
- name: Test
run: cargo test --verbose
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*/target
/target
target
.DS_Store
.vscode
.vscode
Cargo.lock
51 changes: 10 additions & 41 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,44 +1,13 @@
[package]
name = "W-A-T-E-R"
version = "0.1.0"
author = "cerikccc@gmail.com"
edition = "2021"

[lib]
# crate-type = ["cdylib"]
name = "water"
path = "src/lib.rs"

[[bin]]
name = "water_cli"
path = "src/main.rs"

[dependencies]
anyhow = "1.0.7"
tracing = "0.1"
tracing-subscriber = "0.3.17"
clap = { version="4.2.1", features = ["derive"] }
wasmtime = "12.0.1"
wasmtime-wasi = "12.0.1"
wasi-common = "12.0.1"
wasmtime-wasi-threads = "12.0.1"
futures = "0.3"
cap-std = "2.0.0"
libc = "0.2.147"
serde = { version = "1.0", features = ["derive"] }
url = { version = "2.2.2", features = ["serde"] }
toml = "0.7.6"
once_cell = "1.13.0"
[workspace]
members = ["crates/*", "examples/water_bins/*", "examples/clients/*"]
# exclude = ["crates/foo", "path/to/other"]
default-members = ["crates/*"]
resolver="2"

bitflags = "2.4.0"

bincode = "1.3"

rustls = "0.20.6"
rustls-pemfile = "1.0.0"
zeroize = { version = "1.5.4", features = ["alloc"] }

# test & benchmark dependency
[dev-dependencies]
rand = "0.8"
pprof = { version = "0.11.1", features = ["flamegraph", "protobuf-codec", "prost-codec"] }
[workspace.package]
authors = ["cerikccc@gmail.com", "gaukas", "jmwample", "ewust"]
description = "Water WebAssembly Transport Executor for rust"
edition = "2021"
# documentation = "https://example.com/bar"
File renamed without changes.
32 changes: 32 additions & 0 deletions crates/water/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "water"
version = "0.1.0"
authors.workspace = true
description.workspace = true
edition.workspace = true

[lib]
# crate-type = ["cdylib"]
name = "water"
path = "src/lib.rs"

[dependencies]
anyhow = "1.0.7"
tracing = "0.1"
tracing-subscriber = "0.3.17"
wasmtime = "12.0.1"
wasmtime-wasi = "12.0.1"
wasi-common = "12.0.1"
wasmtime-wasi-threads = "12.0.1"
futures = "0.3"
cap-std = "2.0.0"
libc = "0.2.147"
serde = { version = "1.0", features = ["derive"] }
url = { version = "2.2.2", features = ["serde"] }
toml = "0.7.6"
once_cell = "1.13.0"
bitflags = "2.4.0"
bincode = "1.3"
rustls = "0.20.6"
rustls-pemfile = "1.0.0"
zeroize = { version = "1.5.4", features = ["alloc"] }
File renamed without changes.
27 changes: 27 additions & 0 deletions crates/water/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
pub mod wasm_shared_config;

pub struct WATERConfig {
pub filepath: String,
pub entry_fn: String,
pub config_wasm: String,
pub client_type: u32,
pub debug: bool,
}

impl WATERConfig {
pub fn init(
filepath: String,
entry_fn: String,
config_wasm: String,
client_type: u32,
debug: bool,
) -> Result<Self, anyhow::Error> {
Ok(WATERConfig {
filepath,
entry_fn,
config_wasm,
client_type,
debug,
})
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
use serde::{Deserialize, Serialize};
use std::mem;
use serde::{Serialize, Deserialize};

#[repr(C)]
pub struct WASMSharedConfig {

// pub key: u64, // a pointer to a key string's byte-view
// pub size: u64, // size for the key
// pub key: u64, // a pointer to a key string's byte-view
// pub size: u64, // size for the key
}

impl WASMSharedConfig {
pub fn to_bytes(&self) -> Vec<u8> {
let size = mem::size_of::<WASMSharedConfig>();
let ptr = self as *const Self;

let bytes_slice = unsafe { std::slice::from_raw_parts(ptr as *const u8, size) };
let bytes = bytes_slice.to_vec();
bytes
bytes_slice.to_vec()
}

// pub fn from_bytes(bytes: Vec<u8>) -> Option<Self> {
Expand All @@ -42,9 +40,8 @@ impl StreamConfig {
pub fn to_bytes(&self) -> Vec<u8> {
let size = mem::size_of::<StreamConfig>();
let ptr = self as *const Self;

let bytes_slice = unsafe { std::slice::from_raw_parts(ptr as *const u8, size) };
let bytes = bytes_slice.to_vec();
bytes
bytes_slice.to_vec()
}
}
1 change: 1 addition & 0 deletions crates/water/src/errors/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 3 additions & 1 deletion src/globals.rs → crates/water/src/globals.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![allow(dead_code)]

pub const WASM_PATH: &str = "./proxy.wasm";
pub const CONFIF_WASM_PATH: &str = "./conf.json";
pub const CONFIG_WASM_PATH: &str = "./conf.json";

const ALLOC_FN: &str = "alloc";
const MEMORY: &str = "memory";
Expand Down
14 changes: 14 additions & 0 deletions crates/water/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
extern crate anyhow;
extern crate cap_std;
extern crate serde;
extern crate tracing;
extern crate wasi_common;
extern crate wasmtime;
extern crate wasmtime_wasi;
extern crate wasmtime_wasi_threads;

pub mod config;
pub mod errors;
pub mod globals;
pub mod runtime;
pub mod utils;
Loading

0 comments on commit aad0812

Please sign in to comment.