4#include "web/SubscriptionContextInterface.hpp"
6#include <boost/asio/spawn.hpp>
7#include <boost/json/array.hpp>
8#include <boost/json/conversion.hpp>
9#include <boost/json/object.hpp>
10#include <boost/json/value.hpp>
11#include <boost/json/value_from.hpp>
12#include <xrpl/basics/base_uint.h>
13#include <xrpl/basics/strHex.h>
48 bool const lhsHasError = !
static_cast<bool>(lhs);
49 bool const rhsHasError = !
static_cast<bool>(rhs);
50 return lhsHasError == rhsHasError && (!lhsHasError || lhs.error() == rhs.error());
56using Error = std::unexpected<Status>;
61template <
typename OutputType>
74 ReturnType(std::expected<boost::json::value, Status> result, boost::json::array warnings = {})
75 : result{std::move(result)}, warnings(std::move(warnings))
84 return result.has_value();
87 std::expected<boost::json::value, Status> result;
88 boost::json::array warnings;
100 boost::asio::yield_context yield;
102 bool isAdmin =
false;
103 std::string clientIp = {};
104 uint32_t apiVersion = 0u;
119 response = std::move(returnType.result).value().as_object();
121 response = std::unexpected{std::move(returnType.result).error()};
123 warnings = std::move(returnType.warnings);
131 explicit Result(
Status status) : response{std::unexpected{std::move(status)}}
140 explicit Result(boost::json::object response) : response{std::move(response)}
144 std::expected<boost::json::object, Status> response;
145 boost::json::array warnings;
152 ripple::uint256 index;
153 std::uint32_t hint{};
163 return ripple::strHex(index) +
"," + std::to_string(hint);
174 return index.isNonZero() || hint != 0;
188 jv = boost::json::object{};
This class is used to manage connections to transaction processing processes.
Definition LoadBalancer.hpp:59
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:62
std::expected< void, Status > MaybeError
Return type used for Validators that can return error but don't have specific value to return.
Definition Types.hpp:36
void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, BookChange const &change)
Implementation of value_from for BookChange type.
Definition BookChangesHelper.hpp:233
std::unexpected< Status > Error
The type that represents just the error part of MaybeError.
Definition Types.hpp:56
bool operator==(MaybeError const &lhs, MaybeError const &rhs)
Check if two MaybeError objects are equal.
Definition Types.hpp:46
This namespace implements the web server and related components.
Definition Types.hpp:24
std::shared_ptr< SubscriptionContextInterface > SubscriptionContextPtr
An alias for shared pointer to a SubscriptionContextInterface.
Definition SubscriptionContextInterface.hpp:64
A cursor object used to traverse nodes owned by an account.
Definition Types.hpp:151
std::string toString() const
Convert the cursor to a string.
Definition Types.hpp:161
bool isNonZero() const
Check if the cursor is non-zero.
Definition Types.hpp:172
Context of an RPC call.
Definition Types.hpp:99
Result(boost::json::object response)
Construct a new Result object from a response object.
Definition Types.hpp:140
Result(ReturnType returnType)
Construct a new Result object from ReturnType.
Definition Types.hpp:116
Result(Status status)
Construct a new Result object from Status.
Definition Types.hpp:131
The final return type out of RPC engine.
Definition Types.hpp:67
ReturnType(std::expected< boost::json::value, Status > result, boost::json::array warnings={})
Construct a new Return Type object.
Definition Types.hpp:74
A status returned from any RPC handler.
Definition Errors.hpp:65
An empty type used as Output for handlers than don't actually produce output.
Definition Types.hpp:94
Base class for all connections.
Definition ConnectionBase.hpp:25