1 #include "rust_get_flags.hpp"
2 #include <array>
3 #include <cstdint>
4 #include <new>
5 #include <string>
6
7 namespace rust {
8 inline namespace cxxbridge1 {
9 // #include "rust/cxx.h"
10
11 struct unsafe_bitcopy_t;
12
13 namespace {
14 template <typename T>
15 class impl;
16 } // namespace
17
18 #ifndef CXXBRIDGE1_RUST_STRING
19 #define CXXBRIDGE1_RUST_STRING
20 class String final {
21 public:
22 String() noexcept;
23 String(const String &) noexcept;
24 String(String &&) noexcept;
25 ~String() noexcept;
26
27 String(const std::string &);
28 String(const char *);
29 String(const char *, std::size_t);
30 String(const char16_t *);
31 String(const char16_t *, std::size_t);
32
33 static String lossy(const std::string &) noexcept;
34 static String lossy(const char *) noexcept;
35 static String lossy(const char *, std::size_t) noexcept;
36 static String lossy(const char16_t *) noexcept;
37 static String lossy(const char16_t *, std::size_t) noexcept;
38
39 String &operator=(const String &) &noexcept;
40 String &operator=(String &&) &noexcept;
41
42 explicit operator std::string() const;
43
44 const char *data() const noexcept;
45 std::size_t size() const noexcept;
46 std::size_t length() const noexcept;
47 bool empty() const noexcept;
48
49 const char *c_str() noexcept;
50
51 std::size_t capacity() const noexcept;
52 void reserve(size_t new_cap) noexcept;
53
54 using iterator = char *;
55 iterator begin() noexcept;
56 iterator end() noexcept;
57
58 using const_iterator = const char *;
59 const_iterator begin() const noexcept;
60 const_iterator end() const noexcept;
61 const_iterator cbegin() const noexcept;
62 const_iterator cend() const noexcept;
63
64 bool operator==(const String &) const noexcept;
65 bool operator!=(const String &) const noexcept;
66 bool operator<(const String &) const noexcept;
67 bool operator<=(const String &) const noexcept;
68 bool operator>(const String &) const noexcept;
69 bool operator>=(const String &) const noexcept;
70
71 void swap(String &) noexcept;
72
73 String(unsafe_bitcopy_t, const String &) noexcept;
74
75 private:
76 struct lossy_t;
77 String(lossy_t, const char *, std::size_t) noexcept;
78 String(lossy_t, const char16_t *, std::size_t) noexcept;
swap(String & lhs,String & rhs)79 friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
80
81 std::array<std::uintptr_t, 3> repr;
82 };
83 #endif // CXXBRIDGE1_RUST_STRING
84
85 #ifndef CXXBRIDGE1_RUST_STR
86 #define CXXBRIDGE1_RUST_STR
87 class Str final {
88 public:
89 Str() noexcept;
90 Str(const String &) noexcept;
91 Str(const std::string &);
92 Str(const char *);
93 Str(const char *, std::size_t);
94
95 Str &operator=(const Str &) &noexcept = default;
96
97 explicit operator std::string() const;
98
99 const char *data() const noexcept;
100 std::size_t size() const noexcept;
101 std::size_t length() const noexcept;
102 bool empty() const noexcept;
103
104 Str(const Str &) noexcept = default;
105 ~Str() noexcept = default;
106
107 using iterator = const char *;
108 using const_iterator = const char *;
109 const_iterator begin() const noexcept;
110 const_iterator end() const noexcept;
111 const_iterator cbegin() const noexcept;
112 const_iterator cend() const noexcept;
113
114 bool operator==(const Str &) const noexcept;
115 bool operator!=(const Str &) const noexcept;
116 bool operator<(const Str &) const noexcept;
117 bool operator<=(const Str &) const noexcept;
118 bool operator>(const Str &) const noexcept;
119 bool operator>=(const Str &) const noexcept;
120
121 void swap(Str &) noexcept;
122
123 private:
124 class uninit;
125 Str(uninit) noexcept;
126 friend impl<Str>;
127
128 std::array<std::uintptr_t, 2> repr;
129 };
130 #endif // CXXBRIDGE1_RUST_STR
131 } // namespace cxxbridge1
132 } // namespace rust
133
134 extern "C" {
cxxbridge1$GetServerConfigurableFlag(::rust::Str experiment_category_name,::rust::Str experiment_flag_name,::rust::Str default_value,::rust::String * return$)135 void cxxbridge1$GetServerConfigurableFlag(::rust::Str experiment_category_name, ::rust::Str experiment_flag_name, ::rust::Str default_value, ::rust::String *return$) noexcept {
136 ::rust::String (*GetServerConfigurableFlag$)(::rust::Str, ::rust::Str, ::rust::Str) = ::GetServerConfigurableFlag;
137 new (return$) ::rust::String(GetServerConfigurableFlag$(experiment_category_name, experiment_flag_name, default_value));
138 }
139 } // extern "C"
140