StormByte-Network 4.0.0
C++26 networking module of the StormByte suite
Loading...
Searching...
No Matches
remote_file_mount.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Network.
5 *
6 * StormByte-Network original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Network source in this
20 * repository. They do not cover other StormByte modules or any third-party
21 * material shipped with this repository (including everything under
22 * thirdparty/, and in particular the bundled StormByte Buffer tree), which
23 * remains under its own license.
24 *
25 * Neither license grants any patent rights. Any patent licenses required
26 * to use this software or third-party components must be obtained separately
27 * from the patent holders.
28 *
29 * StormByte-Network is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU Lesser General Public License for more details.
33 *
34 * You should have received a copy of the GNU Lesser General Public License
35 * version 3 along with StormByte-Network. If not, see
36 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
37 *
38 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
39 */
40
41#pragma once
42
44#include <StormByte/safe/binary.hxx>
45#include <StormByte/serializable.hxx>
46
47#include <array>
48#include <cstddef>
49#include <cstdint>
50#include <span>
51
56namespace StormByte {
61 namespace Network {
70 public:
74 using ChannelToken = std::array<std::byte, 32>;
75
80 enum class Status: std::uint8_t {
84 Authorized = 1,
85
90
95
100
105
110 };
111
116 enum class Access: std::uint8_t {
120 None = 0,
121
125 Read = 1,
126
130 Write = 2
131 };
132
138
143 static RemoteFileMount Unavailable() noexcept;
144
150
156
161 static RemoteFileMount Failed() noexcept;
162
168
174
180 RemoteFileMount& operator=(const RemoteFileMount& other);
181
187 RemoteFileMount& operator=(RemoteFileMount&& other) noexcept;
188
192 ~RemoteFileMount() noexcept;
193
198 std::uint16_t Port() const noexcept;
199
204 std::uint16_t MaximumTimeoutSeconds() const noexcept;
205
210 Status Result() const noexcept;
211
216 Access Mode() const noexcept;
217
222 const ChannelToken& Token() const noexcept;
223
224 private:
233 RemoteFileMount(Status status, ChannelToken token, std::uint16_t port,
234 std::uint16_t maximum_timeout_seconds, Access access) noexcept;
235
236 Status m_status;
237 ChannelToken m_token;
238 std::uint16_t m_port;
239 std::uint16_t m_maximum_timeout_seconds;
240 Access m_access;
241
245 friend class Server;
246
250 friend struct StormByte::Detail::Codec<RemoteFileMount>;
251 };
252 }
253
258 namespace Detail {
262 template<>
263 struct Codec<Network::RemoteFileMount> {
270
277
284 std::span<const std::byte> data) noexcept;
285 };
286 }
287}
288
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
Public, validated descriptor for attaching to one remote file channel.
Definition remote_file_mount.hxx:69
static RemoteFileMount FileBeingRead() noexcept
Construct a result for a write blocked by mounted readers.
static RemoteFileMount FileBeingWritten() noexcept
Construct a result for a mount blocked by an exclusive writer.
Status
Outcome of the application-authorized mount request.
Definition remote_file_mount.hxx:80
Access Mode() const noexcept
Authorized access mode.
std::array< std::byte, 32 > ChannelToken
Fixed-width opaque channel capability.
Definition remote_file_mount.hxx:74
RemoteFileMount(const RemoteFileMount &other)
Copy a validated mount descriptor.
static RemoteFileMount NotAuthorized() noexcept
Construct an application-level authorization denial.
Access
Permitted direction for this mounted channel.
Definition remote_file_mount.hxx:116
Status Result() const noexcept
Mount request result.
static RemoteFileMount Failed() noexcept
Construct a non-authorization mount failure.
static RemoteFileMount Unavailable() noexcept
Construct a missing-file result without channel credentials.
std::uint16_t MaximumTimeoutSeconds() const noexcept
Maximum idle interval for the Client's peer data-plane heartbeat.
const ChannelToken & Token() const noexcept
Opaque capability checked by the private channel protocol.
friend class Server
Server may construct authorized mount descriptors.
Definition remote_file_mount.hxx:245
std::uint16_t Port() const noexcept
Session data-plane port shared by every Authorized mount from one Client.
Network module of the StormByte suite.
Root namespace of the StormByte suite.
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > > Expected
STL namespace.
static Expected< Network::RemoteFileMount, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decode and validate a complete mount descriptor.
static ByteSize Size(const Network::RemoteFileMount &data) noexcept
Exact serialized size of a mount descriptor.
static Safe::Binary Write(const Network::RemoteFileMount &data) noexcept
Encode a mount descriptor field-by-field.
#define STORMBYTE_NETWORK_PUBLIC
Definition visibility.h:51