StormByte-Buffer 2.0.0
C++26 buffer module of the StormByte suite
 
Loading...
Searching...
No Matches
typedefs.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-Buffer.
5 *
6 * StormByte-Buffer 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-Buffer 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-Logger tree and
23 * the rest of the StormByte suite it vendors), which remains under its own
24 * license.
25 *
26 * Neither license grants any patent rights. Any patent licenses required
27 * to use this software or third-party components must be obtained separately
28 * from the patent holders.
29 *
30 * StormByte-Buffer is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public License
36 * version 3 along with StormByte-Buffer. If not, see
37 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
38 *
39 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
40 */
41
42#pragma once
43
46
47#include <string_view>
48
53namespace StormByte {
58 namespace Buffer {
63 namespace IO {
73 Ok,
74 End,
75 Error,
76 Failed,
78 };
79
95
101 [[nodiscard]] constexpr std::string_view ToString(Status status) noexcept {
102 switch (status) {
103 case Status::Ok: return "Ok";
104 case Status::End: return "End";
105 case Status::Error: return "Error";
106 case Status::Failed: return "Failed";
107 case Status::TryAgain: return "TryAgain";
108 }
109 return {};
110 }
111
117 [[nodiscard]] constexpr std::string_view ToString(State state) noexcept {
118 switch (state) {
119 case State::Idle: return "Idle";
120 case State::Missing: return "Missing";
121 case State::Directory: return "Directory";
122 case State::Permission: return "Permission";
123 case State::NotWritable: return "NotWritable";
124 case State::Fault: return "Fault";
125 case State::Unavailable: return "Unavailable";
126 }
127 return {};
128 }
129
141 Local,
142 Remote
143 };
144
150 [[nodiscard]] constexpr std::string_view ToString(Location location) noexcept {
151 switch (location) {
152 case Location::Local: return "Local";
153 case Location::Remote: return "Remote";
154 }
155 return {};
156 }
157
172
177 namespace Drainer {
186 Started,
187 Paused,
188 Stopped
189 };
190
196 Toggle,
197 Flush
198 };
199
205 [[nodiscard]] constexpr std::string_view ToString(Status status) noexcept {
206 switch (status) {
207 case Status::Started: return "Started";
208 case Status::Paused: return "Paused";
209 case Status::Stopped: return "Stopped";
210 }
211 return {};
212 }
213
219 [[nodiscard]] constexpr std::string_view ToString(Operation operation) noexcept {
220 switch (operation) {
221 case Operation::Toggle: return "Toggle";
222 case Operation::Flush: return "Flush";
223 }
224 return {};
225 }
226 }
227 }
228 }
229}
constexpr std::string_view ToString(Status status) noexcept
Enumerator name of status.
Definition typedefs.hxx:205
Status
Whether the Bridge worker is pumping.
Definition typedefs.hxx:185
@ Started
Worker may pull when there is room.
@ Paused
Worker does not pull. Ctor if high_water is 0.
Operation
Verbs for StormByte::Buffer::Bridge::Drainer.
Definition typedefs.hxx:195
@ Flush
Push what is already held. No destination flush.
Location
Where the bytes of a file-like source or sink live.
Definition typedefs.hxx:140
@ Local
Path is a filesystem path on this machine.
@ Remote
Path names a non-local target.
Status
Outcome of a single I/O call.
Definition typedefs.hxx:72
@ End
Origin exhausted; Result::count may be short.
@ Error
Origin failed during the call; buffers untouched.
@ Ok
The call completed as requested (see Result::count).
@ Failed
Illegal call or dead session; buffers untouched.
@ TryAgain
Not accepted; buffers untouched. State stays Idle.
State
Session state of a coordinated reader or writer.
Definition typedefs.hxx:86
@ Missing
Last Open: path or parent does not exist.
@ Fault
Origin I/O error mid-transfer.
@ Unavailable
Ctor, after Close, or origin gone.
@ Directory
Last Open: path is a directory.
@ NotWritable
Last Open or mid-write: cannot write.
@ Permission
Last Open: exists; read open denied.
constexpr std::string_view ToString(Status status) noexcept
Enumerator name of status.
Definition typedefs.hxx:101
Root namespace of the StormByte C++ suite.
Per-call status plus how many bytes this call transferred.
Definition typedefs.hxx:168
Status status
Outcome of the call.
Definition typedefs.hxx:169
StormByte::ByteSize count
Bytes transferred this call.
Definition typedefs.hxx:170
#define STORMBYTE_BUFFER_PUBLIC
Definition visibility.h:54