33use super :: Transaction ;
44use crate :: { Error , Key , KvPair , Value } ;
55
6+ use derive_new:: new;
67use futures:: prelude:: * ;
78use futures:: task:: { Context , Poll } ;
89use std:: pin:: Pin ;
@@ -24,16 +25,11 @@ impl Stream for Scanner {
2425///
2526/// Once resolved this request will result in the fetching of the value associated with the given
2627/// key.
28+ #[ derive( new) ]
2729pub struct Get {
2830 key : Key ,
2931}
3032
31- impl Get {
32- pub fn new ( key : Key ) -> Self {
33- Get { key }
34- }
35- }
36-
3733impl Future for Get {
3834 type Output = Result < Value , Error > ;
3935
@@ -47,16 +43,11 @@ impl Future for Get {
4743///
4844/// Once resolved this request will result in the fetching of the values associated with the given
4945/// keys.
46+ #[ derive( new) ]
5047pub struct BatchGet {
5148 keys : Vec < Key > ,
5249}
5350
54- impl BatchGet {
55- pub fn new ( keys : Vec < Key > ) -> Self {
56- BatchGet { keys }
57- }
58- }
59-
6051impl Future for BatchGet {
6152 type Output = Result < Vec < KvPair > , Error > ;
6253
@@ -69,16 +60,11 @@ impl Future for BatchGet {
6960/// An unresolved [`Transaction::commit`](Transaction::commit) request.
7061///
7162/// Once resolved this request will result in the committing of the transaction.
63+ #[ derive( new) ]
7264pub struct Commit {
7365 txn : Transaction ,
7466}
7567
76- impl Commit {
77- pub fn new ( txn : Transaction ) -> Self {
78- Commit { txn }
79- }
80- }
81-
8268impl Future for Commit {
8369 type Output = Result < ( ) , Error > ;
8470
@@ -91,16 +77,11 @@ impl Future for Commit {
9177/// An unresolved [`Transaction::rollback`](Transaction::rollback) request.
9278///
9379/// Once resolved this request will result in the rolling back of the transaction.
80+ #[ derive( new) ]
9481pub struct Rollback {
9582 txn : Transaction ,
9683}
9784
98- impl Rollback {
99- pub fn new ( txn : Transaction ) -> Self {
100- Rollback { txn }
101- }
102- }
103-
10485impl Future for Rollback {
10586 type Output = Result < ( ) , Error > ;
10687
@@ -113,16 +94,11 @@ impl Future for Rollback {
11394/// An unresolved [`Transaction::lock_keys`](Transaction::lock_keys) request.
11495///
11596/// Once resolved this request will result in the locking of the given keys.
97+ #[ derive( new) ]
11698pub struct LockKeys {
11799 keys : Vec < Key > ,
118100}
119101
120- impl LockKeys {
121- pub fn new ( keys : Vec < Key > ) -> Self {
122- LockKeys { keys }
123- }
124- }
125-
126102impl Future for LockKeys {
127103 type Output = Result < ( ) , Error > ;
128104
@@ -136,17 +112,12 @@ impl Future for LockKeys {
136112///
137113/// Once resolved this request will result in the setting of the value associated with the given
138114/// key.
115+ #[ derive( new) ]
139116pub struct Set {
140117 key : Key ,
141118 value : Value ,
142119}
143120
144- impl Set {
145- pub fn new ( key : Key , value : Value ) -> Self {
146- Set { key, value }
147- }
148- }
149-
150121impl Future for Set {
151122 type Output = Result < ( ) , Error > ;
152123
@@ -160,16 +131,11 @@ impl Future for Set {
160131/// An unresolved [`Transaction::delete`](Transaction::delete) request.
161132///
162133/// Once resolved this request will result in the deletion of the given key.
134+ #[ derive( new) ]
163135pub struct Delete {
164136 key : Key ,
165137}
166138
167- impl Delete {
168- pub fn new ( key : Key ) -> Self {
169- Delete { key }
170- }
171- }
172-
173139impl Future for Delete {
174140 type Output = Result < ( ) , Error > ;
175141
0 commit comments