contur2
Loading...
Searching...
No Matches
i_ipc_channel.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstddef>
7#include <span>
8#include <string_view>
9
10#include "contur/core/error.h"
11
12namespace contur {
13
19 {
20 public:
21 virtual ~IIpcChannel() = default;
22
26 [[nodiscard]] virtual Result<std::size_t> write(std::span<const std::byte> data) = 0;
27
31 [[nodiscard]] virtual Result<std::size_t> read(std::span<std::byte> buffer) = 0;
32
34 virtual void close() = 0;
35
37 [[nodiscard]] virtual bool isOpen() const noexcept = 0;
38
40 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
41 };
42
43} // namespace contur
Common interface for IPC channels.
virtual Result< std::size_t > write(std::span< const std::byte > data)=0
Writes up to data.size() bytes into the channel.
virtual void close()=0
Closes the channel and releases transient state.
virtual bool isOpen() const noexcept=0
Returns whether the channel accepts read/write operations.
virtual std::string_view name() const noexcept=0
Human-readable channel name.
virtual Result< std::size_t > read(std::span< std::byte > buffer)=0
Reads up to buffer.size() bytes from the channel.
virtual ~IIpcChannel()=default
A result type that holds either a success value of type T or an ErrorCode.
Definition error.h:104
Error codes and Result<T> type for fallible operations.
Definition block.h:15