-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from sminez/ninep-sansio
A sans-io API for ninep
- Loading branch information
Showing
29 changed files
with
3,747 additions
and
1,834 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ad_client" | ||
version = "0.3.0" | ||
version = "0.3.1" | ||
edition = "2021" | ||
authors = ["sminez <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -19,4 +19,4 @@ categories = [ "development-tools", "text-editors", "command-line-utilities" ] | |
|
||
[dependencies] | ||
ad_event = { version = "0.3", path = "../ad_event" } | ||
ninep = { version = "0.3", path = "../ninep" } | ||
ninep = { version = "0.4", path = "../ninep" } |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ninep" | ||
version = "0.3.0" | ||
version = "0.4.0" | ||
edition = "2021" | ||
authors = ["sminez <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -13,8 +13,15 @@ include = [ | |
"README.md" | ||
] | ||
|
||
[features] | ||
default = ["tokio"] | ||
tokio = ["dep:tokio"] | ||
|
||
[dependencies] | ||
bitflags = "2.6" | ||
tokio = { version = "1.43.0", features = ["macros", "net", "io-util", "rt", "sync"], optional = true } | ||
simple_coro = "0.1" | ||
|
||
[dev-dependencies] | ||
simple_test_case = "1" | ||
tokio = { version = "1.43.0", features = ["macros", "net", "io-util", "rt", "sync", "time", "rt-multi-thread", "net", "io-util"] } |
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,33 @@ | ||
//! A simple demo of the 9p client interface | ||
use ninep::{fs::FileType, tokio::client::UnixClient}; | ||
use std::io; | ||
|
||
#[tokio::main] | ||
async fn main() -> io::Result<()> { | ||
let mut client = UnixClient::new_unix("ninep-server", "").await?; | ||
tree(&mut client, "", 0).await?; | ||
|
||
let mut stream = client.stream_lines("blocking").await?; | ||
while let Some(line) = stream.next().await { | ||
println!("{line}"); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn tree(client: &mut UnixClient, path: &str, depth: usize) -> io::Result<()> { | ||
for stat in client.read_dir(path).await? { | ||
let name = stat.fm.name; | ||
println!("{:indent$}{name}", "", indent = depth * 2); | ||
if stat.fm.ty == FileType::Directory { | ||
let child = if path.is_empty() { | ||
name | ||
} else { | ||
format!("{path}/{name}") | ||
}; | ||
Box::pin(tree(client, &child, depth + 1)).await?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.