pub struct RedisConnection {
pub stream: TcpStream,
}
Fields§
§stream: TcpStream
Implementations§
Source§impl RedisConnection
impl RedisConnection
Sourcepub async fn new(addr: SocketAddr) -> Result<Self, RedisError>
pub async fn new(addr: SocketAddr) -> Result<Self, RedisError>
Creates a new RedisConnection instance.
§Arguments
- addr - The address of the Redis instance.
§Examples
use std::net::SocketAddr;
use std::str::FromStr;
use redi_rs::RedisConnection;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::from_str("localhost:6379").unwrap();
let mut redis_connection = RedisConnection::new(addr).await?;
Ok(())
}
Sourcepub async fn send_command(
&mut self,
command: &str,
) -> Result<&mut RedisConnection, RedisError>
pub async fn send_command( &mut self, command: &str, ) -> Result<&mut RedisConnection, RedisError>
Sends a command to the Redis instance.
§Arguments
- command - The command to send to the Redis instance.
§Examples
use std::net::SocketAddr;
use std::str::FromStr;
use redi_rs::RedisConnection;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = SocketAddr::from_str("localhost:6379").unwrap();
let mut redis_connection = RedisConnection::new(addr).await?;
redis_connection.send_command("SET foo bar").await?;
Ok(())
}
Returns a RedisConnection instance.
Auto Trait Implementations§
impl !Freeze for RedisConnection
impl RefUnwindSafe for RedisConnection
impl Send for RedisConnection
impl Sync for RedisConnection
impl Unpin for RedisConnection
impl UnwindSafe for RedisConnection
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