1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
extern crate core;

mod command;
mod connection;
mod error;
mod memento;

pub use self::{command::*, error::*, memento::*};
use std::fmt::Debug;

use tokio::net::ToSocketAddrs;

pub type Result<T> = std::result::Result<T, MementoError>;

pub trait ToCommandResponse: Default {
    fn create<T>(frames: Vec<T>, cmd: Command) -> Result<Option<Self>>
    where
        T: ToString + Debug + Default;
}

///
/// ```rust
/// use memento::Result;
///
/// #[tokio::main]
/// async fn main() -> Result<()> {
///     let client = memento::new("localhost:11211").await?;
///
///     Ok(())
/// }
///```
pub async fn new<A: ToSocketAddrs>(addr: A) -> Result<Memento> {
    Memento::connect(addr).await
}