pub struct Connection {
pub write_buffer: Vec<u8>,
pub connection_id: usize,
pub subscription_count: usize,
pub client_name: Option<String>,
pub client_addr: Option<SocketAddr>,
pub connected_at: u64,
pub commands_processed: u64,
pub flags: Vec<String>,
/* private fields */
}Expand description
Manages a client connection with RESP protocol handling
Handles command parsing, execution, and response buffering.
Fields§
§write_buffer: Vec<u8>§connection_id: usize§subscription_count: usize§client_name: Option<String>§client_addr: Option<SocketAddr>§connected_at: u64§commands_processed: u64§flags: Vec<String>Implementations§
Source§impl Connection
impl Connection
Sourcepub fn new(
fd: RawFd,
buffer_size: usize,
store: Arc<FeoxStore>,
config: &Config,
) -> Self
pub fn new( fd: RawFd, buffer_size: usize, store: Arc<FeoxStore>, config: &Config, ) -> Self
Create a new connection handler
Sourcepub fn set_client_registry(&mut self, registry: Arc<ClientRegistry>)
pub fn set_client_registry(&mut self, registry: Arc<ClientRegistry>)
Set the executor with client registry info
Sourcepub fn new_with_addr(
fd: RawFd,
buffer_size: usize,
store: Arc<FeoxStore>,
config: &Config,
addr: Option<SocketAddr>,
) -> Self
pub fn new_with_addr( fd: RawFd, buffer_size: usize, store: Arc<FeoxStore>, config: &Config, addr: Option<SocketAddr>, ) -> Self
Create a new connection handler with address
pub fn fd(&self) -> RawFd
pub fn is_closed(&self) -> bool
pub fn close(&mut self)
Sourcepub fn set_authenticated(&mut self, authenticated: bool)
pub fn set_authenticated(&mut self, authenticated: bool)
Set authentication status
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if connection is authenticated
Sourcepub fn process_read(&mut self, data: &[u8]) -> Result<Vec<PubSubOp>>
pub fn process_read(&mut self, data: &[u8]) -> Result<Vec<PubSubOp>>
Process incoming data with inline execution Returns pub/sub operations that need to be executed
Sourcepub fn pending_writes(&mut self) -> Option<&[u8]>
pub fn pending_writes(&mut self) -> Option<&[u8]>
Get pending write data as a single buffer slice
Sourcepub fn consume_writes(&mut self, n: usize)
pub fn consume_writes(&mut self, n: usize)
Mark bytes as written
Sourcepub fn queue_pubsub_message(&mut self, message: PubSubMessage)
pub fn queue_pubsub_message(&mut self, message: PubSubMessage)
Add a pub/sub message to the pending queue
Sourcepub fn is_in_pubsub_mode(&self) -> bool
pub fn is_in_pubsub_mode(&self) -> bool
Check if connection is in pub/sub mode
Sourcepub fn set_subscription_count(&mut self, count: usize)
pub fn set_subscription_count(&mut self, count: usize)
Update subscription count
Sourcepub fn process_pubsub_messages(&mut self)
pub fn process_pubsub_messages(&mut self)
Process pending pub/sub messages
Auto Trait Implementations§
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
impl Freeze for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more