pub struct TCPNetworkDecoder<R: AsyncRead + Unpin> {
reader: DecryptionReader<R>,
compression: Option<NonZeroU32>,
}Expand description
Decoder: Client -> Server
Supports ZLib decoding/decompression
Supports Aes128 Encryption
Fields§
§reader: DecryptionReader<R>§compression: Option<NonZeroU32>Implementations§
Source§impl<R: AsyncRead + Unpin> TCPNetworkDecoder<R>
impl<R: AsyncRead + Unpin> TCPNetworkDecoder<R>
Sourcepub const fn set_compression(&mut self, threshold: NonZeroU32)
pub const fn set_compression(&mut self, threshold: NonZeroU32)
Sets the compression threshold for the decoder.
Sourcepub fn set_encryption(&mut self, key: &[u8; 16])
pub fn set_encryption(&mut self, key: &[u8; 16])
NOTE: Encryption can only be set; a minecraft stream cannot go back to being unencrypted
§Panics
- If the reader is already decrypting data.
- If the key is invalid.
Sourcepub async fn get_raw_packet(&mut self) -> Result<RawPacket, PacketError>
pub async fn get_raw_packet(&mut self) -> Result<RawPacket, PacketError>
Gets a raw packet from the stream.
§Errors
- If the packet length is invalid.
- If the packet is too long.
- If the packet is not compressed when it should be.
- If the packet fails to decompress.
Auto Trait Implementations§
impl<R> Freeze for TCPNetworkDecoder<R>where
R: Freeze,
impl<R> RefUnwindSafe for TCPNetworkDecoder<R>where
R: RefUnwindSafe,
impl<R> Send for TCPNetworkDecoder<R>where
R: Send,
impl<R> Sync for TCPNetworkDecoder<R>where
R: Sync,
impl<R> Unpin for TCPNetworkDecoder<R>
impl<R> UnsafeUnpin for TCPNetworkDecoder<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for TCPNetworkDecoder<R>where
R: 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>