pub struct ArcRwLockStream(/* private fields */);Expand description
A wrapper around Arc<RwLock<TcpStream>>.
ArcRwLockStream provides shared, thread-safe access to a TcpStream
using an atomic reference counter (Arc) combined with a read-write lock (RwLock).
It is primarily used to safely share the stream across asynchronous tasks.
§Fields
0: The innerArc<RwLock<TcpStream>>stream.
Implementations§
Source§impl ArcRwLockStream
impl ArcRwLockStream
Sourcepub fn from_stream(stream: TcpStream) -> Self
pub fn from_stream(stream: TcpStream) -> Self
Sourcepub async fn read(&self) -> RwLockReadGuardTcpStream<'_>
pub async fn read(&self) -> RwLockReadGuardTcpStream<'_>
Returns a reference to the inner TcpStream.
This method acquires a read lock on the underlying stream, allowing shared access to the TCP stream while preventing concurrent writes.
§Returns
Returns a read guard that provides shared access to the TCP stream
Sourcepub async fn send(&self, data: &ResponseData) -> ResponseResult
pub async fn send(&self, data: &ResponseData) -> ResponseResult
Sourcepub async fn send_body_conditional(
&self,
body: &ResponseBody,
is_websocket: bool,
) -> ResponseResult
pub async fn send_body_conditional( &self, body: &ResponseBody, is_websocket: bool, ) -> ResponseResult
Sourcepub async fn send_body(&self, body: &ResponseBody) -> ResponseResult
pub async fn send_body(&self, body: &ResponseBody) -> ResponseResult
Sourcepub async fn send_ws_body(&self, body: &ResponseBody) -> ResponseResult
pub async fn send_ws_body(&self, body: &ResponseBody) -> ResponseResult
Trait Implementations§
Source§impl Clone for ArcRwLockStream
impl Clone for ArcRwLockStream
Source§fn clone(&self) -> ArcRwLockStream
fn clone(&self) -> ArcRwLockStream
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ArcRwLockStream
impl !RefUnwindSafe for ArcRwLockStream
impl Send for ArcRwLockStream
impl Sync for ArcRwLockStream
impl Unpin for ArcRwLockStream
impl !UnwindSafe for ArcRwLockStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more