Remove compat and transmute for they are no longer needed

This commit is contained in:
Artem Vorotnikov
2019-04-15 20:24:09 +03:00
parent f4e22bdc2e
commit e3a517bf0d
2 changed files with 2 additions and 27 deletions

View File

@@ -1,23 +0,0 @@
// Copyright 2018 Google LLC
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
use futures::compat::*;
use futures_legacy::task::Spawn as Spawn01;
#[allow(dead_code)]
struct Compat01As03SinkExposed<S, SinkItem> {
inner: Spawn01<S>,
buffer: Option<SinkItem>,
close_started: bool,
}
pub fn exposed_compat_exec<S, SinkItem, F, T>(input: &Compat01As03Sink<S, SinkItem>, f: F) -> T
where
F: FnOnce(&S) -> T,
{
let exposed = unsafe { std::mem::transmute::<_, &Compat01As03SinkExposed<S, SinkItem>>(input) };
f(exposed.inner.get_ref())
}

View File

@@ -24,8 +24,6 @@ use std::{
use tokio_io::{AsyncRead, AsyncWrite};
use tokio_tcp::{TcpListener, TcpStream};
mod compat;
/// A transport that serializes to, and deserializes from, a [`TcpStream`].
#[derive(Debug)]
pub struct Transport<S, Item, SinkItem> {
@@ -100,11 +98,11 @@ where
type SinkItem = SinkItem;
fn peer_addr(&self) -> io::Result<SocketAddr> {
compat::exposed_compat_exec(&self.inner, |conn| conn.get_ref().peer_addr())
self.inner.get_ref().get_ref().peer_addr()
}
fn local_addr(&self) -> io::Result<SocketAddr> {
compat::exposed_compat_exec(&self.inner, |conn| conn.get_ref().local_addr())
self.inner.get_ref().get_ref().local_addr()
}
}