| Crates.io | yosemite |
| lib.rs | yosemite |
| version | 0.5.0 |
| created_at | 2024-10-23 17:18:21.912525+00 |
| updated_at | 2025-06-28 12:19:24.024224+00 |
| description | Asynchronous SAMv3 library |
| homepage | |
| repository | https://github.com/altonen/yosemite |
| max_upload_size | |
| id | 1420405 |
| size | 227,867 |
yosemite is a SAMv3 client library for interacting with the I2P network.
It provides synchronous and asynchronous APIs and supports both tokio and smol.
Read/Write for synchronous streamsAsyncRead/AsyncWrite for tokio streamsAsyncRead/AsyncWrite for smol streamstokio is enabled by default:
yosemite = "0.5.0"
sync enables synchronous APIs:
yosemite = { version = "0.5.0", default-features = false, features = ["sync"] }
smol enables asynchronous APIs implemented with smol:
yosemite = { version = "0.5.0", default-features = false, features = ["smol"] }
tokio, smol, and sync are all mutually exclusive and only one them can be enabled. The APIs are otherwise the same but tokio and smol require blocking calls to .await.
use tokio::io::AsyncReadExt;
use yosemite::{style::Stream, Session};
#[tokio::main]
async fn main() -> yosemite::Result<()> {
let mut session = Session::<Stream>::new(Default::default()).await?;
while let Ok(mut stream) = session.accept().await {
println!("{} connected", stream.remote_destination());
tokio::spawn(async move {
let mut buffer = vec![0u8; 512];
while let Ok(nread) = stream.read(&mut buffer).await {
println!(
"client sent: {:?}",
std::str::from_utf8(&buffer[..nread])
);
}
});
}
Ok(())
}
See examples for instructions on how to use yosemite.
MIT