mirror of https://github.com/chipsenkbeil/distant
Compare commits
6 Commits
f65fb8686b
...
8e1506f6de
Author | SHA1 | Date |
---|---|---|
Chip Senkbeil | 8e1506f6de | 7 months ago |
Chip Senkbeil | 41bf0e49cb | 7 months ago |
Chip Senkbeil | bdb07a5ac8 | 7 months ago |
Chip Senkbeil | 2098edb7ca | 7 months ago |
Chip Senkbeil | 42c70e615c | 7 months ago |
Chip Senkbeil | b32eb504b3 | 7 months ago |
@ -1,6 +1,8 @@
|
|||||||
mod destination;
|
mod destination;
|
||||||
mod map;
|
mod map;
|
||||||
|
mod stream;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub use destination::{Destination, Host, HostParseError};
|
pub use destination::{Destination, Host, HostParseError};
|
||||||
pub use map::{Map, MapParseError};
|
pub use map::{Map, MapParseError};
|
||||||
|
pub use stream::Stream;
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
use async_trait::async_trait;
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
/// Interface to an asynchronous stream of items.
|
||||||
|
#[async_trait]
|
||||||
|
pub trait Stream: Send {
|
||||||
|
type Item: Send;
|
||||||
|
|
||||||
|
/// Retrieves the next item from the stream, returning `None` if no more items are available
|
||||||
|
/// from the stream.
|
||||||
|
async fn next(&mut self) -> Option<Self::Item>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<T: Send> Stream for mpsc::UnboundedReceiver<T> {
|
||||||
|
type Item = T;
|
||||||
|
|
||||||
|
async fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
self.recv().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<T: Send> Stream for mpsc::Receiver<T> {
|
||||||
|
type Item = T;
|
||||||
|
|
||||||
|
async fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
self.recv().await
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue