use tracing::debug;
#[derive(Debug)]
pub struct State {
pub(crate) buffer: Vec<u8>,
pub(crate) bytes_count: Option<usize>,
}
impl State {
pub(crate) const DEFAULT_CAPACITY: usize = 512;
pub(crate) fn new() -> Self {
Self::with_capacity(Self::DEFAULT_CAPACITY)
}
pub(crate) fn with_capacity(capacity: usize) -> Self {
debug!("preparing {capacity} bytes to be read");
Self {
buffer: vec![0; capacity],
bytes_count: None,
}
}
pub fn get_buffer_mut(&mut self) -> &mut [u8] {
&mut self.buffer
}
pub fn set_bytes_count(&mut self, bytes_count: usize) {
self.bytes_count.replace(bytes_count);
}
}