Skip to content

Commit b92aaaf

Browse files
authored
Fix new Rust 1.89 lifetime warnings and impl ToRpcParams on serde_json::Map (#1594)
1 parent c0b947f commit b92aaaf

File tree

10 files changed

+24
-18
lines changed

10 files changed

+24
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ rustls = { version = "0.23", default-features = false }
6868
rustls-pki-types = "1"
6969
rustls-platform-verifier = "0.5"
7070
serde = { version = "1", default-features = false, features = ["derive"] }
71-
serde_json = { version = "1", default-features = false, features = ["alloc", "raw_value"] }
71+
serde_json = { version = "1.0.142", default-features = false, features = ["alloc", "raw_value"] }
7272
soketto = "0.8.1"
7373
syn = { version = "2", default-features = false }
7474
thiserror = "2"

client/http-client/src/rpc_service.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ use crate::{
1414
transport::{Error as TransportError, HttpTransportClient},
1515
};
1616

17+
/// An [`RpcServiceT`] compliant implementation for the HTTP client.
1718
#[derive(Clone, Debug)]
1819
pub struct RpcService<HttpMiddleware> {
1920
service: Arc<HttpTransportClient<HttpMiddleware>>,
2021
}
2122

2223
impl<HttpMiddleware> RpcService<HttpMiddleware> {
24+
/// Convert an [`HttpTransportClient`] into an [`RpcService`].
2325
pub fn new(service: HttpTransportClient<HttpMiddleware>) -> Self {
2426
Self { service: Arc::new(service) }
2527
}

core/src/client/async_client/manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl RequestManager {
256256
&mut self,
257257
request_id: RequestId,
258258
subscription_id: SubscriptionId<'static>,
259-
) -> Option<(RequestId, SubscriptionSink, UnsubscribeMethod, SubscriptionId)> {
259+
) -> Option<(RequestId, SubscriptionSink, UnsubscribeMethod, SubscriptionId<'_>)> {
260260
match (self.requests.entry(request_id), self.subscriptions.entry(subscription_id)) {
261261
(Entry::Occupied(request), Entry::Occupied(subscription))
262262
if matches!(request.get(), Kind::Subscription(_)) =>
@@ -282,7 +282,7 @@ impl RequestManager {
282282
&mut self,
283283
request_id: RequestId,
284284
subscription_id: SubscriptionId<'static>,
285-
) -> Option<(RequestId, SubscriptionSink, UnsubscribeMethod, SubscriptionId)> {
285+
) -> Option<(RequestId, SubscriptionSink, UnsubscribeMethod, SubscriptionId<'_>)> {
286286
match (self.requests.entry(request_id), self.subscriptions.entry(subscription_id)) {
287287
(Entry::Occupied(mut request), Entry::Occupied(subscription))
288288
if matches!(request.get(), Kind::Subscription(_)) =>

core/src/client/async_client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl ThreadSafeRequestManager {
149149
Self::default()
150150
}
151151

152-
pub(crate) fn lock(&self) -> std::sync::MutexGuard<RequestManager> {
152+
pub(crate) fn lock(&self) -> std::sync::MutexGuard<'_, RequestManager> {
153153
self.0.lock().expect(NOT_POISONED)
154154
}
155155
}

core/src/server/subscription.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ impl Subscription {
429429
}
430430

431431
/// Get the subscription ID
432-
pub fn subscription_id(&self) -> &SubscriptionId {
432+
pub fn subscription_id(&self) -> &SubscriptionId<'static> {
433433
&self.sub_id
434434
}
435435

core/src/traits.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ macro_rules! to_rpc_params_impl {
9191
};
9292
}
9393

94+
impl ToRpcParams for serde_json::Map<String, serde_json::Value> {
95+
to_rpc_params_impl!();
96+
}
97+
9498
impl<P: Serialize> ToRpcParams for &[P] {
9599
to_rpc_params_impl!();
96100
}

proc-macros/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl AttributeMeta {
136136
/// Attempt to get a list of `Argument`s from a list of names in order.
137137
///
138138
/// Errors if there is an argument with a name that's not on the list, or if there is a duplicate definition.
139-
pub fn retain<const N: usize>(self, allowed: [&str; N]) -> syn::Result<[Result<Argument, MissingArgument>; N]> {
139+
pub fn retain<const N: usize>(self, allowed: [&str; N]) -> syn::Result<[Result<Argument, MissingArgument<'_>>; N]> {
140140
assert!(
141141
N != 0,
142142
"Calling `AttributeMeta::retain` with an empty `allowed` list, this is a bug, please report it"

server/src/server.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,13 @@ impl<HttpMiddleware, RpcMiddleware> Builder<HttpMiddleware, RpcMiddleware> {
696696
///
697697
/// impl<S> RpcServiceT for MyMiddleware<S>
698698
/// where
699-
/// S: RpcServiceT + Clone + Send + Sync + 'static,
699+
/// S: RpcServiceT + Clone + Send + Sync + 'static,
700700
/// {
701-
/// type MethodResponse = S::MethodResponse;
702-
/// type NotificationResponse = S::NotificationResponse;
703-
/// type BatchResponse = S::BatchResponse;
701+
/// type MethodResponse = S::MethodResponse;
702+
/// type NotificationResponse = S::NotificationResponse;
703+
/// type BatchResponse = S::BatchResponse;
704704
///
705-
/// fn call<'a>(&self, req: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a {
705+
/// fn call<'a>(&self, req: Request<'a>) -> impl Future<Output = Self::MethodResponse> + Send + 'a {
706706
/// tracing::info!("MyMiddleware processed call {}", req.method);
707707
/// let count = self.count.clone();
708708
/// let service = self.service.clone();
@@ -713,15 +713,15 @@ impl<HttpMiddleware, RpcMiddleware> Builder<HttpMiddleware, RpcMiddleware> {
713713
/// count.fetch_add(1, Ordering::Relaxed);
714714
/// rp
715715
/// }
716-
/// }
716+
/// }
717717
///
718-
/// fn batch<'a>(&self, batch: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a {
718+
/// fn batch<'a>(&self, batch: Batch<'a>) -> impl Future<Output = Self::BatchResponse> + Send + 'a {
719719
/// self.service.batch(batch)
720-
/// }
720+
/// }
721721
///
722-
/// fn notification<'a>(&self, notif: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a {
722+
/// fn notification<'a>(&self, notif: Notification<'a>) -> impl Future<Output = Self::NotificationResponse> + Send + 'a {
723723
/// self.service.notification(notif)
724-
/// }
724+
/// }
725725
/// }
726726
///
727727
/// // Create a state per connection

types/src/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'a> Params<'a> {
107107
///
108108
/// This allows sequential parsing of the incoming params, using an `Iterator`-style API and is useful when the RPC
109109
/// request has optional parameters at the tail that may or may not be present.
110-
pub fn sequence(&self) -> ParamsSequence {
110+
pub fn sequence(&self) -> ParamsSequence<'_> {
111111
let json = match self.0.as_ref() {
112112
// It's assumed that params is `[a,b,c]`, if empty regard as no params.
113113
Some(json) if json == "[]" => "",

types/src/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a> Request<'a> {
9191
}
9292

9393
/// Get the params of the request.
94-
pub fn params(&self) -> Params {
94+
pub fn params(&self) -> Params<'_> {
9595
Params::new(self.params.as_ref().map(|p| RawValue::get(p)))
9696
}
9797

0 commit comments

Comments
 (0)