Skip to content

Commit 240f94f

Browse files
drop static lifetime requirement for request name
1 parent 33b0b21 commit 240f94f

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

plugins/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl<'a> ServiceGenerator<'a> {
666666
),*
667667
}
668668
impl ::tarpc::RequestName for #request_ident {
669-
fn name(&self) -> &'static str {
669+
fn name(&self) -> &str {
670670
match self {
671671
#(
672672
#( #method_cfgs )*

tarpc/src/lib.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ use std::{any::Any, error::Error, io, sync::Arc, time::Instant};
255255
/// A message from a client to a server.
256256
#[derive(Debug)]
257257
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
258-
#[non_exhaustive]
259258
pub enum ClientMessage<T> {
260259
/// A request initiated by a user. The server responds to a request by invoking a
261260
/// service-provided request handler. The handler completes with a [`response`](Response), which
@@ -280,7 +279,6 @@ pub enum ClientMessage<T> {
280279

281280
/// A request from a client to a server.
282281
#[derive(Clone, Copy, Debug)]
283-
#[non_exhaustive]
284282
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
285283
pub struct Request<T> {
286284
/// Trace context, deadline, and other cross-cutting concerns.
@@ -294,14 +292,14 @@ pub struct Request<T> {
294292
/// Implemented by the request types generated by tarpc::service.
295293
pub trait RequestName {
296294
/// The name of a request.
297-
fn name(&self) -> &'static str;
295+
fn name(&self) -> &str;
298296
}
299297

300298
impl<Req> RequestName for Arc<Req>
301299
where
302300
Req: RequestName,
303301
{
304-
fn name(&self) -> &'static str {
302+
fn name(&self) -> &str {
305303
self.as_ref().name()
306304
}
307305
}
@@ -310,57 +308,56 @@ impl<Req> RequestName for Box<Req>
310308
where
311309
Req: RequestName,
312310
{
313-
fn name(&self) -> &'static str {
311+
fn name(&self) -> &str {
314312
self.as_ref().name()
315313
}
316314
}
317315

318316
/// Impls for common std types for testing.
319317
impl RequestName for String {
320-
fn name(&self) -> &'static str {
318+
fn name(&self) -> &str {
321319
"string"
322320
}
323321
}
324322

325323
impl RequestName for char {
326-
fn name(&self) -> &'static str {
324+
fn name(&self) -> &str {
327325
"char"
328326
}
329327
}
330328

331329
impl RequestName for () {
332-
fn name(&self) -> &'static str {
330+
fn name(&self) -> &str {
333331
"unit"
334332
}
335333
}
336334

337335
impl RequestName for i32 {
338-
fn name(&self) -> &'static str {
336+
fn name(&self) -> &str {
339337
"i32"
340338
}
341339
}
342340

343341
impl RequestName for u32 {
344-
fn name(&self) -> &'static str {
342+
fn name(&self) -> &str {
345343
"u32"
346344
}
347345
}
348346

349347
impl RequestName for i64 {
350-
fn name(&self) -> &'static str {
348+
fn name(&self) -> &str {
351349
"i64"
352350
}
353351
}
354352

355353
impl RequestName for u64 {
356-
fn name(&self) -> &'static str {
354+
fn name(&self) -> &str {
357355
"u64"
358356
}
359357
}
360358

361359
/// A response from a server to a client.
362360
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
363-
#[non_exhaustive]
364361
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
365362
pub struct Response<T> {
366363
/// The ID of the request being responded to.

0 commit comments

Comments
 (0)