Clarify the ClientRequest invariant

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
This commit is contained in:
teor 2021-01-05 11:15:32 +10:00 committed by Jane Lusby
parent f8ff2e9c0b
commit d5cfd5ad5f
1 changed files with 2 additions and 0 deletions

View File

@ -33,6 +33,8 @@ pub(super) struct ClientRequest {
/// future that may be moved around before it resolves.
///
/// INVARIANT: `tx.send()` must be called before dropping `tx`.
///
/// JUSTIFICATION: the `peer::Client` will translate all `Request`s into a `ClientRequest` which it sends to a background task, and if the send replies with `Ok(())` it will assume that it is safe to unconditionally poll the `Receiver` tied to the `Sender` used to create the `ClientRequest`.
pub tx: MustUseOneshotSender<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.