Struct Famcache

Source
pub struct Famcache {
    pub messaging: Arc<Messaging>,
    /* private fields */
}

Fields§

§messaging: Arc<Messaging>

Implementations§

Source§

impl Famcache

Source

pub fn new(config: Config) -> Self

Create a new instance of the client

§Example
use famcache::{Famcache, Config};

let client = Famcache::new(Config::new("localhost", 3577));
Source§

impl Famcache

Source

pub async fn connect(&mut self) -> Result<()>

Open a connection to the server

§Example
use famcache::{Famcache, Config};

#[tokio::main]
async fn main() {
  let mut client = Famcache::new(Config::new("localhost", 3577));

  client.connect().await.unwrap();

  println!("Connected to server");
}
Source

pub async fn get(&self, key: &str) -> Result<Option<String>>

Get a value from the server

§Example
use famcache::{Famcache, Config};

#[tokio::main]
async fn main() {
  let mut client = Famcache::new(Config::new("localhost", 3577));

  client.connect().await.unwrap();

  client.get("test").await.unwrap();
}
Source

pub async fn set(&self, key: &str, value: &str, ttl: Option<u64>) -> Result<()>

Set a value on the server

§Example
use famcache::{Famcache, Config};

#[tokio::main]
async fn main() {
  let mut client = Famcache::new(Config::new("localhost", 3577));

  client.connect().await.unwrap();

  client.set("test", "val", None).await.unwrap();
}
Source

pub async fn del(&self, key: &str) -> Result<()>

Delete a value from the server

§Example
use famcache::{Famcache, Config};

#[tokio::main]
async fn main() {
  let mut client = Famcache::new(Config::new("localhost", 3577));

  client.connect().await.unwrap();

  client.del("test").await.unwrap();
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.