cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
unix_socket_address.h
Go to the documentation of this file.
1/*
2 * Copyright 2024 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include "msgpack_rpc/config.h"
23
24#if MSGPACK_RPC_HAS_UNIX_SOCKETS
25
26#include <ostream>
27#include <string>
28
29#include <asio/local/stream_protocol.hpp>
30#include <fmt/base.h>
31
34#include "msgpack_rpc/impl/msgpack_rpc_export.h"
35
36namespace msgpack_rpc::addresses {
37
41using AsioUnixSocketAddress = asio::local::stream_protocol::endpoint;
42
46class MSGPACK_RPC_EXPORT UnixSocketAddress final : public IAddress {
47public:
56 explicit UnixSocketAddress(AsioUnixSocketAddress address);
57
63 [[nodiscard]] std::string file_path() const;
64
66 [[nodiscard]] URI to_uri() const override;
67
69 [[nodiscard]] std::string to_string() const override;
70
76 [[nodiscard]] const AsioUnixSocketAddress& asio_address() const;
77
85 [[nodiscard]] bool operator==(const UnixSocketAddress& right) const;
86
94 [[nodiscard]] bool operator!=(const UnixSocketAddress& right) const;
95
96private:
98 AsioUnixSocketAddress address_;
99};
100
101} // namespace msgpack_rpc::addresses
102
103namespace fmt {
104
109template <>
110class formatter<msgpack_rpc::addresses::UnixSocketAddress> {
111public:
118 constexpr format_parse_context::iterator parse( // NOLINT
119 format_parse_context& context) {
120 return context.end();
121 }
122
130 MSGPACK_RPC_EXPORT format_context::iterator format( // NOLINT
131 const msgpack_rpc::addresses::UnixSocketAddress& val,
132 format_context& context) const;
133};
134
135} // namespace fmt
136
144MSGPACK_RPC_EXPORT std::ostream& operator<<(std::ostream& stream,
145 const msgpack_rpc::addresses::UnixSocketAddress& address);
146
147#endif
Interface of addresses.
Definition i_address.h:31
Definitions of platform-specific macros.
Definition of IAddress.
Namespace of fmt library.
Definition uri.h:113
Namespace of addresses.
Definition i_address.h:26
bool operator!=(const MethodName &left, const MethodName &right) noexcept
Compare two method names.
bool operator==(const MethodName &left, const MethodName &right) noexcept
Compare two method names.
Definition of URI class.
std::ostream & operator<<(std::ostream &stream, const msgpack_rpc::addresses::URI &uri)
Format a URI.
Definition uri.cpp:110