https://github.com/golemfactory/gwasm-rust-api
gWasm API for Rust apps
https://github.com/golemfactory/gwasm-rust-api
gwasm-api rust-apps
Last synced: 8 months ago
JSON representation
gWasm API for Rust apps
- Host: GitHub
- URL: https://github.com/golemfactory/gwasm-rust-api
- Owner: golemfactory
- License: gpl-3.0
- Created: 2019-08-21T13:31:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T10:40:11.000Z (about 6 years ago)
- Last Synced: 2024-10-01T04:29:41.789Z (over 1 year ago)
- Topics: gwasm-api, rust-apps
- Language: Rust
- Homepage:
- Size: 1.4 MB
- Stars: 2
- Watchers: 7
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[gWasm](https://docs.golem.network/#/Products/Brass-Beta/gWASM) is Golem's new
meta use-case which allows Golem's developers/users to deploy their Wasm apps
on Golem Network. This API providers convenience structures and functions for
creating a gWasm task and connecting with Golem Network all from native Rust code.
```toml
# Cargo.toml
gwasm-api = "0.3"
```
## Example
```rust
use gwasm_api::prelude::*;
use anyhow::Result;
use std::path::PathBuf;
struct ProgressTracker;
impl ProgressUpdate for ProgressTracker {
fn update(&self, progress: f64) {
println!("Current progress = {}", progress);
}
}
fn main() -> Result<()> {
let binary = GWasmBinary {
js: &[0u8; 100], // JavaScript file generated by Emscripten
wasm: &[0u8; 100], // Wasm binary generated by Emscripten
};
let task = TaskBuilder::try_new("workspace", binary)?
.push_subtask_data(vec![0u8; 100])
.build()?;
let computed_task = compute(
PathBuf::from("datadir"),
"127.0.0.1".to_string(),
61000,
Net::TestNet,
task,
ProgressTracker,
)?;
for subtask in computed_task.subtasks {
for (_, reader) in subtask.data {
assert!(!reader.buffer().is_empty());
}
}
Ok(())
}
```
## More examples
* [g-flite](https://github.com/golemfactory/g-flite) is a CLI which uses `gwasm-api`
internally
## License
Licensed under [GPLv3](LICENSE)