RESTinio
common_types.hpp
Go to the documentation of this file.
1/*
2 restinio
3*/
4
9#pragma once
10
11#include <cstdint>
12
14
15namespace restinio
16{
17
19
25enum class request_handling_status_t : std::uint8_t
26{
28 accepted,
29
32
39};
40
47{
49}
50
54{
56}
57
64{
66}
68
70using request_id_t = unsigned int;
71
73enum class response_parts_attr_t : std::uint8_t
74{
79};
80
81inline std::ostream &
82operator << ( std::ostream & o, response_parts_attr_t attr )
83{
85 o << "not_final_parts";
86 else
87 o << "final_parts";
88
89 return o;
90}
91
93enum class response_connection_attr_t : std::uint8_t
94{
99};
100
101inline std::ostream &
102operator << ( std::ostream & o, response_connection_attr_t attr )
103{
105 o << "connection_keepalive";
106 else
107 o << "connection_close";
108
109 return o;
110}
111
113response_connection_attr( bool should_keep_alive )
114{
115 if( should_keep_alive )
117
119}
120
123{
125 response_parts_attr_t response_parts,
126 response_connection_attr_t response_connection ) noexcept
127 : m_response_parts{ response_parts }
128 , m_response_connection{ response_connection }
129 {}
130
133};
134
135inline std::ostream &
136operator << ( std::ostream & o, const response_output_flags_t & flags )
137{
138 return o << "{ " << flags.m_response_parts << ", "
139 << flags.m_response_connection << " }";
140}
141
142//
143// nullable_pointer_t
144//
153template< typename T >
155
156//
157// not_null_pointer_t
158//
168template< typename T >
170
174using connection_id_t = std::uint64_t;
175
177using endpoint_t = asio_ns::ip::tcp::endpoint;
178
179} /* namespace restinio */
180
#define RESTINIO_NODISCARD
RESTINIO_NODISCARD constexpr request_handling_status_t request_not_handled() noexcept
T * nullable_pointer_t
Type for pointer that can be nullptr.
RESTINIO_NODISCARD constexpr request_handling_status_t request_rejected() noexcept
T * not_null_pointer_t
Type for pointer that is not null by design.
std::ostream & operator<<(std::ostream &o, response_parts_attr_t attr)
unsigned int request_id_t
Request id in scope of single connection.
response_connection_attr_t response_connection_attr(bool should_keep_alive)
request_handling_status_t
Request handling status.
@ accepted
Request accepted for handling.
@ not_handled
The request wasn't handled. If there is another handler to be tried it should be tried....
@ rejected
Request wasn't accepted for handling.
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
response_connection_attr_t
Attribute for parts.
@ connection_close
This response says to close connection.
@ connection_keepalive
This response says to keep connection.
RESTINIO_NODISCARD constexpr request_handling_status_t request_accepted() noexcept
response_parts_attr_t
Attribute for parts.
@ final_parts
Final parts (response ands with these parts).
@ not_final_parts
Intermediate parts (more parts of response to follow).
std::uint64_t connection_id_t
Type for ID of connection.
Response output flags for buffers commited to response-coordinator.
response_connection_attr_t m_response_connection
response_parts_attr_t m_response_parts
response_output_flags_t(response_parts_attr_t response_parts, response_connection_attr_t response_connection) noexcept