Skip to content

Commit 10b4f22

Browse files
committed
minor: Pass http::Method by value, avoids a clone
1 parent db0936b commit 10b4f22

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

node/src/api/client.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ApiClient for LexeApiClient {
9090
user_pk: UserPk,
9191
) -> Result<Option<Node>, ApiError> {
9292
let data = GetByUserPk { user_pk };
93-
self.request(&GET, Backend, V1, "/node", &data).await
93+
self.request(GET, Backend, V1, "/node", &data).await
9494
}
9595

9696
async fn get_instance(
@@ -103,7 +103,7 @@ impl ApiClient for LexeApiClient {
103103
measurement,
104104
};
105105
let maybe_instance: Option<Instance> =
106-
self.request(&GET, Backend, V1, "/instance", &data).await?;
106+
self.request(GET, Backend, V1, "/instance", &data).await?;
107107

108108
Ok(maybe_instance)
109109
}
@@ -112,25 +112,25 @@ impl ApiClient for LexeApiClient {
112112
&self,
113113
data: SealedSeedId,
114114
) -> Result<Option<SealedSeed>, ApiError> {
115-
self.request(&GET, Backend, V1, "/sealed_seed", &data).await
115+
self.request(GET, Backend, V1, "/sealed_seed", &data).await
116116
}
117117

118118
async fn create_node_instance_seed(
119119
&self,
120120
data: NodeInstanceSeed,
121121
) -> Result<NodeInstanceSeed, ApiError> {
122122
let endpoint = "/acid/node_instance_seed";
123-
self.request(&POST, Backend, V1, endpoint, &data).await
123+
self.request(POST, Backend, V1, endpoint, &data).await
124124
}
125125

126126
async fn get_file(&self, data: &FileId) -> Result<Option<File>, ApiError> {
127127
let endpoint = "/file";
128-
self.request(&GET, Backend, V1, endpoint, &data).await
128+
self.request(GET, Backend, V1, endpoint, &data).await
129129
}
130130

131131
async fn create_file(&self, data: &File) -> Result<File, ApiError> {
132132
let endpoint = "/file";
133-
self.request(&POST, Backend, V1, endpoint, &data).await
133+
self.request(POST, Backend, V1, endpoint, &data).await
134134
}
135135

136136
async fn create_file_with_retries(
@@ -139,13 +139,13 @@ impl ApiClient for LexeApiClient {
139139
retries: usize,
140140
) -> Result<File, ApiError> {
141141
let endpoint = "/file";
142-
self.request_with_retries(&POST, Backend, V1, endpoint, &data, retries)
142+
self.request_with_retries(POST, Backend, V1, endpoint, &data, retries)
143143
.await
144144
}
145145

146146
async fn upsert_file(&self, data: &File) -> Result<File, ApiError> {
147147
let endpoint = "/file";
148-
self.request(&PUT, Backend, V1, endpoint, &data).await
148+
self.request(PUT, Backend, V1, endpoint, &data).await
149149
}
150150

151151
async fn upsert_file_with_retries(
@@ -154,7 +154,7 @@ impl ApiClient for LexeApiClient {
154154
retries: usize,
155155
) -> Result<File, ApiError> {
156156
let endpoint = "/file";
157-
self.request_with_retries(&PUT, Backend, V1, endpoint, &data, retries)
157+
self.request_with_retries(PUT, Backend, V1, endpoint, &data, retries)
158158
.await
159159
}
160160

@@ -163,30 +163,30 @@ impl ApiClient for LexeApiClient {
163163
#[allow(dead_code)]
164164
async fn delete_file(&self, data: &FileId) -> Result<String, ApiError> {
165165
let endpoint = "/file";
166-
self.request(&DELETE, Backend, V1, endpoint, &data).await
166+
self.request(DELETE, Backend, V1, endpoint, &data).await
167167
}
168168

169169
async fn get_directory(
170170
&self,
171171
data: &Directory,
172172
) -> Result<Vec<File>, ApiError> {
173173
let endpoint = "/directory";
174-
self.request(&GET, Backend, V1, endpoint, &data).await
174+
self.request(GET, Backend, V1, endpoint, &data).await
175175
}
176176

177177
async fn notify_runner(
178178
&self,
179179
data: UserPorts,
180180
) -> Result<UserPorts, ApiError> {
181-
self.request(&POST, Runner, V1, "/ready", &data).await
181+
self.request(POST, Runner, V1, "/ready", &data).await
182182
}
183183
}
184184

185185
impl LexeApiClient {
186186
/// Makes an API request, retrying up to `DEFAULT_RETRIES` times.
187187
async fn request<D: Serialize, T: DeserializeOwned>(
188188
&self,
189-
method: &Method,
189+
method: Method,
190190
base: BaseUrl,
191191
ver: ApiVersion,
192192
endpoint: &str,
@@ -206,7 +206,7 @@ impl LexeApiClient {
206206
/// Makes an API request, retrying up to `retries` times.
207207
async fn request_with_retries<D: Serialize, T: DeserializeOwned>(
208208
&self,
209-
method: &Method,
209+
method: Method,
210210
base: BaseUrl,
211211
ver: ApiVersion,
212212
endpoint: &str,
@@ -244,7 +244,7 @@ impl LexeApiClient {
244244
/// Constructs the final, serialized parts of a [`reqwest::Request`].
245245
fn serialize_parts<D: Serialize>(
246246
&self,
247-
method: &Method,
247+
method: Method,
248248
base: BaseUrl,
249249
ver: ApiVersion,
250250
endpoint: &str,
@@ -258,7 +258,6 @@ impl LexeApiClient {
258258
let mut url = format!("{}{}{}", base, ver, endpoint);
259259

260260
// If GET, serialize the data in a query string
261-
let method = method.to_owned();
262261
let query_str = match method {
263262
GET => Some(serde_qs::to_string(data)?),
264263
_ => None,

0 commit comments

Comments
 (0)