Skip to content

Commit

Permalink
header cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
falconindy committed Sep 10, 2024
1 parent da91b17 commit 5ed4438
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/aur/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "aur/client.hh"

#include <curl/curl.h>
#include <fcntl.h>
#include <systemd/sd-event.h>
#include <unistd.h>

Expand Down Expand Up @@ -189,16 +188,12 @@ class TypedResponseHandler : public ResponseHandler {
: ResponseHandler(client), callback_(std::move(callback)) {}

protected:
absl::StatusOr<ResponseT> MakeResponse() {
return ResponseT::Parse(std::move(body));
}

int RunCallback(absl::Status status) override {
if (status.ok()) {
return std::move(callback_)(MakeResponse());
} else {
if (!status.ok()) {
return std::move(callback_)(std::move(status));
}

return std::move(callback_)(ResponseT::Parse(std::move(body)));
}

private:
Expand Down
7 changes: 3 additions & 4 deletions src/aur/response.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
#include "aur/response.hh"

#include "absl/base/no_destructor.h"
#include "aur/json_internal.hh"

using nlohmann::json;
Expand All @@ -10,9 +9,9 @@ namespace aur {

absl::StatusOr<RpcResponse> RpcResponse::Parse(std::string_view bytes) {
try {
json j = json::parse(bytes);
if (auto iter = j.find("error"); iter != j.end()) {
return absl::InvalidArgumentError(iter->get<std::string>());
const json j = json::parse(bytes);
if (const auto iter = j.find("error"); iter != j.end()) {
return absl::InvalidArgumentError(iter->get<std::string_view>());
}

return RpcResponse(j["results"].get<std::vector<Package>>());
Expand Down
5 changes: 4 additions & 1 deletion src/aur/response.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#ifndef AUR_RESPONSE_HH_
#define AUR_RESPONSE_HH_

#include "absl/status/status.h"
#include <string>
#include <string_view>
#include <vector>

#include "absl/status/statusor.h"
#include "aur/package.hh"

Expand Down

0 comments on commit 5ed4438

Please sign in to comment.