Skip to content

Commit 5246ce0

Browse files
committed
Minor formatting and code simplification for clippy
1 parent 2ffbf18 commit 5246ce0

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

sdks/rust/src/credentials.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ mod web_mod {
199199
/// Gets the value of a cookie by name.
200200
pub fn get(name: &str) -> Result<Option<String>, CookieError> {
201201
let doc = get_html_document();
202-
let all = doc.cookie().map_err(|e| CookieError::Get(e))?;
202+
let all = doc.cookie().map_err(CookieError::Get)?;
203203
for cookie in all.split(';') {
204204
let cookie = cookie.trim();
205205
if let Some((k, v)) = cookie.split_once('=') {
@@ -248,19 +248,19 @@ mod web_mod {
248248
let mut parts = vec![format!("{}={}", self.name, self.value)];
249249

250250
if let Some(path) = self.path {
251-
parts.push(format!("Path={}", path));
251+
parts.push(format!("Path={path}"));
252252
}
253253
if let Some(domain) = self.domain {
254-
parts.push(format!("Domain={}", domain));
254+
parts.push(format!("Domain={domain}"));
255255
}
256256
if let Some(age) = self.max_age {
257-
parts.push(format!("Max-Age={}", age));
257+
parts.push(format!("Max-Age={age}"));
258258
}
259259
if self.secure {
260260
parts.push("Secure".into());
261261
}
262262
if let Some(same) = self.same_site {
263-
parts.push(format!("SameSite={}", same.to_string()));
263+
parts.push(format!("SameSite={same}"));
264264
}
265265

266266
let cookie_str = parts.join("; ");
@@ -289,12 +289,12 @@ mod web_mod {
289289
None,
290290
}
291291

292-
impl ToString for SameSite {
293-
fn to_string(&self) -> String {
292+
impl std::fmt::Display for SameSite {
293+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
294294
match self {
295-
SameSite::Strict => "Strict".into(),
296-
SameSite::Lax => "Lax".into(),
297-
SameSite::None => "None".into(),
295+
SameSite::Strict => f.write_str("Strict"),
296+
SameSite::Lax => f.write_str("Lax"),
297+
SameSite::None => f.write_str("None"),
298298
}
299299
}
300300
}

sdks/rust/src/websocket.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,11 @@ async fn fetch_ws_token(host: &Uri, auth_token: &str) -> Result<String, WsError>
264264
use js_sys::{Reflect, JSON};
265265
use wasm_bindgen::{JsCast, JsValue};
266266

267-
let url = format!("{}v1/identity/websocket-token", host);
267+
let url = format!("{host}v1/identity/websocket-token");
268268

269269
// helpers to convert gloo_net::Error or JsValue into WsError::TokenVerification
270270
let gloo_to_ws_err = |e: gloo_net::Error| match e {
271-
gloo_net::Error::JsError(js_err) => WsError::TokenVerification(js_err.message.into()),
271+
gloo_net::Error::JsError(js_err) => WsError::TokenVerification(js_err.message),
272272
gloo_net::Error::SerdeError(e) => WsError::TokenVerification(e.to_string()),
273273
gloo_net::Error::GlooError(msg) => WsError::TokenVerification(msg),
274274
};
@@ -278,7 +278,7 @@ async fn fetch_ws_token(host: &Uri, auth_token: &str) -> Result<String, WsError>
278278
} else if let Some(s) = e.as_string() {
279279
WsError::TokenVerification(s)
280280
} else {
281-
WsError::TokenVerification(format!("{:?}", e))
281+
WsError::TokenVerification(format!("{e:?}"))
282282
}
283283
};
284284

@@ -547,7 +547,6 @@ impl WsConnection {
547547
mpsc::UnboundedReceiver<ServerMessage<BsatnFormat>>,
548548
mpsc::UnboundedSender<ClientMessage<Bytes>>,
549549
) {
550-
551550
let websocket_received = CLIENT_METRICS.websocket_received.with_label_values(&self.db_name);
552551
let websocket_received_msg_size = CLIENT_METRICS
553552
.websocket_received_msg_size

0 commit comments

Comments
 (0)