pub struct MidWriter<W, C> { /* private fields */ }
Expand description
Write side of the Middleware
protocol
Implementations§
Source§impl<W, C> MidWriter<W, C>
impl<W, C> MidWriter<W, C>
Sourcepub async fn write_forward(
&mut self,
client_id: u16,
buffer: &[u8],
compression: ForwardCompression,
) -> Result<CompressionStatus>
pub async fn write_forward( &mut self, client_id: u16, buffer: &[u8], compression: ForwardCompression, ) -> Result<CompressionStatus>
Write forward packet to the destination socket.
Source§impl<W, C> MidWriter<W, C>where
W: AsyncWriteExt + Unpin,
impl<W, C> MidWriter<W, C>where
W: AsyncWriteExt + Unpin,
Sourcepub fn write_disconnected(
&mut self,
id: u16,
) -> impl Future<Output = Result<()>> + '_
pub fn write_disconnected( &mut self, id: u16, ) -> impl Future<Output = Result<()>> + '_
Write disconnect packet to the destination socket
Sourcepub async fn write_two_bufs(
&mut self,
before: &[u8],
after: &[u8],
) -> Result<bool>
pub async fn write_two_bufs( &mut self, before: &[u8], after: &[u8], ) -> Result<bool>
Write two buffers to the socket in vectored mode.
Returns
- Ok(true) if buffer was wrote using efficient implementation (without allocating buffer with size before.len() + after.len())
- Ok(false) if buffer was wrote using the fallback way (allocating buffer with size before.len() + after.len() and copying data to it)
Sourcepub fn write_all<'a>(
&'a mut self,
buf: &'a [u8],
) -> impl Future<Output = Result<()>> + 'a
pub fn write_all<'a>( &'a mut self, buf: &'a [u8], ) -> impl Future<Output = Result<()>> + 'a
Writes entire buffer into the socket
Sourcepub fn write_u32(&mut self, v: u32) -> impl Future<Output = Result<()>> + '_
pub fn write_u32(&mut self, v: u32) -> impl Future<Output = Result<()>> + '_
Same as MidWriter::write_u32
but writes u32
(little endian)
Source§impl<W, C> MidWriter<BufWriter<W>, C>where
W: AsyncWrite,
impl<W, C> MidWriter<BufWriter<W>, C>where
W: AsyncWrite,
Sourcepub fn new_buffered(socket: W, compressor: C, buffer_size: usize) -> Self
pub fn new_buffered(socket: W, compressor: C, buffer_size: usize) -> Self
Create buffered writer.
Sourcepub fn unbuffer(self) -> MidWriter<W, C>
pub fn unbuffer(self) -> MidWriter<W, C>
Remove bufferization from the writer.
WARNING: it is neccessary to call
MidWriter::flush
before the unbuffering so
you’re sure that previously buffered data was wrote
Source§impl<W, C> MidWriter<W, C>where
W: AsyncWrite,
impl<W, C> MidWriter<W, C>where
W: AsyncWrite,
Sourcepub fn make_buffered(self, buffer_size: usize) -> MidWriter<BufWriter<W>, C>
pub fn make_buffered(self, buffer_size: usize) -> MidWriter<BufWriter<W>, C>
Make writer buffered
Source§impl<W, C> MidWriter<W, C>
impl<W, C> MidWriter<W, C>
Sourcepub fn client(&mut self) -> MidClientWriter<'_, W, C>
pub fn client(&mut self) -> MidClientWriter<'_, W, C>
Create client packets writer. Used mainly to incapsulate client and server packets
Sourcepub fn server(&mut self) -> MidServerWriter<'_, W, C>
pub fn server(&mut self) -> MidServerWriter<'_, W, C>
Same as MidWriter::client
but for server packets
Sourcepub fn socket_mut(&mut self) -> &mut W
pub fn socket_mut(&mut self) -> &mut W
Get exclusive access to the underlying socket.
Auto Trait Implementations§
impl<W, C> Freeze for MidWriter<W, C>
impl<W, C> RefUnwindSafe for MidWriter<W, C>where
W: RefUnwindSafe,
C: RefUnwindSafe,
impl<W, C> Send for MidWriter<W, C>
impl<W, C> Sync for MidWriter<W, C>
impl<W, C> Unpin for MidWriter<W, C>
impl<W, C> UnwindSafe for MidWriter<W, C>where
W: UnwindSafe,
C: UnwindSafe,
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