net: flatten split mod (#1797)

The misc `split` types (`ReadHalf`, `WriteHalf`, `SendHalf`, `RecvHalf`)
are moved up a module and the `*::split` module is removed.
This commit is contained in:
Carl Lerche
2019-11-20 11:29:32 -08:00
committed by GitHub
parent d4fec2c5d6
commit 15dce2d11a
6 changed files with 37 additions and 33 deletions
+8 -7
View File
@@ -115,12 +115,13 @@ mod tcp {
}
mod udp {
use tokio::net::udp::{RecvHalf, SendHalf};
use tokio::net::UdpSocket;
use futures::{future, Sink, SinkExt, Stream, StreamExt};
use std::{error::Error, io, net::SocketAddr};
use tokio::net::udp::{
split::{UdpSocketRecvHalf, UdpSocketSendHalf},
UdpSocket,
};
use std::error::Error;
use std::io;
use std::net::SocketAddr;
pub async fn connect(
addr: &SocketAddr,
@@ -146,7 +147,7 @@ mod udp {
async fn send(
mut stdin: impl Stream<Item = Result<Vec<u8>, io::Error>> + Unpin,
writer: &mut UdpSocketSendHalf,
writer: &mut SendHalf,
) -> Result<(), io::Error> {
while let Some(item) = stdin.next().await {
let buf = item?;
@@ -158,7 +159,7 @@ mod udp {
async fn recv(
mut stdout: impl Sink<Vec<u8>, Error = io::Error> + Unpin,
reader: &mut UdpSocketRecvHalf,
reader: &mut RecvHalf,
) -> Result<(), io::Error> {
loop {
let mut buf = vec![0; 1024];