use crate::message::PendingSlot;
use kevy_resp::{Argv, RespVersion};
use kevy_sys::Socket;
use std::collections::{HashSet, VecDeque};
use std::sync::Arc;
#[repr(C)]
pub(crate) struct Conn {
pub(crate) sock: Socket,
pub(crate) input: Vec<u8>,
pub(crate) output: Vec<u8>,
pub(crate) output_arcs: Vec<(usize, Arc<[u8]>)>,
pub(crate) pending: VecDeque<PendingSlot>,
pub(crate) write_pos: usize,
pub(crate) next_seq: u64,
pub(crate) next_emit: u64,
pub(crate) proto: RespVersion,
pub(crate) closing: bool,
pub(crate) want_write: bool,
pub(crate) blocked: bool,
pub(crate) cluster: bool,
pub(crate) pending_write: bool,
pub(crate) sub: HashSet<Vec<u8>>,
pub(crate) psub: HashSet<Vec<u8>>,
pub(crate) multi: Option<Vec<Argv>>,
pub(crate) watched: Vec<(Vec<u8>, u64)>,
}
impl Conn {
pub(crate) fn new(sock: Socket) -> Self {
Conn {
sock,
input: Vec::new(),
output: Vec::new(),
output_arcs: Vec::new(),
write_pos: 0,
want_write: false,
next_seq: 0,
next_emit: 0,
closing: false,
pending: VecDeque::new(),
sub: HashSet::new(),
psub: HashSet::new(),
multi: None,
watched: Vec::new(),
proto: RespVersion::default(),
blocked: false,
cluster: false,
pending_write: false,
}
}
}