File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -44,3 +44,20 @@ macro_rules! pushlen {
4444 $buf. push( b'\n' ) ;
4545 } } ;
4646}
47+
48+ #[ macro_export]
49+ /// The `pipe!` macro is used to create pipelines
50+ ///
51+ /// ## Example usage
52+ /// ```
53+ /// use skytable::{pipe, query};
54+ ///
55+ /// let pipe = pipe!(query!("sysctl report status"), query!("use $current"));
56+ /// assert_eq!(pipe.query_count(), 2);
57+ /// ```
58+ macro_rules! pipe {
59+ ( $( $query: expr) ,+) => { {
60+ let mut p = $crate:: Pipeline :: new( ) ;
61+ $( p. push_owned( $query) ; ) * p
62+ } }
63+ }
Original file line number Diff line number Diff line change @@ -153,6 +153,10 @@ impl Pipeline {
153153 pub fn query_count ( & self ) -> usize {
154154 self . cnt
155155 }
156+ /// Same as [`Self::push`], but passes ownership to the [`Pipeline`]
157+ pub fn push_owned ( & mut self , q : Query ) {
158+ self . push ( & q) ;
159+ }
156160 /// Add a query to this pipeline
157161 ///
158162 /// Note: It's not possible to get the query back from the pipeline since it's not indexed (and doing so would be an unnecessary
You can’t perform that action at this time.
0 commit comments