tcplane/stream/
impl.rs

1use crate::*;
2
3impl ArcRwLockStream {
4    pub fn from(arc_rw_lock_stream: ArcRwLock<TcpStream>) -> Self {
5        Self(arc_rw_lock_stream)
6    }
7
8    pub fn from_stream(stream: TcpStream) -> Self {
9        Self(Arc::new(RwLock::new(stream)))
10    }
11
12    pub async fn get_read_lock(&self) -> RwLockReadGuardTcpStream {
13        self.0.read().await
14    }
15
16    pub async fn get_write_lock(&self) -> RwLockWriteGuardTcpStream {
17        self.0.write().await
18    }
19}