idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
21#include <string>
22
23namespace idfxx::http {
24
29enum class method : int {
30 // clang-format off
31 get = 0,
32 post = 1,
33 put = 2,
34 patch = 3,
35 delete_ = 4,
36 head = 5,
37 notify = 6,
38 subscribe = 7,
39 unsubscribe = 8,
40 options = 9,
41 copy = 10,
42 move = 11,
43 lock = 12,
44 unlock = 13,
45 propfind = 14,
46 proppatch = 15,
47 mkcol = 16,
48 report = 17,
49 // clang-format on
50};
51
56enum class auth_type : int {
57 // clang-format off
58 none = 0,
59 basic = 1,
60 digest = 2,
61 // clang-format on
62};
63
68enum class transport : int {
69 // clang-format off
70 unknown = 0,
71 tcp = 1,
72 ssl = 2,
73 // clang-format on
74};
75
76} // namespace idfxx::http
77
78namespace idfxx {
79
88
97
106
107} // namespace idfxx
108
109#include "sdkconfig.h"
110#ifdef CONFIG_IDFXX_STD_FORMAT
112#include <algorithm>
113#include <format>
114namespace std {
115
116template<>
117struct formatter<idfxx::http::method> {
118 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
119
120 template<typename FormatContext>
121 auto format(idfxx::http::method m, FormatContext& ctx) const {
122 auto s = idfxx::to_string(m);
123 return std::copy(s.begin(), s.end(), ctx.out());
124 }
125};
126
127template<>
128struct formatter<idfxx::http::auth_type> {
129 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
130
131 template<typename FormatContext>
132 auto format(idfxx::http::auth_type t, FormatContext& ctx) const {
133 auto s = idfxx::to_string(t);
134 return std::copy(s.begin(), s.end(), ctx.out());
135 }
136};
137
138template<>
139struct formatter<idfxx::http::transport> {
140 constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
141
142 template<typename FormatContext>
143 auto format(idfxx::http::transport t, FormatContext& ctx) const {
144 auto s = idfxx::to_string(t);
145 return std::copy(s.begin(), s.end(), ctx.out());
146 }
147};
148
149} // namespace std
151#endif // CONFIG_IDFXX_STD_FORMAT
152
// end of idfxx_http
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
Definition cpu.hpp:52
method
HTTP request methods.
Definition types.hpp:29
@ delete_
DELETE (trailing underscore — C++ keyword)
@ subscribe
SUBSCRIBE.
@ proppatch
PROPPATCH.
@ unsubscribe
UNSUBSCRIBE.
auth_type
HTTP authentication types.
Definition types.hpp:56
@ none
No authentication.
@ digest
HTTP Digest authentication.
@ basic
HTTP Basic authentication.
transport
HTTP transport types.
Definition types.hpp:68
@ unknown
Unknown transport.
@ tcp
Plain TCP (HTTP)
@ ssl
SSL/TLS (HTTPS)
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120