pub struct Pipeline { /* private fields */ }Expand description
Pipeline
A pipeline is a way of queing up multiple queries, sending them to the server at once instead of sending them individually, avoiding round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent.
Example with the sync API
use skytable::{query, Pipeline, Element, RespCode};
use skytable::sync::Connection;
let mut con = Connection::new("127.0.0.1", 2003).unwrap();
let pipe = Pipeline::new()
.append(query!("set", "x", "100"))
.append(query!("heya", "echo me!"));
let ret = con.run_pipeline(pipe).unwrap();
assert_eq!(
ret,
vec![
Element::RespCode(RespCode::Okay),
Element::String("echo me!".to_owned())
]
);Example with the async API
use skytable::{query, Pipeline, Element, RespCode};
use skytable::aio::Connection;
async fn run() {
let mut con = Connection::new("127.0.0.1", 2003).await.unwrap();
let pipe = Pipeline::new()
.append(query!("set", "x", "100"))
.append(query!("heya", "echo me!"));
let ret = con.run_pipeline(pipe).await.unwrap();
assert_eq!(
ret,
vec![
Element::RespCode(RespCode::Okay),
Element::String("echo me!".to_owned())
]
);
}Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Pipeline
impl Send for Pipeline
impl Sync for Pipeline
impl Unpin for Pipeline
impl UnwindSafe for Pipeline
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