1#![allow(clippy::too_many_arguments)]
7
8#[allow(unused_imports)]
11use crate::support::{BorrowedSlice, Bytes};
12
13#[repr(i32)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
18pub enum BlizzardGame {
19 Unknown = 0,
20 WorldOfWarcraft = 1,
21 WorldOfWarcraftClassic = 2,
22 WorldOfWarcraftClassicEra = 3,
23 WarcraftIIBattleNetEdition = 4,
24 WarcraftIIRemastered = 5,
25 WarcraftIII = 6,
26 WarcraftIIIReforged = 7,
27 StarCraft = 8,
28 StarCraftRemastered = 9,
29 StarCraftII = 10,
30 Diablo = 11,
31 DiabloII = 12,
32 DiabloIIResurrected = 13,
33 DiabloIII = 14,
34 DiabloIV = 15,
35 DiabloImmortal = 16,
36 HeroesOfTheStorm = 17,
37 Overwatch2 = 18,
38 Hearthstone = 19,
39 BlizzardArcadeCollection = 20,
40 BattleNet = 21,
41}
42
43impl TryFrom<i32> for BlizzardGame {
44 type Error = crate::Error;
45 fn try_from(v: i32) -> Result<Self, crate::Error> {
46 match v {
47 0 => Ok(BlizzardGame::Unknown),
48 1 => Ok(BlizzardGame::WorldOfWarcraft),
49 2 => Ok(BlizzardGame::WorldOfWarcraftClassic),
50 3 => Ok(BlizzardGame::WorldOfWarcraftClassicEra),
51 4 => Ok(BlizzardGame::WarcraftIIBattleNetEdition),
52 5 => Ok(BlizzardGame::WarcraftIIRemastered),
53 6 => Ok(BlizzardGame::WarcraftIII),
54 7 => Ok(BlizzardGame::WarcraftIIIReforged),
55 8 => Ok(BlizzardGame::StarCraft),
56 9 => Ok(BlizzardGame::StarCraftRemastered),
57 10 => Ok(BlizzardGame::StarCraftII),
58 11 => Ok(BlizzardGame::Diablo),
59 12 => Ok(BlizzardGame::DiabloII),
60 13 => Ok(BlizzardGame::DiabloIIResurrected),
61 14 => Ok(BlizzardGame::DiabloIII),
62 15 => Ok(BlizzardGame::DiabloIV),
63 16 => Ok(BlizzardGame::DiabloImmortal),
64 17 => Ok(BlizzardGame::HeroesOfTheStorm),
65 18 => Ok(BlizzardGame::Overwatch2),
66 19 => Ok(BlizzardGame::Hearthstone),
67 20 => Ok(BlizzardGame::BlizzardArcadeCollection),
68 21 => Ok(BlizzardGame::BattleNet),
69 other => Err(crate::Error::UnknownEnum {
70 name: "BlizzardGame",
71 value: other,
72 }),
73 }
74 }
75}
76
77pub struct WorkerPool {
79 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_WorkerPool>,
80}
81
82impl Drop for WorkerPool {
83 fn drop(&mut self) {
84 unsafe { ffi::whiteout_host_WorkerPool_delete(self.raw.as_ptr()) }
86 }
87}
88
89impl WorkerPool {
90 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_WorkerPool) -> Option<Self> {
94 core::ptr::NonNull::new(raw).map(|raw| WorkerPool { raw })
95 }
96}
97
98unsafe impl Send for WorkerPool {}
103
104impl core::fmt::Debug for WorkerPool {
105 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
106 f.debug_struct("WorkerPool").finish_non_exhaustive()
107 }
108}
109
110impl WorkerPool {
111 pub fn wait_idle(&mut self) {
113 unsafe {
115 ffi::whiteout_host_WorkerPool_waitIdle(self.raw.as_ptr());
116 }
117 }
118
119 pub fn thread_count(&self) -> usize {
121 unsafe { ffi::whiteout_host_WorkerPool_threadCount(self.raw.as_ptr()) }
123 }
124}
125
126pub struct CascFileSystem {
128 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_CascFileSystem>,
129}
130
131impl Drop for CascFileSystem {
132 fn drop(&mut self) {
133 unsafe { ffi::whiteout_host_CascFileSystem_delete(self.raw.as_ptr()) }
135 }
136}
137
138impl CascFileSystem {
139 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_CascFileSystem) -> Option<Self> {
143 core::ptr::NonNull::new(raw).map(|raw| CascFileSystem { raw })
144 }
145}
146
147unsafe impl Send for CascFileSystem {}
152
153impl core::fmt::Debug for CascFileSystem {
154 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
155 f.debug_struct("CascFileSystem").finish_non_exhaustive()
156 }
157}
158
159impl CascFileSystem {
160 pub fn read_file(&self, file_id: u32) -> Bytes {
162 unsafe {
164 Bytes::from_raw(ffi::whiteout_host_CascFileSystem_readFile(
165 self.raw.as_ptr(),
166 file_id,
167 ))
168 .unwrap_or_else(Bytes::empty)
169 }
170 }
171
172 pub fn reserve_file_id(&mut self, path: &str) -> Option<u32> {
174 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
175 let mut __v: u32 = 0;
176 let __has = unsafe {
179 ffi::whiteout_host_CascFileSystem_reserveFileId(
180 self.raw.as_ptr(),
181 path_cstr.as_ptr(),
182 &mut __v,
183 )
184 };
185 (__has != 0).then_some(__v)
186 }
187
188 pub fn write_file(&mut self, file_id: u32, data: &[u8]) -> bool {
190 unsafe {
192 ffi::whiteout_host_CascFileSystem_writeFile(
193 self.raw.as_ptr(),
194 file_id,
195 data.as_ptr(),
196 data.len(),
197 ) != 0
198 }
199 }
200
201 pub fn file_exists(&self, file_id: u32) -> bool {
203 unsafe { ffi::whiteout_host_CascFileSystem_fileExists(self.raw.as_ptr(), file_id) != 0 }
205 }
206}
207
208pub struct VirtualPathFileSystem {
210 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_VirtualPathFileSystem>,
211}
212
213impl Drop for VirtualPathFileSystem {
214 fn drop(&mut self) {
215 unsafe { ffi::whiteout_host_VirtualPathFileSystem_delete(self.raw.as_ptr()) }
217 }
218}
219
220impl VirtualPathFileSystem {
221 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_VirtualPathFileSystem) -> Option<Self> {
225 core::ptr::NonNull::new(raw).map(|raw| VirtualPathFileSystem { raw })
226 }
227}
228
229unsafe impl Send for VirtualPathFileSystem {}
234
235impl core::fmt::Debug for VirtualPathFileSystem {
236 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
237 f.debug_struct("VirtualPathFileSystem")
238 .finish_non_exhaustive()
239 }
240}
241
242impl VirtualPathFileSystem {
243 pub fn read_file(&self, path: &str) -> Bytes {
245 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
246 unsafe {
248 Bytes::from_raw(ffi::whiteout_host_VirtualPathFileSystem_readFile(
249 self.raw.as_ptr(),
250 path_cstr.as_ptr(),
251 ))
252 .unwrap_or_else(Bytes::empty)
253 }
254 }
255
256 pub fn write_file(&mut self, path: &str, data: &[u8]) -> bool {
258 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
259 unsafe {
261 ffi::whiteout_host_VirtualPathFileSystem_writeFile(
262 self.raw.as_ptr(),
263 path_cstr.as_ptr(),
264 data.as_ptr(),
265 data.len(),
266 ) != 0
267 }
268 }
269
270 pub fn file_exists(&self, path: &str) -> bool {
272 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
273 unsafe {
275 ffi::whiteout_host_VirtualPathFileSystem_fileExists(
276 self.raw.as_ptr(),
277 path_cstr.as_ptr(),
278 ) != 0
279 }
280 }
281}
282
283pub struct HttpResponse {
285 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_HttpResponse>,
286}
287
288impl Drop for HttpResponse {
289 fn drop(&mut self) {
290 unsafe { ffi::whiteout_host_HttpResponse_delete(self.raw.as_ptr()) }
292 }
293}
294
295impl HttpResponse {
296 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_HttpResponse) -> Option<Self> {
300 core::ptr::NonNull::new(raw).map(|raw| HttpResponse { raw })
301 }
302}
303
304unsafe impl Send for HttpResponse {}
309
310impl core::fmt::Debug for HttpResponse {
311 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
312 f.debug_struct("HttpResponse").finish_non_exhaustive()
313 }
314}
315
316impl HttpResponse {
317 pub fn new() -> Self {
320 unsafe {
323 let raw = ffi::whiteout_host_HttpResponse_new();
324 Self::from_raw(raw).expect("native HttpResponse allocation failed")
325 }
326 }
327
328 pub fn status_code(&self) -> i32 {
330 unsafe { ffi::whiteout_host_HttpResponse_get_statusCode(self.raw.as_ptr()) }
332 }
333
334 pub fn set_status_code(&mut self, value: i32) {
335 unsafe { ffi::whiteout_host_HttpResponse_set_statusCode(self.raw.as_ptr(), value) }
337 }
338
339 pub fn body(&self) -> &[u8] {
342 unsafe {
345 let n = ffi::whiteout_host_HttpResponse_get_body_count(self.raw.as_ptr());
346 let p = ffi::whiteout_host_HttpResponse_get_body_data(self.raw.as_ptr());
347 if p.is_null() || n == 0 {
348 &[]
349 } else {
350 core::slice::from_raw_parts(p, n)
351 }
352 }
353 }
354
355 pub fn body_mut(&mut self) -> &mut [u8] {
357 unsafe {
359 let n = ffi::whiteout_host_HttpResponse_get_body_count(self.raw.as_ptr());
360 let p = ffi::whiteout_host_HttpResponse_get_body_data(self.raw.as_ptr()) as *mut u8;
361 if p.is_null() || n == 0 {
362 &mut []
363 } else {
364 core::slice::from_raw_parts_mut(p, n)
365 }
366 }
367 }
368
369 pub fn set_body(&mut self, values: &[u8]) {
370 unsafe {
372 ffi::whiteout_host_HttpResponse_assign_body(
373 self.raw.as_ptr(),
374 values.as_ptr() as *const _,
375 values.len(),
376 )
377 }
378 }
379
380 pub fn resize_body(&mut self, count: usize) {
381 unsafe { ffi::whiteout_host_HttpResponse_resize_body(self.raw.as_ptr(), count) }
384 }
385
386 pub fn error(&self) -> String {
388 unsafe {
390 crate::support::take_string(ffi::whiteout_host_HttpResponse_get_error(
391 self.raw.as_ptr(),
392 ))
393 }
394 }
395
396 pub fn set_error(&mut self, value: &str) {
397 let value = std::ffi::CString::new(value).unwrap_or_default();
398 unsafe { ffi::whiteout_host_HttpResponse_set_error(self.raw.as_ptr(), value.as_ptr()) }
400 }
401}
402
403impl Default for HttpResponse {
404 fn default() -> Self {
405 Self::new()
406 }
407}
408
409pub struct HttpHandler {
417 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_HttpHandler>,
418}
419
420impl Drop for HttpHandler {
421 fn drop(&mut self) {
422 unsafe { ffi::whiteout_host_HttpHandler_delete(self.raw.as_ptr()) }
424 }
425}
426
427impl HttpHandler {
428 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_HttpHandler) -> Option<Self> {
432 core::ptr::NonNull::new(raw).map(|raw| HttpHandler { raw })
433 }
434}
435
436unsafe impl Send for HttpHandler {}
441
442impl core::fmt::Debug for HttpHandler {
443 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
444 f.debug_struct("HttpHandler").finish_non_exhaustive()
445 }
446}
447
448impl HttpHandler {
449 pub fn capabilities(&self) -> u32 {
451 unsafe { ffi::whiteout_host_HttpHandler_capabilities(self.raw.as_ptr()) }
453 }
454}
455
456pub struct OsFileSystem {
464 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_OsFileSystem>,
465}
466
467impl Drop for OsFileSystem {
468 fn drop(&mut self) {
469 unsafe { ffi::whiteout_host_OsFileSystem_delete(self.raw.as_ptr()) }
471 }
472}
473
474impl OsFileSystem {
475 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_OsFileSystem) -> Option<Self> {
479 core::ptr::NonNull::new(raw).map(|raw| OsFileSystem { raw })
480 }
481}
482
483unsafe impl Send for OsFileSystem {}
488
489impl core::fmt::Debug for OsFileSystem {
490 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
491 f.debug_struct("OsFileSystem").finish_non_exhaustive()
492 }
493}
494
495impl OsFileSystem {
496 pub fn read_file(&self, path: &str) -> Bytes {
498 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
499 unsafe {
501 Bytes::from_raw(ffi::whiteout_host_OsFileSystem_readFile(
502 self.raw.as_ptr(),
503 path_cstr.as_ptr(),
504 ))
505 .unwrap_or_else(Bytes::empty)
506 }
507 }
508
509 pub fn write_file(&mut self, path: &str, data: &[u8]) -> bool {
510 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
511 unsafe {
513 ffi::whiteout_host_OsFileSystem_writeFile(
514 self.raw.as_ptr(),
515 path_cstr.as_ptr(),
516 data.as_ptr(),
517 data.len(),
518 ) != 0
519 }
520 }
521
522 pub fn file_exists(&self, path: &str) -> bool {
523 let path_cstr = std::ffi::CString::new(path).unwrap_or_default();
524 unsafe {
526 ffi::whiteout_host_OsFileSystem_fileExists(self.raw.as_ptr(), path_cstr.as_ptr()) != 0
527 }
528 }
529}
530
531pub struct SimpleThreadPool {
535 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_SimpleThreadPool>,
536}
537
538impl Drop for SimpleThreadPool {
539 fn drop(&mut self) {
540 unsafe { ffi::whiteout_host_SimpleThreadPool_delete(self.raw.as_ptr()) }
542 }
543}
544
545impl SimpleThreadPool {
546 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_SimpleThreadPool) -> Option<Self> {
550 core::ptr::NonNull::new(raw).map(|raw| SimpleThreadPool { raw })
551 }
552}
553
554unsafe impl Send for SimpleThreadPool {}
559
560impl core::fmt::Debug for SimpleThreadPool {
561 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
562 f.debug_struct("SimpleThreadPool").finish_non_exhaustive()
563 }
564}
565
566impl SimpleThreadPool {
567 pub fn wait_idle(&mut self) {
569 unsafe {
571 ffi::whiteout_host_SimpleThreadPool_waitIdle(self.raw.as_ptr());
572 }
573 }
574
575 pub fn thread_count(&self) -> usize {
577 unsafe { ffi::whiteout_host_SimpleThreadPool_threadCount(self.raw.as_ptr()) }
579 }
580}
581
582pub struct SimpleHttpHandler {
586 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_SimpleHttpHandler>,
587}
588
589impl Drop for SimpleHttpHandler {
590 fn drop(&mut self) {
591 unsafe { ffi::whiteout_host_SimpleHttpHandler_delete(self.raw.as_ptr()) }
593 }
594}
595
596impl SimpleHttpHandler {
597 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_SimpleHttpHandler) -> Option<Self> {
601 core::ptr::NonNull::new(raw).map(|raw| SimpleHttpHandler { raw })
602 }
603}
604
605unsafe impl Send for SimpleHttpHandler {}
610
611impl core::fmt::Debug for SimpleHttpHandler {
612 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
613 f.debug_struct("SimpleHttpHandler").finish_non_exhaustive()
614 }
615}
616
617impl SimpleHttpHandler {
618 pub fn new() -> Self {
621 unsafe {
624 let raw = ffi::whiteout_host_SimpleHttpHandler_new();
625 Self::from_raw(raw).expect("native SimpleHttpHandler allocation failed")
626 }
627 }
628
629 pub fn capabilities(&self) -> u32 {
631 unsafe { ffi::whiteout_host_SimpleHttpHandler_capabilities(self.raw.as_ptr()) }
633 }
634}
635
636impl Default for SimpleHttpHandler {
637 fn default() -> Self {
638 Self::new()
639 }
640}
641
642pub struct JobGroup {
648 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_JobGroup>,
649}
650
651impl Drop for JobGroup {
652 fn drop(&mut self) {
653 unsafe { ffi::whiteout_host_JobGroup_delete(self.raw.as_ptr()) }
655 }
656}
657
658impl JobGroup {
659 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_JobGroup) -> Option<Self> {
663 core::ptr::NonNull::new(raw).map(|raw| JobGroup { raw })
664 }
665}
666
667unsafe impl Send for JobGroup {}
672
673impl core::fmt::Debug for JobGroup {
674 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
675 f.debug_struct("JobGroup").finish_non_exhaustive()
676 }
677}
678
679impl JobGroup {
680 pub fn new() -> Self {
683 unsafe {
686 let raw = ffi::whiteout_host_JobGroup_new();
687 Self::from_raw(raw).expect("native JobGroup allocation failed")
688 }
689 }
690
691 pub fn add(&mut self, n: usize) {
695 unsafe {
697 ffi::whiteout_host_JobGroup_add(self.raw.as_ptr(), n);
698 }
699 }
700
701 pub fn done(&mut self) {
707 unsafe {
709 ffi::whiteout_host_JobGroup_done(self.raw.as_ptr());
710 }
711 }
712
713 pub fn await_(&mut self) {
715 unsafe {
717 ffi::whiteout_host_JobGroup_await(self.raw.as_ptr());
718 }
719 }
720
721 pub fn is_ready(&self) -> bool {
725 unsafe { ffi::whiteout_host_JobGroup_isReady(self.raw.as_ptr()) != 0 }
727 }
728}
729
730impl Default for JobGroup {
731 fn default() -> Self {
732 Self::new()
733 }
734}
735
736pub struct BlizzardGameInfo {
738 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_BlizzardGameInfo>,
739}
740
741impl Drop for BlizzardGameInfo {
742 fn drop(&mut self) {
743 unsafe { ffi::whiteout_host_BlizzardGameInfo_delete(self.raw.as_ptr()) }
745 }
746}
747
748impl BlizzardGameInfo {
749 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_BlizzardGameInfo) -> Option<Self> {
753 core::ptr::NonNull::new(raw).map(|raw| BlizzardGameInfo { raw })
754 }
755}
756
757unsafe impl Send for BlizzardGameInfo {}
762
763impl core::fmt::Debug for BlizzardGameInfo {
764 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
765 f.debug_struct("BlizzardGameInfo").finish_non_exhaustive()
766 }
767}
768
769impl BlizzardGameInfo {
770 pub fn new() -> Self {
773 unsafe {
776 let raw = ffi::whiteout_host_BlizzardGameInfo_new();
777 Self::from_raw(raw).expect("native BlizzardGameInfo allocation failed")
778 }
779 }
780
781 pub fn game(&self) -> BlizzardGame {
783 unsafe { ffi::whiteout_host_BlizzardGameInfo_get_game(self.raw.as_ptr()) }
785 .try_into()
786 .expect("unknown enum discriminant from the native library")
787 }
788
789 pub fn set_game(&mut self, value: BlizzardGame) {
790 unsafe { ffi::whiteout_host_BlizzardGameInfo_set_game(self.raw.as_ptr(), value as i32) }
792 }
793
794 pub fn name(&self) -> String {
796 unsafe {
798 crate::support::take_string(ffi::whiteout_host_BlizzardGameInfo_get_name(
799 self.raw.as_ptr(),
800 ))
801 }
802 }
803
804 pub fn set_name(&mut self, value: &str) {
805 let value = std::ffi::CString::new(value).unwrap_or_default();
806 unsafe { ffi::whiteout_host_BlizzardGameInfo_set_name(self.raw.as_ptr(), value.as_ptr()) }
808 }
809
810 pub fn path(&self) -> String {
812 unsafe {
814 crate::support::take_string(ffi::whiteout_host_BlizzardGameInfo_get_path(
815 self.raw.as_ptr(),
816 ))
817 }
818 }
819
820 pub fn set_path(&mut self, value: &str) {
821 let value = std::ffi::CString::new(value).unwrap_or_default();
822 unsafe { ffi::whiteout_host_BlizzardGameInfo_set_path(self.raw.as_ptr(), value.as_ptr()) }
824 }
825}
826
827impl Default for BlizzardGameInfo {
828 fn default() -> Self {
829 Self::new()
830 }
831}
832
833pub struct BlizzardGameInfoList {
835 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_BlizzardGameInfoList>,
836}
837
838impl Drop for BlizzardGameInfoList {
839 fn drop(&mut self) {
840 unsafe { ffi::whiteout_host_BlizzardGameInfoList_delete(self.raw.as_ptr()) }
842 }
843}
844
845impl BlizzardGameInfoList {
846 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_BlizzardGameInfoList) -> Option<Self> {
850 core::ptr::NonNull::new(raw).map(|raw| BlizzardGameInfoList { raw })
851 }
852}
853
854unsafe impl Send for BlizzardGameInfoList {}
859
860impl core::fmt::Debug for BlizzardGameInfoList {
861 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
862 f.debug_struct("BlizzardGameInfoList")
863 .finish_non_exhaustive()
864 }
865}
866
867impl BlizzardGameInfoList {
868 pub fn size(&self) -> usize {
870 unsafe { ffi::whiteout_host_BlizzardGameInfoList_size(self.raw.as_ptr()) }
872 }
873
874 pub fn at(&self, index: usize) -> Option<crate::support::Ref<'_, BlizzardGameInfo>> {
876 unsafe {
880 core::ptr::NonNull::new(ffi::whiteout_host_BlizzardGameInfoList_at(
881 self.raw.as_ptr(),
882 index,
883 ))
884 .map(|raw| crate::support::Ref::new(BlizzardGameInfo { raw }))
885 }
886 }
887}
888
889pub struct BlizzardGameFinder {
891 pub(crate) raw: core::ptr::NonNull<ffi::whiteout_BlizzardGameFinder>,
892}
893
894impl Drop for BlizzardGameFinder {
895 fn drop(&mut self) {
896 unsafe { ffi::whiteout_host_BlizzardGameFinder_delete(self.raw.as_ptr()) }
898 }
899}
900
901impl BlizzardGameFinder {
902 #[allow(dead_code)] pub(crate) unsafe fn from_raw(raw: *mut ffi::whiteout_BlizzardGameFinder) -> Option<Self> {
906 core::ptr::NonNull::new(raw).map(|raw| BlizzardGameFinder { raw })
907 }
908}
909
910unsafe impl Send for BlizzardGameFinder {}
915
916impl core::fmt::Debug for BlizzardGameFinder {
917 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
918 f.debug_struct("BlizzardGameFinder").finish_non_exhaustive()
919 }
920}
921
922impl BlizzardGameFinder {
923 pub fn find_all() -> Option<BlizzardGameInfoList> {
925 unsafe { BlizzardGameInfoList::from_raw(ffi::whiteout_host_BlizzardGameFinder_findAll()) }
927 }
928
929 pub fn from_name(name: &str) -> BlizzardGame {
931 let name_cstr = std::ffi::CString::new(name).unwrap_or_default();
932 unsafe {
934 BlizzardGame::try_from(ffi::whiteout_host_BlizzardGameFinder_fromName(
935 name_cstr.as_ptr(),
936 ))
937 .expect("unknown enum discriminant from the native library (ABI version skew)")
938 }
939 }
940
941 pub fn to_name(game: BlizzardGame) -> String {
943 unsafe {
945 crate::support::take_string(ffi::whiteout_host_BlizzardGameFinder_toName(game as i32))
946 }
947 }
948}
949
950#[doc(hidden)]
951pub mod ffi {
952 #![allow(missing_debug_implementations)]
953
954 #[allow(unused_imports)]
955 use crate::support::{RawBytes, RawCString};
956
957 #[repr(C)]
958 pub struct whiteout_WorkerPool {
959 _private: [u8; 0],
960 }
961 #[repr(C)]
962 pub struct whiteout_CascFileSystem {
963 _private: [u8; 0],
964 }
965 #[repr(C)]
966 pub struct whiteout_VirtualPathFileSystem {
967 _private: [u8; 0],
968 }
969 #[repr(C)]
970 pub struct whiteout_HttpResponse {
971 _private: [u8; 0],
972 }
973 #[repr(C)]
974 pub struct whiteout_HttpHandler {
975 _private: [u8; 0],
976 }
977 #[repr(C)]
978 pub struct whiteout_OsFileSystem {
979 _private: [u8; 0],
980 }
981 #[repr(C)]
982 pub struct whiteout_SimpleThreadPool {
983 _private: [u8; 0],
984 }
985 #[repr(C)]
986 pub struct whiteout_SimpleHttpHandler {
987 _private: [u8; 0],
988 }
989 #[repr(C)]
990 pub struct whiteout_JobGroup {
991 _private: [u8; 0],
992 }
993 #[repr(C)]
994 pub struct whiteout_BlizzardGameInfo {
995 _private: [u8; 0],
996 }
997 #[repr(C)]
998 pub struct whiteout_BlizzardGameInfoList {
999 _private: [u8; 0],
1000 }
1001 #[repr(C)]
1002 pub struct whiteout_BlizzardGameFinder {
1003 _private: [u8; 0],
1004 }
1005
1006 extern "C" {
1007 pub fn whiteout_host_WorkerPool_delete(self_: *mut whiteout_WorkerPool);
1009 pub fn whiteout_host_WorkerPool_waitIdle(self_: *mut whiteout_WorkerPool);
1010 pub fn whiteout_host_WorkerPool_threadCount(self_: *mut whiteout_WorkerPool) -> usize;
1011 pub fn whiteout_host_CascFileSystem_delete(self_: *mut whiteout_CascFileSystem);
1013 pub fn whiteout_host_CascFileSystem_readFile(
1014 self_: *mut whiteout_CascFileSystem,
1015 file_id: u32,
1016 ) -> RawBytes;
1017 pub fn whiteout_host_CascFileSystem_reserveFileId(
1018 self_: *mut whiteout_CascFileSystem,
1019 path: *const core::ffi::c_char,
1020 out_value: *mut u32,
1021 ) -> i32;
1022 pub fn whiteout_host_CascFileSystem_writeFile(
1023 self_: *mut whiteout_CascFileSystem,
1024 file_id: u32,
1025 data: *const u8,
1026 data_size: usize,
1027 ) -> i32;
1028 pub fn whiteout_host_CascFileSystem_fileExists(
1029 self_: *mut whiteout_CascFileSystem,
1030 file_id: u32,
1031 ) -> i32;
1032 pub fn whiteout_host_VirtualPathFileSystem_delete(
1034 self_: *mut whiteout_VirtualPathFileSystem,
1035 );
1036 pub fn whiteout_host_VirtualPathFileSystem_readFile(
1037 self_: *mut whiteout_VirtualPathFileSystem,
1038 path: *const core::ffi::c_char,
1039 ) -> RawBytes;
1040 pub fn whiteout_host_VirtualPathFileSystem_writeFile(
1041 self_: *mut whiteout_VirtualPathFileSystem,
1042 path: *const core::ffi::c_char,
1043 data: *const u8,
1044 data_size: usize,
1045 ) -> i32;
1046 pub fn whiteout_host_VirtualPathFileSystem_fileExists(
1047 self_: *mut whiteout_VirtualPathFileSystem,
1048 path: *const core::ffi::c_char,
1049 ) -> i32;
1050 pub fn whiteout_host_HttpResponse_new() -> *mut whiteout_HttpResponse;
1052 pub fn whiteout_host_HttpResponse_delete(self_: *mut whiteout_HttpResponse);
1053 pub fn whiteout_host_HttpResponse_get_statusCode(self_: *mut whiteout_HttpResponse) -> i32;
1054 pub fn whiteout_host_HttpResponse_set_statusCode(
1055 self_: *mut whiteout_HttpResponse,
1056 value: i32,
1057 );
1058 pub fn whiteout_host_HttpResponse_get_body_count(
1059 self_: *mut whiteout_HttpResponse,
1060 ) -> usize;
1061 pub fn whiteout_host_HttpResponse_resize_body(
1062 self_: *mut whiteout_HttpResponse,
1063 count: usize,
1064 );
1065 pub fn whiteout_host_HttpResponse_get_body_data(
1066 self_: *mut whiteout_HttpResponse,
1067 ) -> *const u8;
1068 pub fn whiteout_host_HttpResponse_assign_body(
1069 self_: *mut whiteout_HttpResponse,
1070 data: *const u8,
1071 count: usize,
1072 );
1073 pub fn whiteout_host_HttpResponse_get_error(
1074 self_: *mut whiteout_HttpResponse,
1075 ) -> RawCString;
1076 pub fn whiteout_host_HttpResponse_set_error(
1077 self_: *mut whiteout_HttpResponse,
1078 value: *const core::ffi::c_char,
1079 );
1080 pub fn whiteout_host_HttpHandler_delete(self_: *mut whiteout_HttpHandler);
1082 pub fn whiteout_host_HttpHandler_capabilities(self_: *mut whiteout_HttpHandler) -> u32;
1083 pub fn whiteout_host_OsFileSystem_new_rootPath(
1085 _0: *mut core::ffi::c_void,
1086 ) -> *mut whiteout_OsFileSystem;
1087 pub fn whiteout_host_OsFileSystem_delete(self_: *mut whiteout_OsFileSystem);
1088 pub fn whiteout_host_OsFileSystem_readFile(
1089 self_: *mut whiteout_OsFileSystem,
1090 path: *const core::ffi::c_char,
1091 ) -> RawBytes;
1092 pub fn whiteout_host_OsFileSystem_writeFile(
1093 self_: *mut whiteout_OsFileSystem,
1094 path: *const core::ffi::c_char,
1095 data: *const u8,
1096 data_size: usize,
1097 ) -> i32;
1098 pub fn whiteout_host_OsFileSystem_fileExists(
1099 self_: *mut whiteout_OsFileSystem,
1100 path: *const core::ffi::c_char,
1101 ) -> i32;
1102 pub fn whiteout_host_SimpleThreadPool_new_nThreads(
1104 _0: *mut core::ffi::c_void,
1105 ) -> *mut whiteout_SimpleThreadPool;
1106 pub fn whiteout_host_SimpleThreadPool_delete(self_: *mut whiteout_SimpleThreadPool);
1107 pub fn whiteout_host_SimpleThreadPool_waitIdle(self_: *mut whiteout_SimpleThreadPool);
1108 pub fn whiteout_host_SimpleThreadPool_threadCount(
1109 self_: *mut whiteout_SimpleThreadPool,
1110 ) -> usize;
1111 pub fn whiteout_host_SimpleHttpHandler_new() -> *mut whiteout_SimpleHttpHandler;
1113 pub fn whiteout_host_SimpleHttpHandler_new_nThreads(
1114 _0: *mut core::ffi::c_void,
1115 ) -> *mut whiteout_SimpleHttpHandler;
1116 pub fn whiteout_host_SimpleHttpHandler_delete(self_: *mut whiteout_SimpleHttpHandler);
1117 pub fn whiteout_host_SimpleHttpHandler_capabilities(
1118 self_: *mut whiteout_SimpleHttpHandler,
1119 ) -> u32;
1120 pub fn whiteout_host_JobGroup_new() -> *mut whiteout_JobGroup;
1122 pub fn whiteout_host_JobGroup_delete(self_: *mut whiteout_JobGroup);
1123 pub fn whiteout_host_JobGroup_add(self_: *mut whiteout_JobGroup, n: usize);
1124 pub fn whiteout_host_JobGroup_done(self_: *mut whiteout_JobGroup);
1125 pub fn whiteout_host_JobGroup_await(self_: *mut whiteout_JobGroup);
1126 pub fn whiteout_host_JobGroup_isReady(self_: *mut whiteout_JobGroup) -> i32;
1127 pub fn whiteout_host_BlizzardGameInfo_new() -> *mut whiteout_BlizzardGameInfo;
1129 pub fn whiteout_host_BlizzardGameInfo_delete(self_: *mut whiteout_BlizzardGameInfo);
1130 pub fn whiteout_host_BlizzardGameInfo_get_game(
1131 self_: *mut whiteout_BlizzardGameInfo,
1132 ) -> i32;
1133 pub fn whiteout_host_BlizzardGameInfo_set_game(
1134 self_: *mut whiteout_BlizzardGameInfo,
1135 value: i32,
1136 );
1137 pub fn whiteout_host_BlizzardGameInfo_get_name(
1138 self_: *mut whiteout_BlizzardGameInfo,
1139 ) -> RawCString;
1140 pub fn whiteout_host_BlizzardGameInfo_set_name(
1141 self_: *mut whiteout_BlizzardGameInfo,
1142 value: *const core::ffi::c_char,
1143 );
1144 pub fn whiteout_host_BlizzardGameInfo_get_path(
1145 self_: *mut whiteout_BlizzardGameInfo,
1146 ) -> RawCString;
1147 pub fn whiteout_host_BlizzardGameInfo_set_path(
1148 self_: *mut whiteout_BlizzardGameInfo,
1149 value: *const core::ffi::c_char,
1150 );
1151 pub fn whiteout_host_BlizzardGameInfoList_delete(self_: *mut whiteout_BlizzardGameInfoList);
1153 pub fn whiteout_host_BlizzardGameInfoList_size(
1154 self_: *mut whiteout_BlizzardGameInfoList,
1155 ) -> usize;
1156 pub fn whiteout_host_BlizzardGameInfoList_at(
1157 self_: *mut whiteout_BlizzardGameInfoList,
1158 index: usize,
1159 ) -> *mut whiteout_BlizzardGameInfo;
1160 pub fn whiteout_host_BlizzardGameFinder_delete(self_: *mut whiteout_BlizzardGameFinder);
1162 pub fn whiteout_host_BlizzardGameFinder_findAll() -> *mut whiteout_BlizzardGameInfoList;
1163 pub fn whiteout_host_BlizzardGameFinder_fromName(name: *const core::ffi::c_char) -> i32;
1164 pub fn whiteout_host_BlizzardGameFinder_toName(game: i32) -> RawCString;
1165 }
1166}