mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
remove unnecessary mut self references
This commit is contained in:
parent
619a2a61c7
commit
fa2b84d646
6 changed files with 55 additions and 19 deletions
|
@ -10,7 +10,7 @@ pub use crate::packet::*;
|
|||
pub use crate::stream::*;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use futures::{channel::mpsc, Future, StreamExt};
|
||||
use futures::{channel::mpsc, Future, FutureExt, StreamExt};
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, AtomicU32, Ordering},
|
||||
Arc,
|
||||
|
@ -109,11 +109,10 @@ impl<W: ws::WebSocketWrite + Send + 'static> ServerMux<W> {
|
|||
R: ws::WebSocketRead,
|
||||
FR: std::future::Future<Output = Result<(), WispError>>,
|
||||
{
|
||||
futures::try_join! {
|
||||
self.server_close_loop(close_rx, self.stream_map.clone(), self.tx.clone()),
|
||||
self.server_msg_loop(rx, handler_fn)
|
||||
futures::select! {
|
||||
x = self.server_close_loop(close_rx, self.stream_map.clone(), self.tx.clone()).fuse() => x,
|
||||
x = self.server_msg_loop(rx, handler_fn).fuse() => x
|
||||
}
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
async fn server_close_loop(
|
||||
|
@ -299,7 +298,7 @@ impl<W: ws::WebSocketWrite + Send + 'static> ClientMux<W> {
|
|||
}
|
||||
|
||||
pub async fn client_new_stream(
|
||||
&mut self,
|
||||
&self,
|
||||
stream_type: StreamType,
|
||||
host: String,
|
||||
port: u16,
|
||||
|
|
|
@ -69,7 +69,7 @@ where
|
|||
}
|
||||
|
||||
impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStreamWrite<W> {
|
||||
pub async fn write(&mut self, data: Bytes) -> Result<(), crate::WispError> {
|
||||
pub async fn write(&self, data: Bytes) -> Result<(), crate::WispError> {
|
||||
if self.is_closed.load(Ordering::Acquire) {
|
||||
return Err(crate::WispError::StreamAlreadyClosed);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStreamWrite<W> {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn close(&mut self, reason: u8) -> Result<(), crate::WispError> {
|
||||
pub async fn close(&self, reason: u8) -> Result<(), crate::WispError> {
|
||||
if self.is_closed.load(Ordering::Acquire) {
|
||||
return Err(crate::WispError::StreamAlreadyClosed);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStreamWrite<W> {
|
|||
}
|
||||
|
||||
pub(crate) fn into_sink(self) -> Pin<Box<dyn Sink<Bytes, Error = crate::WispError> + Send>> {
|
||||
Box::pin(sink::unfold(self, |mut tx, data| async move {
|
||||
Box::pin(sink::unfold(self, |tx, data| async move {
|
||||
tx.write(data).await?;
|
||||
Ok(tx)
|
||||
}))
|
||||
|
@ -155,7 +155,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStream<W> {
|
|||
self.rx.read().await
|
||||
}
|
||||
|
||||
pub async fn write(&mut self, data: Bytes) -> Result<(), crate::WispError> {
|
||||
pub async fn write(&self, data: Bytes) -> Result<(), crate::WispError> {
|
||||
self.tx.write(data).await
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ impl<W: crate::ws::WebSocketWrite + Send + 'static> MuxStream<W> {
|
|||
self.tx.get_close_handle()
|
||||
}
|
||||
|
||||
pub async fn close(&mut self, reason: u8) -> Result<(), crate::WispError> {
|
||||
pub async fn close(&self, reason: u8) -> Result<(), crate::WispError> {
|
||||
self.tx.close(reason).await
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ pub struct MuxStreamCloser {
|
|||
}
|
||||
|
||||
impl MuxStreamCloser {
|
||||
pub async fn close(&mut self, reason: u8) -> Result<(), crate::WispError> {
|
||||
pub async fn close(&self, reason: u8) -> Result<(), crate::WispError> {
|
||||
if self.is_closed.load(Ordering::Acquire) {
|
||||
return Err(crate::WispError::StreamAlreadyClosed);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue