use std::task::Waker;
pub struct State {
pub buf: Vec<u8>,
pub waker: Option<Waker>,
pub chunk_size: usize,
}
impl State {
pub fn with_chunk_size(chunk_size: usize) -> Self {
let mut this = Self::default();
this.chunk_size = chunk_size;
this
}
pub fn wake(&mut self) {
if let Some(waker) = self.waker.take() {
waker.wake();
}
}
}
impl Default for State {
fn default() -> Self {
Self {
buf: vec![],
waker: None,
chunk_size: 10,
}
}
}