use crate::cfb8::{setup_craft_cipher, CipherError, CraftCipher};
use crate::util::{get_sized_buf, VAR_INT_BUF_SIZE};
use crate::wrapper::{CraftIo, CraftWrapper};
use flate2::{DecompressError, FlushDecompress, Status};
use mcproto_rs::protocol::{Id, PacketDirection, RawPacket, State};
use mcproto_rs::types::VarInt;
use mcproto_rs::{Deserialize, Deserialized};
use thiserror::Error;
#[cfg(feature = "async")]
use {async_trait::async_trait, futures::AsyncReadExt};
#[derive(Debug, Error)]
pub enum ReadError {
#[error("i/o failure during read")]
IoFailure(#[from] std::io::Error),
#[error("failed to read header VarInt")]
PacketHeaderErr(#[from] mcproto_rs::DeserializeErr),
#[error("failed to read packet")]
PacketErr(#[from] mcproto_rs::protocol::PacketErr),
#[error("failed to decompress packet")]
DecompressFailed(#[from] DecompressErr),
}
#[derive(Debug, Error)]
pub enum DecompressErr {
#[error("buf error")]
BufError,
#[error("failure while decompressing")]
Failure(#[from] DecompressError),
}
pub type ReadResult
= Result