Expand description
A client connection.
Fields
context: Option<Box<dyn Any>>
A custom user-defined context.
Implementations
sourceimpl Conn
impl Conn
sourcepub fn addr(&self) -> &SocketAddr
pub fn addr(&self) -> &SocketAddr
The connection socket address.
sourcepub fn next_command(&mut self) -> Option<Vec<Vec<u8>>>
pub fn next_command(&mut self) -> Option<Vec<Vec<u8>>>
Read the next command in the pipeline, if any.
This method is not typically needed, but it can be used for reading additional incoming commands that may be present. Which, may come in handy for specialized stuff like batching operations or for optimizing a locking strategy.
sourcepub fn write_string(&mut self, msg: &str)
pub fn write_string(&mut self, msg: &str)
Write a RESP Simple String to client connection.
https://redis.io/docs/reference/protocol-spec/#resp-simple-strings
sourcepub fn write_null(&mut self)
pub fn write_null(&mut self)
Write a RESP Null Bulk String to client connection.
https://redis.io/docs/reference/protocol-spec/#resp-bulk-strings
sourcepub fn write_error(&mut self, msg: &str)
pub fn write_error(&mut self, msg: &str)
Write a RESP Error to client connection.
sourcepub fn write_integer(&mut self, x: i64)
pub fn write_integer(&mut self, x: i64)
Write a RESP Integer to client connection.
sourcepub fn write_array(&mut self, count: usize)
pub fn write_array(&mut self, count: usize)
Write a RESP Array to client connection.
sourcepub fn write_bulk(&mut self, msg: &[u8])
pub fn write_bulk(&mut self, msg: &[u8])
Write a RESP Bulk String to client connection.
https://redis.io/docs/reference/protocol-spec/#resp-simple-strings
sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Shutdown the server that was started by Server::serve
.
This operation will gracefully shutdown the server by closing the all client connections, stopping the server listener, and waiting for the server resources to free.
sourcepub fn cross_close(&mut self, id: u64)
pub fn cross_close(&mut self, id: u64)
Close a client connection that is not this one.
The identifier is for a client connection that was connection to the
same server as self
. This operation can safely be called on the same
identifier multiple time.
Auto Trait Implementations
impl !RefUnwindSafe for Conn
impl !Send for Conn
impl !Sync for Conn
impl Unpin for Conn
impl !UnwindSafe for Conn
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more