Rename Response::Ok to Response::Nil.

This is a better name because it signals "no data in response" rather
than "Ok", which is semantically mixed with `Ok/Err` of `Result`.
This commit is contained in:
Henry de Valence 2020-02-07 21:52:20 -08:00
parent 5929e05e52
commit 29f901add3
4 changed files with 7 additions and 7 deletions

View File

@ -53,11 +53,11 @@ impl Handler {
use Handler::*;
let mut ignored_msg = None;
// XXX can this be avoided?
let tmp_state = std::mem::replace(self, Finished(Ok(Response::Ok)));
let tmp_state = std::mem::replace(self, Finished(Ok(Response::Nil)));
*self = match (tmp_state, msg) {
(Ping(req_nonce), Message::Pong(rsp_nonce)) => {
if req_nonce == rsp_nonce {
Finished(Ok(Response::Ok))
Finished(Ok(Response::Nil))
} else {
Ping(req_nonce)
}
@ -407,7 +407,7 @@ where
};
match rsp {
Response::Ok => { /* generic success, do nothing */ }
Response::Nil => { /* generic success, do nothing */ }
Response::Error => {
if let Err(e) = self.peer_tx.send(Message::from(PeerError::Rejected)).await {
self.fail_with(e.into());

View File

@ -8,8 +8,8 @@ use crate::meta_addr::MetaAddr;
/// A response to a network request, represented in internal format.
#[derive(Clone, Debug)]
pub enum Response {
/// Generic success.
Ok,
/// A response with no data.
Nil,
/// Generic error.
Error,

View File

@ -51,7 +51,7 @@ impl ConnectCmd {
let node = Buffer::new(
service_fn(|req| async move {
info!(?req);
Ok::<Response, Error>(Response::Ok)
Ok::<Response, Error>(Response::Nil)
}),
1,
);

View File

@ -92,7 +92,7 @@ impl Service<Request> for SeedService {
}
_ => {
debug!("ignoring request");
Ok(Response::Ok)
Ok(Response::Nil)
}
};
Box::pin(futures::future::ready(response))