3838//!
3939//! First add this to your `Cargo.toml` file:
4040//! ```toml
41- //! skytable = "0.6.2-alpha.1 "
41+ //! skytable = "0.6.2-alpha.2 "
4242//! ```
4343//! Now open up your `src/main.rs` file and establish a connection to the server while also adding some
4444//! imports:
125125//!
126126//! If you need to use an `async` API, just change your import to:
127127//! ```toml
128- //! skytable = { version = "0.6.2-alpha.1 ", features=["async"], default-features=false }
128+ //! skytable = { version = "0.6.2-alpha.2 ", features=["async"], default-features=false }
129129//! ```
130130//! You can now establish a connection by using `skytable::AsyncConnection::new()`, adding `.await`s wherever
131131//! necessary. Do note that you'll the [Tokio runtime](https://tokio.rs).
135135//! With this client driver, it is possible to use both sync and `async` APIs **at the same time**. To do
136136//! this, simply change your import to:
137137//! ```toml
138- //! skytable = { version="0.6.2-alpha.1 ", features=["sync", "async"] }
138+ //! skytable = { version="0.6.2-alpha.2 ", features=["sync", "async"] }
139139//! ```
140140//!
141141//! ## TLS
144144//!
145145//! ### Using TLS with sync interfaces
146146//! ```toml
147- //! skytable = { version="0.6.2-alpha.1 ", features=["sync","ssl"] }
147+ //! skytable = { version="0.6.2-alpha.2 ", features=["sync","ssl"] }
148148//! ```
149149//! You can now use the async [TlsConnection](`sync::TlsConnection`) object.
150150//!
151151//! ### Using TLS with async interfaces
152152//! ```toml
153- //! skytable = { version="0.6.2-alpha.1 ", features=["async","aio-ssl"], default-features=false }
153+ //! skytable = { version="0.6.2-alpha.2 ", features=["async","aio-ssl"], default-features=false }
154154//! ```
155155//! You can now use the async [TlsConnection](`aio::TlsConnection`) object.
156156//!
@@ -608,7 +608,52 @@ cfg_dbg!(
608608/// # Pipeline
609609///
610610/// A pipeline is a way of queing up multiple queries, sending them to the server at once instead of sending them individually, avoiding
611- /// round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent
611+ /// round-trip-times while also simplifying usage in several places. Responses are returned in the order they are sent.
612+ ///
613+ /// ## Example with the sync API
614+ ///
615+ /// ```no_run
616+ /// use skytable::{query, Pipeline, Element, RespCode};
617+ /// use skytable::sync::Connection;
618+ ///
619+ /// let mut con = Connection::new("127.0.0.1", 2003).unwrap();
620+ /// let pipe = Pipeline::new()
621+ /// .add(query!("set", "x", "100"))
622+ /// .add(query!("heya", "echo me!"));
623+ ///
624+ /// let ret = con.run_pipeline(pipe).unwrap();
625+ /// assert_eq!(
626+ /// ret,
627+ /// vec![
628+ /// Element::RespCode(RespCode::Okay),
629+ /// Element::String("echo me!".to_owned())
630+ /// ]
631+ /// );
632+ /// ```
633+ ///
634+ /// ## Example with the async API
635+ ///
636+ /// ```no_run
637+ /// use skytable::{query, Pipeline, Element, RespCode};
638+ /// use skytable::aio::Connection;
639+ ///
640+ /// async fn run() {
641+ /// let mut con = Connection::new("127.0.0.1", 2003).await.unwrap();
642+ /// let pipe = Pipeline::new()
643+ /// .add(query!("set", "x", "100"))
644+ /// .add(query!("heya", "echo me!"));
645+ ///
646+ /// let ret = con.run_pipeline(pipe).await.unwrap();
647+ /// assert_eq!(
648+ /// ret,
649+ /// vec![
650+ /// Element::RespCode(RespCode::Okay),
651+ /// Element::String("echo me!".to_owned())
652+ /// ]
653+ /// );
654+ /// }
655+ /// ```
656+ ///
612657pub struct Pipeline {
613658 len : usize ,
614659 chain : Vec < u8 > ,
@@ -633,6 +678,7 @@ impl Pipeline {
633678 self . len += 1 ;
634679 query. write_query_to_writable ( & mut self . chain ) ;
635680 }
681+ /// Returns the number of queries in the pipeline
636682 pub fn len ( & self ) -> usize {
637683 self . len
638684 }
0 commit comments