mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-02-23 15:49:54 +01:00
Replace _non_exhaustive fields with #[non_exhaustive] attribute.
The attribute landed on stable rust (1.40.0) today. Fixes https://github.com/google/tarpc/issues/275
This commit is contained in:
@@ -385,9 +385,7 @@ where
|
||||
context: context::Context {
|
||||
deadline: dispatch_request.ctx.deadline,
|
||||
trace_context: dispatch_request.ctx.trace_context,
|
||||
_non_exhaustive: (),
|
||||
},
|
||||
_non_exhaustive: (),
|
||||
});
|
||||
self.as_mut().project().transport.start_send(request)?;
|
||||
self.as_mut().project().in_flight_requests.insert(
|
||||
@@ -768,7 +766,6 @@ mod tests {
|
||||
Response {
|
||||
request_id: 0,
|
||||
message: Ok("hello".into()),
|
||||
_non_exhaustive: (),
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -104,6 +104,7 @@ where
|
||||
|
||||
/// Settings that control the behavior of the client.
|
||||
#[derive(Clone, Debug)]
|
||||
#[non_exhaustive]
|
||||
pub struct Config {
|
||||
/// The number of requests that can be in flight at once.
|
||||
/// `max_in_flight_requests` controls the size of the map used by the client
|
||||
@@ -113,8 +114,6 @@ pub struct Config {
|
||||
/// `pending_requests_buffer` controls the size of the channel clients use
|
||||
/// to communicate with the request dispatch task.
|
||||
pub pending_request_buffer: usize,
|
||||
#[doc(hidden)]
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -122,7 +121,6 @@ impl Default for Config {
|
||||
Config {
|
||||
max_in_flight_requests: 1_000,
|
||||
pending_request_buffer: 100,
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use std::time::{Duration, SystemTime};
|
||||
/// The context should not be stored directly in a server implementation, because the context will
|
||||
/// be different for each request in scope.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[non_exhaustive]
|
||||
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Context {
|
||||
/// When the client expects the request to be complete by. The server should cancel the request
|
||||
@@ -35,9 +36,6 @@ pub struct Context {
|
||||
/// include the same `trace_id` as that included on the original request. This way,
|
||||
/// users can trace related actions across a distributed system.
|
||||
pub trace_context: trace::Context,
|
||||
#[doc(hidden)]
|
||||
#[cfg_attr(feature = "serde1", serde(skip_serializing, default))]
|
||||
pub(crate) _non_exhaustive: (),
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde1")]
|
||||
@@ -51,7 +49,6 @@ pub fn current() -> Context {
|
||||
Context {
|
||||
deadline: SystemTime::now() + Duration::from_secs(10),
|
||||
trace_context: trace::Context::new_root(),
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ pub enum ClientMessage<T> {
|
||||
|
||||
/// A request from a client to a server.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[non_exhaustive]
|
||||
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Request<T> {
|
||||
/// Trace context, deadline, and other cross-cutting concerns.
|
||||
@@ -72,26 +73,22 @@ pub struct Request<T> {
|
||||
pub id: u64,
|
||||
/// The request body.
|
||||
pub message: T,
|
||||
#[doc(hidden)]
|
||||
#[cfg_attr(feature = "serde1", serde(skip_serializing, default))]
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
|
||||
/// A response from a server to a client.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Response<T> {
|
||||
/// The ID of the request being responded to.
|
||||
pub request_id: u64,
|
||||
/// The response body, or an error if the request failed.
|
||||
pub message: Result<T, ServerError>,
|
||||
#[doc(hidden)]
|
||||
#[cfg_attr(feature = "serde1", serde(skip_serializing, default))]
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
|
||||
/// An error response from a server to a client.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct ServerError {
|
||||
#[cfg_attr(
|
||||
@@ -106,9 +103,6 @@ pub struct ServerError {
|
||||
pub kind: io::ErrorKind,
|
||||
/// A message describing more detail about the error that occurred.
|
||||
pub detail: Option<String>,
|
||||
#[doc(hidden)]
|
||||
#[cfg_attr(feature = "serde1", serde(skip_serializing, default))]
|
||||
_non_exhaustive: (),
|
||||
}
|
||||
|
||||
impl From<ServerError> for io::Error {
|
||||
|
||||
@@ -569,11 +569,9 @@ where
|
||||
"Response did not complete before deadline of {}s.",
|
||||
format_rfc3339(self.deadline)
|
||||
)),
|
||||
_non_exhaustive: (),
|
||||
})
|
||||
}
|
||||
},
|
||||
_non_exhaustive: (),
|
||||
});
|
||||
*self.as_mut().project().state = RespState::PollReady;
|
||||
}
|
||||
|
||||
@@ -87,11 +87,9 @@ impl<Req, Resp> FakeChannel<io::Result<Request<Req>>, Response<Resp>> {
|
||||
context: context::Context {
|
||||
deadline: SystemTime::UNIX_EPOCH,
|
||||
trace_context: Default::default(),
|
||||
_non_exhaustive: (),
|
||||
},
|
||||
id,
|
||||
message,
|
||||
_non_exhaustive: (),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,7 @@ where
|
||||
message: Err(ServerError {
|
||||
kind: io::ErrorKind::WouldBlock,
|
||||
detail: Some("Server throttled the request.".into()),
|
||||
_non_exhaustive: (),
|
||||
}),
|
||||
_non_exhaustive: (),
|
||||
})?;
|
||||
}
|
||||
None => return Poll::Ready(None),
|
||||
@@ -311,7 +309,6 @@ fn throttler_start_send() {
|
||||
.start_send(Response {
|
||||
request_id: 0,
|
||||
message: Ok(1),
|
||||
_non_exhaustive: (),
|
||||
})
|
||||
.unwrap();
|
||||
assert!(throttler.inner.in_flight_requests.is_empty());
|
||||
@@ -320,7 +317,6 @@ fn throttler_start_send() {
|
||||
Some(&Response {
|
||||
request_id: 0,
|
||||
message: Ok(1),
|
||||
_non_exhaustive: ()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user