Skip to content

Commit

Permalink
fix: remove unneeded features of tokio
Browse files Browse the repository at this point in the history
  • Loading branch information
threadexio committed Dec 17, 2023
1 parent 9b91b9f commit 0bd4c6e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,52 @@

Sender/Receiver types for communicating with a channel-like API across generic IO streams. It takes the burden on serializing, deserializing and transporting data off your back and let's you focus on the important logic of your project. It is:

- **Fast**: The simple protocol allows lower-overhead parsing of data.
- **Fast**: The simple protocol allows low-overhead transporting of data.

- **Minimal**: Channels can be used in `no_std` environments with only a memory allocator.
- **Modular**: Channels' _sans-io_ approach means it can be used on top of any medium, be it a network socket, a pipe, a shared memory region, a file, anything.

- **Light**: Channels' low memory usage means it can run in constrained embedded environments.
- **Ergonomic**: The API offered empowers you to use your time on building the logic of your application instead of worrying about data transport.

- **Async & sync first**: Channels' natively supports both synchronous and asynchronous operation with no hacky workarounds like spawning threads or running a separate runtime.

# In action

```rust no_run
use tokio::net::TcpStream;

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
enum Message {
Ping,
Pong
}

#[tokio::main]
async fn main() {
let stream = TcpStream::connect("127.0.0.1:8080").await.unwrap();
let (r, w) = stream.into_split();
let (mut tx, mut rx) = channels::channel::<Message, _, _>(r, w);

loop {
match rx.recv().await.unwrap() {
Message::Ping => {
println!("pinged!");
tx.send(Message::Pong).await.unwrap();
}
Message::Pong => {
println!("ponged!");
}
}
}
}
```

For more, see: [examples/](https://github.com/threadexio/channels-rs/tree/master/examples)

Some more complete examples:

- [chat-app](./examples/chat-app)

# How it works

Expand All @@ -44,10 +85,6 @@ Channels implements a communication protocol that allows sending and receiving d

You can find out more about how the underlying communication protocol works [here](./spec/PROTOCOL.md).

# Examples

See: [examples/](https://github.com/threadexio/channels-rs/tree/master/examples)

# License

- All code in this repository is licensed under the MIT license, a copy of which can be found [here](./LICENSE).
Expand Down
2 changes: 1 addition & 1 deletion channels/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ channels-packet = { version = "0.1.0", path = "../channels-packet" }
channels-serdes = { version = "0.1.0", path = "../channels-serdes" }

serde = { version = "1.0", default-features = false, optional = true }
tokio = { version = "1", features = ["net"], optional = true }
tokio = { version = "1", default-features = false, optional = true }
futures = { version = "0.3", optional = true }

[features]
Expand Down

0 comments on commit 0bd4c6e

Please sign in to comment.