llmx-rtaco 0.0.1
RTNL-only netlink control-plane library for Linux (C++23).
Loading...
Searching...
No Matches
nl_socket_guard.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <expected>
4#include <string_view>
5#include <system_error>
6
8
9namespace boost {
10namespace asio {
11class io_context;
12}
13} // namespace boost
14
15namespace llmx {
16namespace rtaco {
17
26public:
28 SocketGuard(boost::asio::io_context& io, std::string_view label) noexcept;
29
31 SocketGuard(boost::asio::io_context& io, std::string_view label,
32 uint32_t group_mask) noexcept;
33
34 SocketGuard(const SocketGuard&) = delete;
38
40 auto socket() -> Socket&;
41
46 auto ensure_open() -> std::expected<void, std::error_code>;
47
49 void stop();
50
51private:
53 uint32_t group_mask_;
54};
55
56} // namespace rtaco
57} // namespace llmx
SocketGuard(SocketGuard &&)=delete
auto socket() -> Socket &
Access the underlying Socket instance.
Definition nl_socket_guard.cxx:30
auto ensure_open() -> std::expected< void, std::error_code >
Ensure the underlying socket is open, opening it if necessary.
Definition nl_socket_guard.cxx:34
SocketGuard(boost::asio::io_context &io, std::string_view label) noexcept
Construct a SocketGuard holding a labeled Socket.
Definition nl_socket_guard.cxx:22
SocketGuard & operator=(const SocketGuard &)=delete
SocketGuard & operator=(SocketGuard &&)=delete
SocketGuard(const SocketGuard &)=delete
uint32_t group_mask_
Definition nl_socket_guard.hxx:53
void stop()
Stop and close the guarded socket.
Definition nl_socket_guard.cxx:54
Socket socket_
Definition nl_socket_guard.hxx:52
RAII wrapper for a Boost.Asio netlink socket.
Definition nl_socket.hxx:46
Definition nl_socket.hxx:27
Definition nl_socket.hxx:26
Definition nl_common.hxx:21
Definition nl_common.hxx:20
Netlink socket helper declarations.