| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
|
2 |
|
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/cppalliance/capy
|
7 |
|
// Official repository: https://github.com/cppalliance/capy
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#ifndef BOOST_CAPY_COND_HPP
|
10 |
|
#ifndef BOOST_CAPY_COND_HPP
|
| 11 |
|
#define BOOST_CAPY_COND_HPP
|
11 |
|
#define BOOST_CAPY_COND_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/capy/detail/config.hpp>
|
13 |
|
#include <boost/capy/detail/config.hpp>
|
| 14 |
|
|
14 |
|
|
| 15 |
|
|
15 |
|
|
| 16 |
|
|
16 |
|
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
/** Portable error conditions for capy I/O operations.
|
19 |
|
/** Portable error conditions for capy I/O operations.
|
| 20 |
|
|
20 |
|
|
| 21 |
|
These are the conditions callers should compare against when
|
21 |
|
These are the conditions callers should compare against when
|
| 22 |
|
handling errors from capy operations. The @ref error enum values
|
22 |
|
handling errors from capy operations. The @ref error enum values
|
| 23 |
|
map to these conditions, as do platform-specific error codes
|
23 |
|
map to these conditions, as do platform-specific error codes
|
| 24 |
|
(e.g., `ECANCELED`, SSL EOF errors).
|
24 |
|
(e.g., `ECANCELED`, SSL EOF errors).
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
|
27 |
|
|
| 28 |
|
|
28 |
|
|
| 29 |
|
auto [ec, n] = co_await stream.read_some( bufs );
|
29 |
|
auto [ec, n] = co_await stream.read_some( bufs );
|
| 30 |
|
if( ec == cond::canceled )
|
30 |
|
if( ec == cond::canceled )
|
| 31 |
|
|
31 |
|
|
| 32 |
|
else if( ec == cond::eof )
|
32 |
|
else if( ec == cond::eof )
|
| 33 |
|
|
33 |
|
|
| 34 |
|
|
34 |
|
|
| 35 |
|
|
35 |
|
|
| 36 |
|
|
36 |
|
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
|
39 |
|
|
| 40 |
|
|
40 |
|
|
| 41 |
|
|
41 |
|
|
| 42 |
|
/** End-of-stream condition.
|
42 |
|
/** End-of-stream condition.
|
| 43 |
|
|
43 |
|
|
| 44 |
|
An `error_code` compares equal to `eof` when the stream
|
44 |
|
An `error_code` compares equal to `eof` when the stream
|
| 45 |
|
reached its natural end, such as when a peer sends TCP FIN
|
45 |
|
reached its natural end, such as when a peer sends TCP FIN
|
| 46 |
|
|
46 |
|
|
| 47 |
|
|
47 |
|
|
| 48 |
|
|
48 |
|
|
| 49 |
|
|
49 |
|
|
| 50 |
|
/** Operation cancelled condition.
|
50 |
|
/** Operation cancelled condition.
|
| 51 |
|
|
51 |
|
|
| 52 |
|
An `error_code` compares equal to `canceled` when the
|
52 |
|
An `error_code` compares equal to `canceled` when the
|
| 53 |
|
operation's stop token was activated, the I/O object's
|
53 |
|
operation's stop token was activated, the I/O object's
|
| 54 |
|
`cancel()` was called, or a platform cancellation error
|
54 |
|
`cancel()` was called, or a platform cancellation error
|
| 55 |
|
|
55 |
|
|
| 56 |
|
|
56 |
|
|
| 57 |
|
|
57 |
|
|
| 58 |
|
|
58 |
|
|
| 59 |
|
/** Stream truncated condition.
|
59 |
|
/** Stream truncated condition.
|
| 60 |
|
|
60 |
|
|
| 61 |
|
An `error_code` compares equal to `stream_truncated` when
|
61 |
|
An `error_code` compares equal to `stream_truncated` when
|
| 62 |
|
a TLS peer closed the connection without sending a proper
|
62 |
|
a TLS peer closed the connection without sending a proper
|
| 63 |
|
|
63 |
|
|
| 64 |
|
|
64 |
|
|
| 65 |
|
|
65 |
|
|
| 66 |
|
|
66 |
|
|
| 67 |
|
/** Item not found condition.
|
67 |
|
/** Item not found condition.
|
| 68 |
|
|
68 |
|
|
| 69 |
|
An `error_code` compares equal to `not_found` when a
|
69 |
|
An `error_code` compares equal to `not_found` when a
|
| 70 |
|
lookup operation failed to find the requested item.
|
70 |
|
lookup operation failed to find the requested item.
|
| 71 |
|
|
71 |
|
|
| 72 |
|
|
72 |
|
|
| 73 |
|
|
73 |
|
|
| 74 |
|
|
74 |
|
|
| 75 |
|
//-----------------------------------------------
|
75 |
|
//-----------------------------------------------
|
| 76 |
|
|
76 |
|
|
| 77 |
|
|
77 |
|
|
| 78 |
|
|
78 |
|
|
| 79 |
|
|
79 |
|
|
| 80 |
|
|
80 |
|
|
| 81 |
|
|
81 |
|
|
| 82 |
|
struct is_error_condition_enum<
|
82 |
|
struct is_error_condition_enum<
|
| 83 |
|
|
83 |
|
|
| 84 |
|
|
84 |
|
|
| 85 |
|
|
85 |
|
|
| 86 |
|
|
86 |
|
|
| 87 |
|
|
87 |
|
|
| 88 |
|
|
88 |
|
|
| 89 |
|
|
89 |
|
|
| 90 |
|
//-----------------------------------------------
|
90 |
|
//-----------------------------------------------
|
| 91 |
|
|
91 |
|
|
| 92 |
|
|
92 |
|
|
| 93 |
|
|
93 |
|
|
| 94 |
|
struct BOOST_CAPY_SYMBOL_VISIBLE
|
94 |
|
struct BOOST_CAPY_SYMBOL_VISIBLE
|
| 95 |
|
|
95 |
|
|
| 96 |
|
|
96 |
|
|
| 97 |
|
|
97 |
|
|
| 98 |
|
BOOST_CAPY_DECL const char* name(
|
98 |
|
BOOST_CAPY_DECL const char* name(
|
| 99 |
|
) const noexcept override;
|
99 |
|
) const noexcept override;
|
| 100 |
|
BOOST_CAPY_DECL std::string message(
|
100 |
|
BOOST_CAPY_DECL std::string message(
|
| 101 |
|
|
101 |
|
|
| 102 |
|
BOOST_CAPY_DECL bool equivalent(
|
102 |
|
BOOST_CAPY_DECL bool equivalent(
|
| 103 |
|
std::error_code const& ec,
|
103 |
|
std::error_code const& ec,
|
| 104 |
|
int condition) const noexcept override;
|
104 |
|
int condition) const noexcept override;
|
| 105 |
|
constexpr cond_cat_type() noexcept = default;
|
105 |
|
constexpr cond_cat_type() noexcept = default;
|
| 106 |
|
|
106 |
|
|
| 107 |
|
|
107 |
|
|
| 108 |
|
BOOST_CAPY_DECL extern cond_cat_type cond_cat;
|
108 |
|
BOOST_CAPY_DECL extern cond_cat_type cond_cat;
|
| 109 |
|
|
109 |
|
|
| 110 |
|
|
110 |
|
|
| 111 |
|
|
111 |
|
|
| 112 |
|
//-----------------------------------------------
|
112 |
|
//-----------------------------------------------
|
| 113 |
|
|
113 |
|
|
| 114 |
|
|
114 |
|
|
| 115 |
|
|
115 |
|
|
| 116 |
|
|
116 |
|
|
| 117 |
|
|
117 |
|
|
| 118 |
|
|
118 |
|
|
| 119 |
|
return std::error_condition{
|
119 |
|
return std::error_condition{
|
| 120 |
|
static_cast<std::underlying_type<
|
120 |
|
static_cast<std::underlying_type<
|
| 121 |
|
|
121 |
|
|
| 122 |
|
|
122 |
|
|
| 123 |
|
|
123 |
|
|
| 124 |
|
|
124 |
|
|
| 125 |
|
|
125 |
|
|
| 126 |
|
|
126 |
|
|
| 127 |
|
|
127 |
|
|
| 128 |
|
|
128 |
|
|