async-transmit
Async trait for transmitting data to peers
async-transmit crate provides Transmit trait which allows value to be transmit asynchronously.
This crate relies on async-trait, the original definition of the Transmit trait is:
use async_trait;
So use #[async_trait] to when implement Transmit like:
use *;
use async_trait;
With async-std/async-channel
If you'd like to play with async_std::channel::Sender or async_channel::Sender,
use with-async-channel feature like:
[]
= "0.1.0"
= ["with-async-channel"]
Then you can use transmit() method through Transmit trait on the sender like:
use *;
let = ;
s.transmit.await?;
s.transmit.await?;
drop;
assert_eq!;
assert_eq!;
assert_eq!;
With tokio
If you'd like to play with tokio::sync::mpsc::Sender or tokio::sync::mpsc::UnboundedSender,
use with-tokio feature like:
[]
= "0.1.0"
= ["with-tokio"]
Then you can use transmit() method through Transmit trait on the sender like:
use *;
let = ;
s.transmit.await?;
s.transmit.await?;
drop;
assert_eq!;
assert_eq!;
assert_eq!;
With futures-rs
If you'd like to play with futures::sink::Sink, use with-sink feature like:
[]
= "0.1.0"
= ["with-sink"]
Then you can use async_transmit::from_sink() to create a wrapper object which implements Transmit
trait like:
use *;
use *;
let = ;
let mut s = from_sink;
s.transmit.await?;
s.transmit.await?;
drop;
assert_eq!;
assert_eq!;
assert_eq!;
License
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.