diff --git a/snocat/src/util/mapped_owned_async_mutex.rs b/snocat/src/util/mapped_owned_async_mutex.rs deleted file mode 100644 index 8af54ec..0000000 --- a/snocat/src/util/mapped_owned_async_mutex.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license OR Apache 2.0 -use tokio::sync::{Mutex, OwnedMutexGuard}; - -pub struct MappedOwnedMutexGuard { - mutex: OwnedMutexGuard, - mapper: Box Fn(&'a U) -> &'a T) + Send + 'static>, -} - -impl MappedOwnedMutexGuard { - pub fn new Fn(&'a U) -> &'a T) + Send + 'static>( - item: OwnedMutexGuard, - map: FMap, - ) -> Self { - Self { - mutex: item, - mapper: Box::new(map), - } - } - - fn map(&self) -> &T { - (self.mapper)(&*self.mutex) - } - - fn map_mut(&mut self) -> &mut T { - let immutable_ref = self.map(); - // We're mutable on the outside, so we're safe to make mutable on the inside - #[allow(mutable_transmutes)] - let mutable_unsafe_ref = unsafe { std::mem::transmute::<&T, &mut T>(immutable_ref) }; - mutable_unsafe_ref - } - - pub fn extract(self) -> OwnedMutexGuard { - self.mutex - } -} - -impl AsRef for MappedOwnedMutexGuard { - fn as_ref(&self) -> &T { - self.map() - } -} - -impl AsMut for MappedOwnedMutexGuard { - fn as_mut(&mut self) -> &mut T { - self.map_mut() - } -} diff --git a/snocat/src/util/mod.rs b/snocat/src/util/mod.rs index e66242b..bfe44d7 100644 --- a/snocat/src/util/mod.rs +++ b/snocat/src/util/mod.rs @@ -20,12 +20,10 @@ use tokio::net::TcpStream; pub mod cancellation; pub mod dropkick; pub mod framed; -mod mapped_owned_async_mutex; pub(crate) mod merge_streams; pub mod tunnel_stream; pub mod validators; pub(crate) mod vtdroppable; -pub use mapped_owned_async_mutex::MappedOwnedMutexGuard; // HTTP protocol constant from quinn/examples/common pub const ALPN_QUIC_HTTP: &[&[u8]] = &[b"hq-29"];