Skip to content

Commit

Permalink
Merge pull request #53 from pi-hole/fix/outdated-reply-comment
Browse files Browse the repository at this point in the history
Fix outdated comments in util.rs about the reply format
  • Loading branch information
AzureMarker authored Sep 20, 2018
2 parents e8e808e + a3c7204 commit 4854425
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ pub fn reply<D: Serialize>(data: ReplyType<D>, status: Status) -> Reply {
Ok(SetStatus(Json(json_data), status))
}

/// Create a reply from some serializable data. The reply will contain no
/// errors and will have a status code of 200.
/// Create a reply from some serializable data. The reply will have a status
/// code of 200.
pub fn reply_data<D: Serialize>(data: D) -> Reply {
reply(ReplyType::Data(data), Status::Ok)
}

/// Create a reply with an error. The data will be an empty array and the
/// status will taken from `error.status()`.
/// Create a reply with an error. The status will taken from `error.status()`.
pub fn reply_error<E: Into<Error>>(error: E) -> Reply {
let error = error.into();
let status = error.status();
Expand All @@ -65,6 +64,7 @@ pub fn reply_success() -> Reply {
reply(ReplyType::Data(json!({ "status": "success" })), Status::Ok)
}

/// The type of reply which should be sent.
pub enum ReplyType<D: Serialize> {
Data(D),
Error(Error)
Expand Down

0 comments on commit 4854425

Please sign in to comment.