Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ documentation = "https://docs.rs/memcache-async"
homepage = "https://github.com/vavrusa/memcache-async"

[dependencies]
cfg-if = "1.0.1"
futures = { version = "0.3" }
tokio = { version = "1.37", features = ["io-util"] }

Expand Down
19 changes: 15 additions & 4 deletions src/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
//! This is a simplified implementation of [rust-memcache](https://github.com/aisk/rust-memcache)
//! ported for AsyncRead + AsyncWrite.
use core::fmt::Display;
#[cfg(feature = "with-futures")]
use futures::io::{AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufReader};

#[cfg(feature = "with-tokio")]
use tokio::io::{AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufReader};
use cfg_if::cfg_if;

cfg_if! {
// The order here matters. If both features are enabled,
// this one will be chosen, avoiding a conflict.
if #[cfg(feature = "with-tokio")] {
use tokio::io as async_io;
} else if #[cfg(feature = "with-futures")] {
use futures::io as async_io;
} else {
compile_error!("An async I/O feature ('with-tokio' or 'with-futures') must be enabled.");
}
}

use async_io::{AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, BufReader};

use std::collections::HashMap;
use std::io::{Error, ErrorKind};
Expand Down