| 1 | #include "engine/shared/snapshot.h" |
| 2 | #include <array> |
| 3 | #include <cassert> |
| 4 | #include <cstddef> |
| 5 | #include <cstdint> |
| 6 | #include <iterator> |
| 7 | #include <new> |
| 8 | #include <stdexcept> |
| 9 | #include <type_traits> |
| 10 | #include <utility> |
| 11 | |
| 12 | namespace rust { |
| 13 | inline namespace cxxbridge1 { |
| 14 | // #include "rust/cxx.h" |
| 15 | |
| 16 | #ifndef CXXBRIDGE1_PANIC |
| 17 | #define CXXBRIDGE1_PANIC |
| 18 | template <typename Exception> |
| 19 | void panic [[noreturn]] (const char *msg); |
| 20 | #endif // CXXBRIDGE1_PANIC |
| 21 | |
| 22 | namespace { |
| 23 | template <typename T> |
| 24 | class impl; |
| 25 | } // namespace |
| 26 | |
| 27 | template <typename T> |
| 28 | ::std::size_t size_of(); |
| 29 | template <typename T> |
| 30 | ::std::size_t align_of(); |
| 31 | |
| 32 | #ifndef CXXBRIDGE1_RUST_SLICE |
| 33 | #define CXXBRIDGE1_RUST_SLICE |
| 34 | namespace detail { |
| 35 | template <bool> |
| 36 | struct copy_assignable_if {}; |
| 37 | |
| 38 | template <> |
| 39 | struct copy_assignable_if<false> { |
| 40 | copy_assignable_if() noexcept = default; |
| 41 | copy_assignable_if(const copy_assignable_if &) noexcept = default; |
| 42 | copy_assignable_if &operator=(const copy_assignable_if &) &noexcept = delete; |
| 43 | copy_assignable_if &operator=(copy_assignable_if &&) &noexcept = default; |
| 44 | }; |
| 45 | } // namespace detail |
| 46 | |
| 47 | template <typename T> |
| 48 | class Slice final |
| 49 | : private detail::copy_assignable_if<std::is_const<T>::value> { |
| 50 | public: |
| 51 | using value_type = T; |
| 52 | |
| 53 | Slice() noexcept; |
| 54 | Slice(T *, std::size_t count) noexcept; |
| 55 | |
| 56 | Slice &operator=(const Slice<T> &) &noexcept = default; |
| 57 | Slice &operator=(Slice<T> &&) &noexcept = default; |
| 58 | |
| 59 | T *data() const noexcept; |
| 60 | std::size_t size() const noexcept; |
| 61 | std::size_t length() const noexcept; |
| 62 | bool empty() const noexcept; |
| 63 | |
| 64 | T &operator[](std::size_t n) const noexcept; |
| 65 | T &at(std::size_t n) const; |
| 66 | T &front() const noexcept; |
| 67 | T &back() const noexcept; |
| 68 | |
| 69 | Slice(const Slice<T> &) noexcept = default; |
| 70 | ~Slice() noexcept = default; |
| 71 | |
| 72 | class iterator; |
| 73 | iterator begin() const noexcept; |
| 74 | iterator end() const noexcept; |
| 75 | |
| 76 | void swap(Slice &) noexcept; |
| 77 | |
| 78 | private: |
| 79 | class uninit; |
| 80 | Slice(uninit) noexcept; |
| 81 | friend impl<Slice>; |
| 82 | friend void sliceInit(void *, const void *, std::size_t) noexcept; |
| 83 | friend void *slicePtr(const void *) noexcept; |
| 84 | friend std::size_t sliceLen(const void *) noexcept; |
| 85 | |
| 86 | std::array<std::uintptr_t, 2> repr; |
| 87 | }; |
| 88 | |
| 89 | template <typename T> |
| 90 | class Slice<T>::iterator final { |
| 91 | public: |
| 92 | using iterator_category = std::random_access_iterator_tag; |
| 93 | using value_type = T; |
| 94 | using difference_type = std::ptrdiff_t; |
| 95 | using pointer = typename std::add_pointer<T>::type; |
| 96 | using reference = typename std::add_lvalue_reference<T>::type; |
| 97 | |
| 98 | reference operator*() const noexcept; |
| 99 | pointer operator->() const noexcept; |
| 100 | reference operator[](difference_type) const noexcept; |
| 101 | |
| 102 | iterator &operator++() noexcept; |
| 103 | iterator operator++(int) noexcept; |
| 104 | iterator &operator--() noexcept; |
| 105 | iterator operator--(int) noexcept; |
| 106 | |
| 107 | iterator &operator+=(difference_type) noexcept; |
| 108 | iterator &operator-=(difference_type) noexcept; |
| 109 | iterator operator+(difference_type) const noexcept; |
| 110 | iterator operator-(difference_type) const noexcept; |
| 111 | difference_type operator-(const iterator &) const noexcept; |
| 112 | |
| 113 | bool operator==(const iterator &) const noexcept; |
| 114 | bool operator!=(const iterator &) const noexcept; |
| 115 | bool operator<(const iterator &) const noexcept; |
| 116 | bool operator<=(const iterator &) const noexcept; |
| 117 | bool operator>(const iterator &) const noexcept; |
| 118 | bool operator>=(const iterator &) const noexcept; |
| 119 | |
| 120 | private: |
| 121 | friend class Slice; |
| 122 | void *pos; |
| 123 | std::size_t stride; |
| 124 | }; |
| 125 | |
| 126 | template <typename T> |
| 127 | Slice<T>::Slice() noexcept { |
| 128 | sliceInit(this, reinterpret_cast<void *>(align_of<T>()), 0); |
| 129 | } |
| 130 | |
| 131 | template <typename T> |
| 132 | Slice<T>::Slice(T *s, std::size_t count) noexcept { |
| 133 | assert(s != nullptr || count == 0); |
| 134 | sliceInit(this, |
| 135 | s == nullptr && count == 0 |
| 136 | ? reinterpret_cast<void *>(align_of<T>()) |
| 137 | : const_cast<typename std::remove_const<T>::type *>(s), |
| 138 | count); |
| 139 | } |
| 140 | |
| 141 | template <typename T> |
| 142 | T *Slice<T>::data() const noexcept { |
| 143 | return reinterpret_cast<T *>(slicePtr(this)); |
| 144 | } |
| 145 | |
| 146 | template <typename T> |
| 147 | std::size_t Slice<T>::size() const noexcept { |
| 148 | return sliceLen(this); |
| 149 | } |
| 150 | |
| 151 | template <typename T> |
| 152 | std::size_t Slice<T>::length() const noexcept { |
| 153 | return this->size(); |
| 154 | } |
| 155 | |
| 156 | template <typename T> |
| 157 | bool Slice<T>::empty() const noexcept { |
| 158 | return this->size() == 0; |
| 159 | } |
| 160 | |
| 161 | template <typename T> |
| 162 | T &Slice<T>::operator[](std::size_t n) const noexcept { |
| 163 | assert(n < this->size()); |
| 164 | auto ptr = static_cast<char *>(slicePtr(this)) + size_of<T>() * n; |
| 165 | return *reinterpret_cast<T *>(ptr); |
| 166 | } |
| 167 | |
| 168 | template <typename T> |
| 169 | T &Slice<T>::at(std::size_t n) const { |
| 170 | if (n >= this->size()) { |
| 171 | panic<std::out_of_range>("rust::Slice index out of range" ); |
| 172 | } |
| 173 | return (*this)[n]; |
| 174 | } |
| 175 | |
| 176 | template <typename T> |
| 177 | T &Slice<T>::front() const noexcept { |
| 178 | assert(!this->empty()); |
| 179 | return (*this)[0]; |
| 180 | } |
| 181 | |
| 182 | template <typename T> |
| 183 | T &Slice<T>::back() const noexcept { |
| 184 | assert(!this->empty()); |
| 185 | return (*this)[this->size() - 1]; |
| 186 | } |
| 187 | |
| 188 | template <typename T> |
| 189 | typename Slice<T>::iterator::reference |
| 190 | Slice<T>::iterator::operator*() const noexcept { |
| 191 | return *static_cast<T *>(this->pos); |
| 192 | } |
| 193 | |
| 194 | template <typename T> |
| 195 | typename Slice<T>::iterator::pointer |
| 196 | Slice<T>::iterator::operator->() const noexcept { |
| 197 | return static_cast<T *>(this->pos); |
| 198 | } |
| 199 | |
| 200 | template <typename T> |
| 201 | typename Slice<T>::iterator::reference Slice<T>::iterator::operator[]( |
| 202 | typename Slice<T>::iterator::difference_type n) const noexcept { |
| 203 | auto ptr = static_cast<char *>(this->pos) + this->stride * n; |
| 204 | return *reinterpret_cast<T *>(ptr); |
| 205 | } |
| 206 | |
| 207 | template <typename T> |
| 208 | typename Slice<T>::iterator &Slice<T>::iterator::operator++() noexcept { |
| 209 | this->pos = static_cast<char *>(this->pos) + this->stride; |
| 210 | return *this; |
| 211 | } |
| 212 | |
| 213 | template <typename T> |
| 214 | typename Slice<T>::iterator Slice<T>::iterator::operator++(int) noexcept { |
| 215 | auto ret = iterator(*this); |
| 216 | this->pos = static_cast<char *>(this->pos) + this->stride; |
| 217 | return ret; |
| 218 | } |
| 219 | |
| 220 | template <typename T> |
| 221 | typename Slice<T>::iterator &Slice<T>::iterator::operator--() noexcept { |
| 222 | this->pos = static_cast<char *>(this->pos) - this->stride; |
| 223 | return *this; |
| 224 | } |
| 225 | |
| 226 | template <typename T> |
| 227 | typename Slice<T>::iterator Slice<T>::iterator::operator--(int) noexcept { |
| 228 | auto ret = iterator(*this); |
| 229 | this->pos = static_cast<char *>(this->pos) - this->stride; |
| 230 | return ret; |
| 231 | } |
| 232 | |
| 233 | template <typename T> |
| 234 | typename Slice<T>::iterator &Slice<T>::iterator::operator+=( |
| 235 | typename Slice<T>::iterator::difference_type n) noexcept { |
| 236 | this->pos = static_cast<char *>(this->pos) + this->stride * n; |
| 237 | return *this; |
| 238 | } |
| 239 | |
| 240 | template <typename T> |
| 241 | typename Slice<T>::iterator &Slice<T>::iterator::operator-=( |
| 242 | typename Slice<T>::iterator::difference_type n) noexcept { |
| 243 | this->pos = static_cast<char *>(this->pos) - this->stride * n; |
| 244 | return *this; |
| 245 | } |
| 246 | |
| 247 | template <typename T> |
| 248 | typename Slice<T>::iterator Slice<T>::iterator::operator+( |
| 249 | typename Slice<T>::iterator::difference_type n) const noexcept { |
| 250 | auto ret = iterator(*this); |
| 251 | ret.pos = static_cast<char *>(this->pos) + this->stride * n; |
| 252 | return ret; |
| 253 | } |
| 254 | |
| 255 | template <typename T> |
| 256 | typename Slice<T>::iterator Slice<T>::iterator::operator-( |
| 257 | typename Slice<T>::iterator::difference_type n) const noexcept { |
| 258 | auto ret = iterator(*this); |
| 259 | ret.pos = static_cast<char *>(this->pos) - this->stride * n; |
| 260 | return ret; |
| 261 | } |
| 262 | |
| 263 | template <typename T> |
| 264 | typename Slice<T>::iterator::difference_type |
| 265 | Slice<T>::iterator::operator-(const iterator &other) const noexcept { |
| 266 | auto diff = std::distance(static_cast<char *>(other.pos), |
| 267 | static_cast<char *>(this->pos)); |
| 268 | return diff / this->stride; |
| 269 | } |
| 270 | |
| 271 | template <typename T> |
| 272 | bool Slice<T>::iterator::operator==(const iterator &other) const noexcept { |
| 273 | return this->pos == other.pos; |
| 274 | } |
| 275 | |
| 276 | template <typename T> |
| 277 | bool Slice<T>::iterator::operator!=(const iterator &other) const noexcept { |
| 278 | return this->pos != other.pos; |
| 279 | } |
| 280 | |
| 281 | template <typename T> |
| 282 | bool Slice<T>::iterator::operator<(const iterator &other) const noexcept { |
| 283 | return this->pos < other.pos; |
| 284 | } |
| 285 | |
| 286 | template <typename T> |
| 287 | bool Slice<T>::iterator::operator<=(const iterator &other) const noexcept { |
| 288 | return this->pos <= other.pos; |
| 289 | } |
| 290 | |
| 291 | template <typename T> |
| 292 | bool Slice<T>::iterator::operator>(const iterator &other) const noexcept { |
| 293 | return this->pos > other.pos; |
| 294 | } |
| 295 | |
| 296 | template <typename T> |
| 297 | bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept { |
| 298 | return this->pos >= other.pos; |
| 299 | } |
| 300 | |
| 301 | template <typename T> |
| 302 | typename Slice<T>::iterator Slice<T>::begin() const noexcept { |
| 303 | iterator it; |
| 304 | it.pos = slicePtr(this); |
| 305 | it.stride = size_of<T>(); |
| 306 | return it; |
| 307 | } |
| 308 | |
| 309 | template <typename T> |
| 310 | typename Slice<T>::iterator Slice<T>::end() const noexcept { |
| 311 | iterator it = this->begin(); |
| 312 | it.pos = static_cast<char *>(it.pos) + it.stride * this->size(); |
| 313 | return it; |
| 314 | } |
| 315 | |
| 316 | template <typename T> |
| 317 | void Slice<T>::swap(Slice &rhs) noexcept { |
| 318 | std::swap(*this, rhs); |
| 319 | } |
| 320 | #endif // CXXBRIDGE1_RUST_SLICE |
| 321 | |
| 322 | #ifndef CXXBRIDGE1_RUST_BOX |
| 323 | #define CXXBRIDGE1_RUST_BOX |
| 324 | template <typename T> |
| 325 | class Box final { |
| 326 | public: |
| 327 | using element_type = T; |
| 328 | using const_pointer = |
| 329 | typename std::add_pointer<typename std::add_const<T>::type>::type; |
| 330 | using pointer = typename std::add_pointer<T>::type; |
| 331 | |
| 332 | Box() = delete; |
| 333 | Box(Box &&) noexcept; |
| 334 | ~Box() noexcept; |
| 335 | |
| 336 | explicit Box(const T &); |
| 337 | explicit Box(T &&); |
| 338 | |
| 339 | Box &operator=(Box &&) &noexcept; |
| 340 | |
| 341 | const T *operator->() const noexcept; |
| 342 | const T &operator*() const noexcept; |
| 343 | T *operator->() noexcept; |
| 344 | T &operator*() noexcept; |
| 345 | |
| 346 | template <typename... Fields> |
| 347 | static Box in_place(Fields &&...); |
| 348 | |
| 349 | void swap(Box &) noexcept; |
| 350 | |
| 351 | static Box from_raw(T *) noexcept; |
| 352 | |
| 353 | T *into_raw() noexcept; |
| 354 | |
| 355 | /* Deprecated */ using value_type = element_type; |
| 356 | |
| 357 | private: |
| 358 | class uninit; |
| 359 | class allocation; |
| 360 | Box(uninit) noexcept; |
| 361 | void drop() noexcept; |
| 362 | |
| 363 | friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); } |
| 364 | |
| 365 | T *ptr; |
| 366 | }; |
| 367 | |
| 368 | template <typename T> |
| 369 | class Box<T>::uninit {}; |
| 370 | |
| 371 | template <typename T> |
| 372 | class Box<T>::allocation { |
| 373 | static T *alloc() noexcept; |
| 374 | static void dealloc(T *) noexcept; |
| 375 | |
| 376 | public: |
| 377 | allocation() noexcept : ptr(alloc()) {} |
| 378 | ~allocation() noexcept { |
| 379 | if (this->ptr) { |
| 380 | dealloc(this->ptr); |
| 381 | } |
| 382 | } |
| 383 | T *ptr; |
| 384 | }; |
| 385 | |
| 386 | template <typename T> |
| 387 | Box<T>::Box(Box &&other) noexcept : ptr(other.ptr) { |
| 388 | other.ptr = nullptr; |
| 389 | } |
| 390 | |
| 391 | template <typename T> |
| 392 | Box<T>::Box(const T &val) { |
| 393 | allocation alloc; |
| 394 | ::new (alloc.ptr) T(val); |
| 395 | this->ptr = alloc.ptr; |
| 396 | alloc.ptr = nullptr; |
| 397 | } |
| 398 | |
| 399 | template <typename T> |
| 400 | Box<T>::Box(T &&val) { |
| 401 | allocation alloc; |
| 402 | ::new (alloc.ptr) T(std::move(val)); |
| 403 | this->ptr = alloc.ptr; |
| 404 | alloc.ptr = nullptr; |
| 405 | } |
| 406 | |
| 407 | template <typename T> |
| 408 | Box<T>::~Box() noexcept { |
| 409 | if (this->ptr) { |
| 410 | this->drop(); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | template <typename T> |
| 415 | Box<T> &Box<T>::operator=(Box &&other) &noexcept { |
| 416 | if (this->ptr) { |
| 417 | this->drop(); |
| 418 | } |
| 419 | this->ptr = other.ptr; |
| 420 | other.ptr = nullptr; |
| 421 | return *this; |
| 422 | } |
| 423 | |
| 424 | template <typename T> |
| 425 | const T *Box<T>::operator->() const noexcept { |
| 426 | return this->ptr; |
| 427 | } |
| 428 | |
| 429 | template <typename T> |
| 430 | const T &Box<T>::operator*() const noexcept { |
| 431 | return *this->ptr; |
| 432 | } |
| 433 | |
| 434 | template <typename T> |
| 435 | T *Box<T>::operator->() noexcept { |
| 436 | return this->ptr; |
| 437 | } |
| 438 | |
| 439 | template <typename T> |
| 440 | T &Box<T>::operator*() noexcept { |
| 441 | return *this->ptr; |
| 442 | } |
| 443 | |
| 444 | template <typename T> |
| 445 | template <typename... Fields> |
| 446 | Box<T> Box<T>::in_place(Fields &&...fields) { |
| 447 | allocation alloc; |
| 448 | auto ptr = alloc.ptr; |
| 449 | ::new (ptr) T{std::forward<Fields>(fields)...}; |
| 450 | alloc.ptr = nullptr; |
| 451 | return from_raw(ptr); |
| 452 | } |
| 453 | |
| 454 | template <typename T> |
| 455 | void Box<T>::swap(Box &rhs) noexcept { |
| 456 | using std::swap; |
| 457 | swap(this->ptr, rhs.ptr); |
| 458 | } |
| 459 | |
| 460 | template <typename T> |
| 461 | Box<T> Box<T>::from_raw(T *raw) noexcept { |
| 462 | Box box = uninit{}; |
| 463 | box.ptr = raw; |
| 464 | return box; |
| 465 | } |
| 466 | |
| 467 | template <typename T> |
| 468 | T *Box<T>::into_raw() noexcept { |
| 469 | T *raw = this->ptr; |
| 470 | this->ptr = nullptr; |
| 471 | return raw; |
| 472 | } |
| 473 | |
| 474 | template <typename T> |
| 475 | Box<T>::Box(uninit) noexcept {} |
| 476 | #endif // CXXBRIDGE1_RUST_BOX |
| 477 | |
| 478 | #ifndef CXXBRIDGE1_RUST_OPAQUE |
| 479 | #define CXXBRIDGE1_RUST_OPAQUE |
| 480 | class Opaque { |
| 481 | public: |
| 482 | Opaque() = delete; |
| 483 | Opaque(const Opaque &) = delete; |
| 484 | ~Opaque() = delete; |
| 485 | }; |
| 486 | #endif // CXXBRIDGE1_RUST_OPAQUE |
| 487 | |
| 488 | #ifndef CXXBRIDGE1_IS_COMPLETE |
| 489 | #define CXXBRIDGE1_IS_COMPLETE |
| 490 | namespace detail { |
| 491 | namespace { |
| 492 | template <typename T, typename = std::size_t> |
| 493 | struct is_complete : std::false_type {}; |
| 494 | template <typename T> |
| 495 | struct is_complete<T, decltype(sizeof(T))> : std::true_type {}; |
| 496 | } // namespace |
| 497 | } // namespace detail |
| 498 | #endif // CXXBRIDGE1_IS_COMPLETE |
| 499 | |
| 500 | #ifndef CXXBRIDGE1_LAYOUT |
| 501 | #define CXXBRIDGE1_LAYOUT |
| 502 | class layout { |
| 503 | template <typename T> |
| 504 | friend std::size_t size_of(); |
| 505 | template <typename T> |
| 506 | friend std::size_t align_of(); |
| 507 | template <typename T> |
| 508 | static typename std::enable_if<std::is_base_of<Opaque, T>::value, |
| 509 | std::size_t>::type |
| 510 | do_size_of() { |
| 511 | return T::layout::size(); |
| 512 | } |
| 513 | template <typename T> |
| 514 | static typename std::enable_if<!std::is_base_of<Opaque, T>::value, |
| 515 | std::size_t>::type |
| 516 | do_size_of() { |
| 517 | return sizeof(T); |
| 518 | } |
| 519 | template <typename T> |
| 520 | static |
| 521 | typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type |
| 522 | size_of() { |
| 523 | return do_size_of<T>(); |
| 524 | } |
| 525 | template <typename T> |
| 526 | static typename std::enable_if<std::is_base_of<Opaque, T>::value, |
| 527 | std::size_t>::type |
| 528 | do_align_of() { |
| 529 | return T::layout::align(); |
| 530 | } |
| 531 | template <typename T> |
| 532 | static typename std::enable_if<!std::is_base_of<Opaque, T>::value, |
| 533 | std::size_t>::type |
| 534 | do_align_of() { |
| 535 | return alignof(T); |
| 536 | } |
| 537 | template <typename T> |
| 538 | static |
| 539 | typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type |
| 540 | align_of() { |
| 541 | return do_align_of<T>(); |
| 542 | } |
| 543 | }; |
| 544 | |
| 545 | template <typename T> |
| 546 | std::size_t size_of() { |
| 547 | return layout::size_of<T>(); |
| 548 | } |
| 549 | |
| 550 | template <typename T> |
| 551 | std::size_t align_of() { |
| 552 | return layout::align_of<T>(); |
| 553 | } |
| 554 | #endif // CXXBRIDGE1_LAYOUT |
| 555 | |
| 556 | template <typename T> |
| 557 | class Slice<T>::uninit {}; |
| 558 | template <typename T> |
| 559 | inline Slice<T>::Slice(uninit) noexcept {} |
| 560 | |
| 561 | namespace { |
| 562 | namespace repr { |
| 563 | using Fat = ::std::array<::std::uintptr_t, 2>; |
| 564 | } // namespace repr |
| 565 | |
| 566 | template <typename T> |
| 567 | class impl<Slice<T>> final { |
| 568 | public: |
| 569 | static Slice<T> slice(repr::Fat repr) noexcept { |
| 570 | Slice<T> slice = typename Slice<T>::uninit{}; |
| 571 | slice.repr = repr; |
| 572 | return slice; |
| 573 | } |
| 574 | }; |
| 575 | } // namespace |
| 576 | } // namespace cxxbridge1 |
| 577 | } // namespace rust |
| 578 | |
| 579 | struct CSnapshotDelta; |
| 580 | |
| 581 | #ifndef CXXBRIDGE1_STRUCT_CSnapshotDelta |
| 582 | #define CXXBRIDGE1_STRUCT_CSnapshotDelta |
| 583 | struct CSnapshotDelta final : public ::rust::Opaque { |
| 584 | ::rust::Box<::CSnapshotDelta> Clone() noexcept; |
| 585 | ::std::uint64_t GetDataRate(::std::int32_t type_) const noexcept; |
| 586 | ::std::uint64_t GetDataUpdates(::std::int32_t type_) const noexcept; |
| 587 | void SetStaticsize(::std::int32_t type_, ::std::size_t size) noexcept; |
| 588 | ::rust::Slice<const ::std::int32_t> EmptyDelta() const noexcept; |
| 589 | ::std::int32_t CreateDelta(const ::CSnapshot &from, const ::CSnapshot &to, ::rust::Slice<::std::int32_t> delta) noexcept; |
| 590 | ::std::int32_t UnpackDelta(const ::CSnapshot &from, ::CSnapshotBuffer &to, ::rust::Slice<const ::std::int32_t> delta) noexcept; |
| 591 | ~CSnapshotDelta() = delete; |
| 592 | |
| 593 | private: |
| 594 | friend ::rust::layout; |
| 595 | struct layout { |
| 596 | static ::std::size_t size() noexcept; |
| 597 | static ::std::size_t align() noexcept; |
| 598 | }; |
| 599 | }; |
| 600 | #endif // CXXBRIDGE1_STRUCT_CSnapshotDelta |
| 601 | |
| 602 | extern "C" { |
| 603 | ::std::size_t cxxbridge1$CSnapshotDelta$operator$sizeof() noexcept; |
| 604 | ::std::size_t cxxbridge1$CSnapshotDelta$operator$alignof() noexcept; |
| 605 | |
| 606 | void cxxbridge1$CSnapshotDelta_DiffItem(::rust::Slice<const ::std::int32_t> past, ::rust::Slice<const ::std::int32_t> current, ::rust::Slice<::std::int32_t> out) noexcept; |
| 607 | |
| 608 | ::CSnapshotDelta *cxxbridge1$CSnapshotDelta_New() noexcept; |
| 609 | |
| 610 | ::CSnapshotDelta *cxxbridge1$CSnapshotDelta$Clone(::CSnapshotDelta &self) noexcept; |
| 611 | |
| 612 | ::std::uint64_t cxxbridge1$CSnapshotDelta$GetDataRate(const ::CSnapshotDelta &self, ::std::int32_t type_) noexcept; |
| 613 | |
| 614 | ::std::uint64_t cxxbridge1$CSnapshotDelta$GetDataUpdates(const ::CSnapshotDelta &self, ::std::int32_t type_) noexcept; |
| 615 | |
| 616 | void cxxbridge1$CSnapshotDelta$SetStaticsize(::CSnapshotDelta &self, ::std::int32_t type_, ::std::size_t size) noexcept; |
| 617 | |
| 618 | ::rust::repr::Fat cxxbridge1$CSnapshotDelta$EmptyDelta(const ::CSnapshotDelta &self) noexcept; |
| 619 | |
| 620 | ::std::int32_t cxxbridge1$CSnapshotDelta$CreateDelta(::CSnapshotDelta &self, const ::CSnapshot &from, const ::CSnapshot &to, ::rust::Slice<::std::int32_t> delta) noexcept; |
| 621 | |
| 622 | ::std::int32_t cxxbridge1$CSnapshotDelta$UnpackDelta(::CSnapshotDelta &self, const ::CSnapshot &from, ::CSnapshotBuffer &to, ::rust::Slice<const ::std::int32_t> delta) noexcept; |
| 623 | } // extern "C" |
| 624 | |
| 625 | ::std::size_t CSnapshotDelta::layout::size() noexcept { |
| 626 | return cxxbridge1$CSnapshotDelta$operator$sizeof(); |
| 627 | } |
| 628 | |
| 629 | ::std::size_t CSnapshotDelta::layout::align() noexcept { |
| 630 | return cxxbridge1$CSnapshotDelta$operator$alignof(); |
| 631 | } |
| 632 | |
| 633 | void CSnapshotDelta_DiffItem(::rust::Slice<const ::std::int32_t> past, ::rust::Slice<const ::std::int32_t> current, ::rust::Slice<::std::int32_t> out) noexcept { |
| 634 | cxxbridge1$CSnapshotDelta_DiffItem(past, current, out); |
| 635 | } |
| 636 | |
| 637 | // Create a new snapshot delta. |
| 638 | // |
| 639 | // # Example |
| 640 | // |
| 641 | // ``` |
| 642 | // # extern crate ddnet_test; |
| 643 | // use ddnet_engine_shared::CSnapshotDelta_New; |
| 644 | // |
| 645 | // let delta = CSnapshotDelta_New(); |
| 646 | // ``` |
| 647 | ::rust::Box<::CSnapshotDelta> CSnapshotDelta_New() noexcept { |
| 648 | return ::rust::Box<::CSnapshotDelta>::from_raw(raw: cxxbridge1$CSnapshotDelta_New()); |
| 649 | } |
| 650 | |
| 651 | ::rust::Box<::CSnapshotDelta> CSnapshotDelta::Clone() noexcept { |
| 652 | return ::rust::Box<::CSnapshotDelta>::from_raw(raw: cxxbridge1$CSnapshotDelta$Clone(self&: *this)); |
| 653 | } |
| 654 | |
| 655 | ::std::uint64_t CSnapshotDelta::GetDataRate(::std::int32_t type_) const noexcept { |
| 656 | return cxxbridge1$CSnapshotDelta$GetDataRate(self: *this, type_); |
| 657 | } |
| 658 | |
| 659 | ::std::uint64_t CSnapshotDelta::GetDataUpdates(::std::int32_t type_) const noexcept { |
| 660 | return cxxbridge1$CSnapshotDelta$GetDataUpdates(self: *this, type_); |
| 661 | } |
| 662 | |
| 663 | void CSnapshotDelta::SetStaticsize(::std::int32_t type_, ::std::size_t size) noexcept { |
| 664 | cxxbridge1$CSnapshotDelta$SetStaticsize(self&: *this, type_, size); |
| 665 | } |
| 666 | |
| 667 | ::rust::Slice<const ::std::int32_t> CSnapshotDelta::EmptyDelta() const noexcept { |
| 668 | return ::rust::impl<::rust::Slice<const ::std::int32_t>>::slice(repr: cxxbridge1$CSnapshotDelta$EmptyDelta(self: *this)); |
| 669 | } |
| 670 | |
| 671 | ::std::int32_t CSnapshotDelta::CreateDelta(const ::CSnapshot &from, const ::CSnapshot &to, ::rust::Slice<::std::int32_t> delta) noexcept { |
| 672 | return cxxbridge1$CSnapshotDelta$CreateDelta(self&: *this, from, to, delta); |
| 673 | } |
| 674 | |
| 675 | ::std::int32_t CSnapshotDelta::UnpackDelta(const ::CSnapshot &from, ::CSnapshotBuffer &to, ::rust::Slice<const ::std::int32_t> delta) noexcept { |
| 676 | return cxxbridge1$CSnapshotDelta$UnpackDelta(self&: *this, from, to, delta); |
| 677 | } |
| 678 | |
| 679 | extern "C" { |
| 680 | ::CSnapshotDelta *cxxbridge1$box$CSnapshotDelta$alloc() noexcept; |
| 681 | void cxxbridge1$box$CSnapshotDelta$dealloc(::CSnapshotDelta *) noexcept; |
| 682 | void cxxbridge1$box$CSnapshotDelta$drop(::rust::Box<::CSnapshotDelta> *ptr) noexcept; |
| 683 | } // extern "C" |
| 684 | |
| 685 | namespace rust { |
| 686 | inline namespace cxxbridge1 { |
| 687 | template <> |
| 688 | ::CSnapshotDelta *Box<::CSnapshotDelta>::allocation::alloc() noexcept { |
| 689 | return cxxbridge1$box$CSnapshotDelta$alloc(); |
| 690 | } |
| 691 | template <> |
| 692 | void Box<::CSnapshotDelta>::allocation::dealloc(::CSnapshotDelta *ptr) noexcept { |
| 693 | cxxbridge1$box$CSnapshotDelta$dealloc(ptr); |
| 694 | } |
| 695 | template <> |
| 696 | void Box<::CSnapshotDelta>::drop() noexcept { |
| 697 | cxxbridge1$box$CSnapshotDelta$drop(ptr: this); |
| 698 | } |
| 699 | } // namespace cxxbridge1 |
| 700 | } // namespace rust |
| 701 | |