Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
i_transport.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
11#pragma once
12
21#include "types.h"
22
23#include <cstddef>
24#include <span>
25#include <string_view>
26#include <vector>
27
29
31
74public:
78 virtual ~i_transport() = default;
79
80 // Non-copyable (interface class, typically used via unique_ptr/shared_ptr)
81 i_transport(const i_transport&) = delete;
83
84 // Movable (for transfer of ownership)
87
88 // =========================================================================
89 // Data Transfer Operations
90 // =========================================================================
91
109 [[nodiscard]] virtual auto send(std::span<const std::byte> data) -> VoidResult = 0;
110
119 [[nodiscard]] virtual auto send(std::vector<uint8_t>&& data) -> VoidResult = 0;
120
121 // =========================================================================
122 // State Query Operations
123 // =========================================================================
124
139 [[nodiscard]] virtual auto is_connected() const noexcept -> bool = 0;
140
148 [[nodiscard]] virtual auto id() const noexcept -> std::string_view = 0;
149
157 [[nodiscard]] virtual auto remote_endpoint() const noexcept -> endpoint_info = 0;
158
166 [[nodiscard]] virtual auto local_endpoint() const noexcept -> endpoint_info = 0;
167
168protected:
172 i_transport() = default;
173};
174
175} // namespace kcenon::network::unified
Core interface for data transport abstraction.
Definition i_transport.h:73
i_transport & operator=(i_transport &&)=default
virtual auto remote_endpoint() const noexcept -> endpoint_info=0
Gets the remote endpoint information.
i_transport(const i_transport &)=delete
virtual auto local_endpoint() const noexcept -> endpoint_info=0
Gets the local endpoint information.
virtual auto send(std::vector< uint8_t > &&data) -> VoidResult=0
Sends data from a uint8_t vector.
i_transport(i_transport &&)=default
virtual ~i_transport()=default
Virtual destructor for proper cleanup of derived classes.
virtual auto send(std::span< const std::byte > data) -> VoidResult=0
Sends raw data to the remote endpoint.
virtual auto is_connected() const noexcept -> bool=0
Checks if the transport is currently connected.
i_transport & operator=(const i_transport &)=delete
Network-specific error and result type definitions.
Network endpoint information (host/port or URL)
Definition types.h:56
Network endpoint types (host/port, URL) and common type aliases.