use super::kcp_peer::KcpPeer;
use bytes::Bytes;
use std::error::Error;
use std::future::Future;
use std::sync::Arc;
type BuffInputType<S, R> = dyn Fn(Arc<KcpPeer<S>>, Bytes) -> R + 'static + Send + Sync;
pub struct BuffInputStore<S, R>(pub Option<Box<BuffInputType<S, R>>>);
impl<S: Send + 'static, R: Future<Output = Result<(), Box<dyn Error>>> + Send + 'static>
BuffInputStore<S, R>
{
pub fn get(&self) -> Option<&BuffInputType<S, R>> {
self.0.as_ref().map(|x| x as _)
}
pub fn set(&mut self, v: Box<BuffInputType<S, R>>) {
self.0 = Some(v);
}
}
pub struct KcpPeerDropInputStore(pub Option<fn(u32)>);
unsafe impl Send for KcpPeerDropInputStore {}
unsafe impl Sync for KcpPeerDropInputStore {}
impl KcpPeerDropInputStore {
pub fn new() -> KcpPeerDropInputStore {
KcpPeerDropInputStore(None)
}
pub fn get(&self) -> Option<fn(u32)> {
self.0.as_ref().map(|x| *x as _)
}
pub fn set(&mut self, v: fn(u32)) {
self.0 = Some(v);
}
}