Update usage of ErrorOr in openscreen
This patch includes changes that make the usage of the ErrorOr
type more widespread throughout our codebase. Currently, we
only have a few example of this class, however there are multiple
opportunities for its use elsewhere.
NOTE: this patch mostly leaves alone the api/public services,
specifically the following classes are left using bool:
codegen (Write*)
mdns_responder_service (Handle*Event)
quic_client (Start, Stop)
quic_server (Start, Stop, Suspend, Resume)
service_listener, _impl (Start, Stop, ...)
service_publisher, _impl (Start, Stop, ....)
Bug: openscreen:26
Change-Id: I558b61a29046a263014e295958059d979cdca67e
Reviewed-on: https://chromium-review.googlesource.com/c/1443817
Commit-Queue: Jordan Bayles <jophba@chromium.org>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
diff --git a/platform/api/socket.h b/platform/api/socket.h
index 994b49d..0636225 100644
--- a/platform/api/socket.h
+++ b/platform/api/socket.h
@@ -5,6 +5,7 @@
#ifndef PLATFORM_API_SOCKET_H_
#define PLATFORM_API_SOCKET_H_
+#include "base/error.h"
#include "base/ip_address.h"
#include "platform/api/network_interface.h"
#include "third_party/abseil/src/absl/types/optional.h"
@@ -29,12 +30,12 @@
// Closes the underlying platform socket and frees any allocated memory.
void DestroyUdpSocket(UdpSocketPtr socket);
-bool BindUdpSocket(UdpSocketPtr socket,
- const IPEndpoint& endpoint,
- NetworkInterfaceIndex ifindex);
-bool JoinUdpMulticastGroup(UdpSocketPtr socket,
- const IPAddress& address,
- NetworkInterfaceIndex ifindex);
+Error BindUdpSocket(UdpSocketPtr socket,
+ const IPEndpoint& endpoint,
+ NetworkInterfaceIndex ifindex);
+Error JoinUdpMulticastGroup(UdpSocketPtr socket,
+ const IPAddress& address,
+ NetworkInterfaceIndex ifindex);
absl::optional<int64_t> ReceiveUdp(UdpSocketPtr socket,
void* data,