Mark ClientRequest and State::AwaitingResponse as must_use

This commit is contained in:
teor 2020-12-15 19:05:26 +10:00 committed by Jane Lusby
parent d67de58554
commit 28f3186182
2 changed files with 4 additions and 0 deletions

View File

@ -25,11 +25,14 @@ pub struct Client {
/// A message from the `peer::Client` to the `peer::Server`.
#[derive(Debug)]
#[must_use = "tx.send() must be called before drop"]
pub(super) struct ClientRequest {
/// The actual request.
pub request: Request,
/// The return message channel, included because `peer::Client::call` returns a
/// future that may be moved around before it resolves.
///
/// INVARIANT: `tx.send()` must be called before dropping `tx`.
pub tx: oneshot::Sender<Result<Response, SharedPeerError>>,
/// The tracing context for the request, so that work the connection task does
/// processing messages in the context of this request will have correct context.

View File

@ -304,6 +304,7 @@ impl Handler {
}
}
#[must_use = "AwaitingResponse.tx.send() must be called before drop"]
pub(super) enum State {
/// Awaiting a client request or a peer message.
AwaitingRequest,