-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into wasm-action
- Loading branch information
Showing
95 changed files
with
4,872 additions
and
2,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,5 @@ Cargo.lock | |
|
||
*.csv | ||
|
||
# Compiled wasm | ||
www/wasm | ||
# Built wasm files | ||
built-wasm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Examples | ||
|
||
Example usages of warp-ipfs | ||
|
||
## Using from Rust (desktop) | ||
|
||
CLI for interacting with Multipass (identity): | ||
``` | ||
cargo run --example identity-interface | ||
``` | ||
|
||
Basic ipfs setup example: | ||
``` | ||
cargo run --example ipfs-example | ||
``` | ||
|
||
Basic friends example: | ||
``` | ||
cargo run --example ipfs-friends | ||
``` | ||
|
||
Basic identity example: | ||
``` | ||
cargo run --example ipfs-identity | ||
``` | ||
|
||
CLI for interacting with Constellation (file management): | ||
``` | ||
cargo run --example ipfs-persisent | ||
``` | ||
|
||
CLI messenger example: | ||
``` | ||
cargo run --example messenger | ||
``` | ||
|
||
## Using from Rust (WASM) | ||
|
||
[wasm-ipfs-friends](./wasm-ipfs-friends/README.md) | ||
|
||
[wasm-ipfs-identity](./wasm-ipfs-identity/README.md) | ||
|
||
[wasm-ipfs-storage](./wasm-ipfs-storage/README.md) | ||
|
||
## Using from Javascript | ||
|
||
Serves web files that contain examples of javascript calling into wasm built from `warp-ipfs`: | ||
``` | ||
cargo run --example from-js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::process::Command; | ||
use tiny_file_server::FileServer; | ||
use tracing_subscriber::{filter::LevelFilter, EnvFilter}; | ||
|
||
const ADDR: &str = "127.0.0.1:9080"; | ||
const PATH: &str = "extensions/warp-ipfs/examples/from-js"; | ||
|
||
fn main() { | ||
//set up logger so we can get an output from tiny_file_server | ||
tracing_subscriber::fmt() | ||
.with_env_filter( | ||
EnvFilter::builder() | ||
.with_default_directive(LevelFilter::INFO.into()) | ||
.from_env_lossy(), | ||
) | ||
.init(); | ||
|
||
println!("\nInstalling wasm-pack ..."); | ||
let cmd = get_cmd("cargo install wasm-pack"); | ||
spawn_and_wait(cmd); | ||
|
||
println!("\nBuilding warp-ipfs wasm files ..."); | ||
let cmd = get_cmd("wasm-pack build extensions/warp-ipfs --target web --out-dir examples/from-js/built-wasm/warp-ipfs"); | ||
spawn_and_wait(cmd); | ||
|
||
println!("\nStarting file server ..."); | ||
FileServer::http(ADDR) | ||
.expect("Server should be created") | ||
.run(PATH) | ||
.expect("Server should start"); | ||
} | ||
|
||
// assumes all spaces are argument separators. args containing spaces will yield unexpected results (such as strings) | ||
fn get_cmd(cmd_str: &str) -> Command { | ||
let mut split = cmd_str.split(' '); | ||
|
||
// first item is the program, then the rest of the items are the args | ||
let mut cmd = Command::new(split.next().unwrap()); | ||
for arg in split { | ||
cmd.arg(arg); | ||
} | ||
cmd | ||
} | ||
|
||
fn spawn_and_wait(mut cmd: Command) { | ||
let status = cmd | ||
.spawn() | ||
.expect("command failed to start") | ||
.wait() | ||
.expect("failed to get ExitStatus"); | ||
|
||
if !status.success() { | ||
panic!("cmd ExitStatus not successful"); | ||
}; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.