Skip to main content

nil_ffi/
lib.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4#![feature(nonpoison_mutex, sync_nonpoison)]
5#![expect(clippy::missing_safety_doc)]
6
7mod client;
8mod json;
9mod macros;
10mod queue;
11mod request;
12mod response;
13mod runtime;
14mod server;
15mod status;
16
17use crate::runtime::RUNTIME;
18use crate::server::SERVER;
19use client::{CLIENT, on_event};
20use json::serialize;
21use std::ffi::{CString, c_char};
22use std::ptr;
23use tap::TryConv;
24
25pub use request::RequestId;
26pub use response::{Response, Result};
27pub use status::Status;
28
29///////////////////////////////
30//////////// FFI //////////////
31///////////////////////////////
32
33#[unsafe(no_mangle)]
34pub unsafe extern "C" fn nil_ffi_free_str(ptr: *mut c_char) {
35  if !ptr.is_null() {
36    drop(unsafe { CString::from_raw(ptr) });
37  }
38}
39
40#[unsafe(no_mangle)]
41pub unsafe extern "C" fn nil_ffi_poll(json_out: *mut *mut c_char) -> Status {
42  if json_out.is_null() {
43    return Status::ERR_NULL_POINTER;
44  }
45
46  unsafe { *json_out = ptr::null_mut() };
47
48  match queue::poll() {
49    Some(entry) => {
50      match serialize(&entry) {
51        Ok(json) => {
52          let json = CString::new(json).unwrap();
53          unsafe { *json_out = json.into_raw() };
54          Status::OK
55        }
56        Err(_) => Status::ERR_SERIALIZATION,
57      }
58    }
59    None => Status::ERR_NOTHING_TO_POLL,
60  }
61}
62
63#[unsafe(no_mangle)]
64pub unsafe extern "C" fn nil_ffi_shutdown() {
65  queue::clear();
66}
67
68#[unsafe(no_mangle)]
69pub unsafe extern "C" fn nil_ffi_version(request_id: RequestId) {
70  push_ok!(request_id, env!("CARGO_PKG_VERSION"));
71}
72
73///////////////////////////////
74//////////// SERVER ///////////
75///////////////////////////////
76
77#[unsafe(no_mangle)]
78pub unsafe extern "C" fn nil_is_host(request_id: RequestId) {
79  async_push_ok!(request_id, SERVER.read().await.is_some());
80}
81
82/// [`nil_server::local::start`]
83#[unsafe(no_mangle)]
84pub unsafe extern "C" fn nil_start_server(request_id: RequestId, json_options: *const c_char) {
85  let f = |options| {
86    RUNTIME.spawn(async move {
87      let result = server::start_with_options(options).await;
88      queue::push_result(request_id, Result::from(result));
89    });
90  };
91
92  unsafe { json::with_ptr(request_id, json_options, f) };
93}
94
95/// [`nil_server::local::load`]
96#[unsafe(no_mangle)]
97pub unsafe extern "C" fn nil_start_server_with_savedata(
98  request_id: RequestId,
99  json_path: *const c_char,
100) {
101  let f = |path| {
102    RUNTIME.spawn(async move {
103      let result = server::start_with_savedata(path).await;
104      queue::push_result(request_id, Result::from(result));
105    });
106  };
107
108  unsafe { json::with_ptr(request_id, json_path, f) };
109}
110
111/// [`LocalServer::stop`](nil_server::local::LocalServer::stop)
112#[unsafe(no_mangle)]
113pub unsafe extern "C" fn nil_stop_server(request_id: RequestId) {
114  RUNTIME.spawn(async move {
115    server::stop().await;
116    queue::push_ok(request_id, ());
117  });
118}
119
120///////////////////////////////
121//////////// CLIENT ///////////
122///////////////////////////////
123
124#[unsafe(no_mangle)]
125pub unsafe extern "C" fn nil_client_version(request_id: RequestId) {
126  push_ok!(request_id, nil_client::VERSION);
127}
128
129/// [`Client::is_local`](nil_client::Client::is_local)
130#[unsafe(no_mangle)]
131pub unsafe extern "C" fn nil_is_local(request_id: RequestId) {
132  async_push_ok!(request_id, CLIENT.read().await.is_local());
133}
134
135/// [`Client::is_ready`](nil_client::Client::is_ready)
136#[unsafe(no_mangle)]
137pub unsafe extern "C" fn nil_is_ready(request_id: RequestId) {
138  async_push_ok!(request_id, CLIENT.read().await.is_ready().await);
139}
140
141/// [`Client::is_remote`](nil_client::Client::is_remote)
142#[unsafe(no_mangle)]
143pub unsafe extern "C" fn nil_is_remote(request_id: RequestId) {
144  async_push_ok!(request_id, CLIENT.read().await.is_remote());
145}
146
147/// [`Client::server_addr`](nil_client::Client::server_addr)
148#[unsafe(no_mangle)]
149pub unsafe extern "C" fn nil_server_addr(request_id: RequestId) {
150  async_push_ok!(request_id, CLIENT.read().await.server_addr());
151}
152
153/// [`Client::set_user_agent`](nil_client::Client::set_user_agent)
154#[unsafe(no_mangle)]
155pub unsafe extern "C" fn nil_set_user_agent(request_id: RequestId, json_user_agent: *const c_char) {
156  let f = |user_agent: String| {
157    RUNTIME.spawn(async move {
158      CLIENT
159        .write()
160        .await
161        .set_user_agent(&user_agent);
162
163      queue::push_ok(request_id, ());
164    });
165  };
166
167  unsafe { json::with_ptr(request_id, json_user_agent, f) };
168}
169
170/// [`Client::stop`](nil_client::Client::stop)
171#[unsafe(no_mangle)]
172pub unsafe extern "C" fn nil_stop_client(request_id: RequestId) {
173  RUNTIME.spawn(async move {
174    CLIENT.write().await.stop().await;
175    queue::push_ok(request_id, ());
176  });
177}
178
179/// [`Client::update`](nil_client::Client::update)
180#[unsafe(no_mangle)]
181pub unsafe extern "C" fn nil_update_client(request_id: RequestId, json_options: *const c_char) {
182  let f = |options| {
183    RUNTIME.spawn(async move {
184      let result = CLIENT
185        .write()
186        .await
187        .update(options, Some(on_event()))
188        .await;
189
190      queue::push_result(request_id, Result::from(result));
191    });
192  };
193
194  unsafe { json::with_ptr(request_id, json_options, f) };
195}
196
197/// [`Client::user_agent`](nil_client::Client::user_agent)
198#[unsafe(no_mangle)]
199pub unsafe extern "C" fn nil_user_agent(request_id: RequestId) {
200  async_push_ok!(request_id, CLIENT.read().await.user_agent().to_owned());
201}
202
203/// [`Client::world`](nil_client::Client::world)
204#[unsafe(no_mangle)]
205pub unsafe extern "C" fn nil_world(request_id: RequestId) {
206  RUNTIME.spawn(async move {
207    match CLIENT.read().await.world() {
208      Some(world) => queue::push_ok(request_id, world),
209      None => queue::push_ok(request_id, None::<&str>),
210    }
211  });
212}
213
214///////////////////////////////
215/////////// RUNTIME ///////////
216///////////////////////////////
217
218/// [`RuntimeMetrics::global_queue_depth`](tokio::runtime::RuntimeMetrics::global_queue_depth)
219#[unsafe(no_mangle)]
220pub unsafe extern "C" fn nil_runtime_global_queue_depth(request_id: RequestId) {
221  push_result!(
222    request_id,
223    RUNTIME
224      .metrics()
225      .global_queue_depth()
226      .try_conv::<u32>()
227  );
228}
229
230/// [`RuntimeMetrics::num_alive_tasks`](tokio::runtime::RuntimeMetrics::num_alive_tasks)
231#[unsafe(no_mangle)]
232pub unsafe extern "C" fn nil_runtime_num_alive_tasks(request_id: RequestId) {
233  push_result!(
234    request_id,
235    RUNTIME
236      .metrics()
237      .num_alive_tasks()
238      .try_conv::<u32>()
239  );
240}
241
242/// [`RuntimeMetrics::num_workers`](tokio::runtime::RuntimeMetrics::num_workers)
243#[unsafe(no_mangle)]
244pub unsafe extern "C" fn nil_runtime_num_workers(request_id: RequestId) {
245  push_result!(
246    request_id,
247    RUNTIME
248      .metrics()
249      .num_workers()
250      .try_conv::<u32>()
251  );
252}
253
254///////////////////////////////
255////////// ENDPOINTS //////////
256///////////////////////////////
257
258/// [`Client::add_academy_recruit_order`](nil_client::Client::add_academy_recruit_order)
259#[unsafe(no_mangle)]
260pub unsafe extern "C" fn nil_add_academy_recruit_order(
261  request_id: RequestId,
262  json_req: *const c_char,
263) {
264  send!(request_id, add_academy_recruit_order, json_req);
265}
266
267/// [`Client::add_prefecture_build_order`](nil_client::Client::add_prefecture_build_order)
268#[unsafe(no_mangle)]
269pub unsafe extern "C" fn nil_add_prefecture_build_order(
270  request_id: RequestId,
271  json_req: *const c_char,
272) {
273  send!(request_id, add_prefecture_build_order, json_req);
274}
275
276/// [`Client::add_stable_recruit_order`](nil_client::Client::add_stable_recruit_order)
277#[unsafe(no_mangle)]
278pub unsafe extern "C" fn nil_add_stable_recruit_order(
279  request_id: RequestId,
280  json_req: *const c_char,
281) {
282  send!(request_id, add_stable_recruit_order, json_req);
283}
284
285/// [`Client::add_workshop_recruit_order`](nil_client::Client::add_workshop_recruit_order)
286#[unsafe(no_mangle)]
287pub unsafe extern "C" fn nil_add_workshop_recruit_order(
288  request_id: RequestId,
289  json_req: *const c_char,
290) {
291  send!(request_id, add_workshop_recruit_order, json_req);
292}
293
294/// [`Client::authorize`](nil_client::Client::authorize)
295#[unsafe(no_mangle)]
296pub unsafe extern "C" fn nil_authorize(request_id: RequestId, json_req: *const c_char) {
297  send!(request_id, authorize, json_req);
298}
299
300/// [`Client::buy_resources`](nil_client::Client::buy_resources)
301#[unsafe(no_mangle)]
302pub unsafe extern "C" fn nil_buy_resources(request_id: RequestId, json_req: *const c_char) {
303  send!(request_id, buy_resources, json_req);
304}
305
306/// [`Client::cancel_academy_recruit_order`](nil_client::Client::cancel_academy_recruit_order)
307#[unsafe(no_mangle)]
308pub unsafe extern "C" fn nil_cancel_academy_recruit_order(
309  request_id: RequestId,
310  json_req: *const c_char,
311) {
312  send!(request_id, cancel_academy_recruit_order, json_req);
313}
314
315/// [`Client::cancel_maneuver`](nil_client::Client::cancel_maneuver)
316#[unsafe(no_mangle)]
317pub unsafe extern "C" fn nil_cancel_maneuver(request_id: RequestId, json_req: *const c_char) {
318  send!(request_id, cancel_maneuver, json_req);
319}
320
321/// [`Client::cancel_prefecture_build_order`](nil_client::Client::cancel_prefecture_build_order)
322#[unsafe(no_mangle)]
323pub unsafe extern "C" fn nil_cancel_prefecture_build_order(
324  request_id: RequestId,
325  json_req: *const c_char,
326) {
327  send!(request_id, cancel_prefecture_build_order, json_req);
328}
329
330/// [`Client::cancel_stable_recruit_order`](nil_client::Client::cancel_stable_recruit_order)
331#[unsafe(no_mangle)]
332pub unsafe extern "C" fn nil_cancel_stable_recruit_order(
333  request_id: RequestId,
334  json_req: *const c_char,
335) {
336  send!(request_id, cancel_stable_recruit_order, json_req);
337}
338
339/// [`Client::cancel_workshop_recruit_order`](nil_client::Client::cancel_workshop_recruit_order)
340#[unsafe(no_mangle)]
341pub unsafe extern "C" fn nil_cancel_workshop_recruit_order(
342  request_id: RequestId,
343  json_req: *const c_char,
344) {
345  send!(request_id, cancel_workshop_recruit_order, json_req);
346}
347
348/// [`Client::cheat_fill_world`](nil_client::Client::cheat_fill_world)
349#[unsafe(no_mangle)]
350pub unsafe extern "C" fn nil_cheat_fill_world(request_id: RequestId, json_req: *const c_char) {
351  send!(request_id, cheat_fill_world, json_req);
352}
353
354/// [`Client::cheat_get_academy_recruit_queue`](nil_client::Client::cheat_get_academy_recruit_queue)
355#[unsafe(no_mangle)]
356pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queue(
357  request_id: RequestId,
358  json_req: *const c_char,
359) {
360  send!(request_id, cheat_get_academy_recruit_queue, json_req);
361}
362
363/// [`Client::cheat_get_academy_recruit_queues`](nil_client::Client::cheat_get_academy_recruit_queues)
364#[unsafe(no_mangle)]
365pub unsafe extern "C" fn nil_cheat_get_academy_recruit_queues(
366  request_id: RequestId,
367  json_req: *const c_char,
368) {
369  send!(request_id, cheat_get_academy_recruit_queues, json_req);
370}
371
372/// [`Client::cheat_get_all_academy_recruit_queues`](nil_client::Client::cheat_get_all_academy_recruit_queues)
373#[unsafe(no_mangle)]
374pub unsafe extern "C" fn nil_cheat_get_all_academy_recruit_queues(
375  request_id: RequestId,
376  json_req: *const c_char,
377) {
378  send!(request_id, cheat_get_all_academy_recruit_queues, json_req);
379}
380
381/// [`Client::cheat_get_all_prefecture_build_queues`](nil_client::Client::cheat_get_all_prefecture_build_queues)
382#[unsafe(no_mangle)]
383pub unsafe extern "C" fn nil_cheat_get_all_prefecture_build_queues(
384  request_id: RequestId,
385  json_req: *const c_char,
386) {
387  send!(request_id, cheat_get_all_prefecture_build_queues, json_req);
388}
389
390/// [`Client::cheat_get_all_stable_recruit_queues`](nil_client::Client::cheat_get_all_stable_recruit_queues)
391#[unsafe(no_mangle)]
392pub unsafe extern "C" fn nil_cheat_get_all_stable_recruit_queues(
393  request_id: RequestId,
394  json_req: *const c_char,
395) {
396  send!(request_id, cheat_get_all_stable_recruit_queues, json_req);
397}
398
399/// [`Client::cheat_get_build_steps`](nil_client::Client::cheat_get_build_steps)
400#[unsafe(no_mangle)]
401pub unsafe extern "C" fn nil_cheat_get_build_steps(request_id: RequestId, json_req: *const c_char) {
402  send!(request_id, cheat_get_build_steps, json_req);
403}
404
405/// [`Client::cheat_get_cities`](nil_client::Client::cheat_get_cities)
406#[unsafe(no_mangle)]
407pub unsafe extern "C" fn nil_cheat_get_cities(request_id: RequestId, json_req: *const c_char) {
408  send!(request_id, cheat_get_cities, json_req);
409}
410
411/// [`Client::cheat_get_city`](nil_client::Client::cheat_get_city)
412#[unsafe(no_mangle)]
413pub unsafe extern "C" fn nil_cheat_get_city(request_id: RequestId, json_req: *const c_char) {
414  send!(request_id, cheat_get_city, json_req);
415}
416
417/// [`Client::cheat_get_ethics`](nil_client::Client::cheat_get_ethics)
418#[unsafe(no_mangle)]
419pub unsafe extern "C" fn nil_cheat_get_ethics(request_id: RequestId, json_req: *const c_char) {
420  send!(request_id, cheat_get_ethics, json_req);
421}
422
423/// [`Client::cheat_get_idle_armies_at`](nil_client::Client::cheat_get_idle_armies_at)
424#[unsafe(no_mangle)]
425pub unsafe extern "C" fn nil_cheat_get_idle_armies_at(
426  request_id: RequestId,
427  json_req: *const c_char,
428) {
429  send!(request_id, cheat_get_idle_armies_at, json_req);
430}
431
432/// [`Client::cheat_get_idle_personnel_at`](nil_client::Client::cheat_get_idle_personnel_at)
433#[unsafe(no_mangle)]
434pub unsafe extern "C" fn nil_cheat_get_idle_personnel_at(
435  request_id: RequestId,
436  json_req: *const c_char,
437) {
438  send!(request_id, cheat_get_idle_personnel_at, json_req);
439}
440
441/// [`Client::cheat_get_infrastructure`](nil_client::Client::cheat_get_infrastructure)
442#[unsafe(no_mangle)]
443pub unsafe extern "C" fn nil_cheat_get_infrastructure(
444  request_id: RequestId,
445  json_req: *const c_char,
446) {
447  send!(request_id, cheat_get_infrastructure, json_req);
448}
449
450/// [`Client::cheat_get_maneuvers`](nil_client::Client::cheat_get_maneuvers)
451#[unsafe(no_mangle)]
452pub unsafe extern "C" fn nil_cheat_get_maneuvers(request_id: RequestId, json_req: *const c_char) {
453  send!(request_id, cheat_get_maneuvers, json_req);
454}
455
456/// [`Client::cheat_get_maneuvers_of`](nil_client::Client::cheat_get_maneuvers_of)
457#[unsafe(no_mangle)]
458pub unsafe extern "C" fn nil_cheat_get_maneuvers_of(
459  request_id: RequestId,
460  json_req: *const c_char,
461) {
462  send!(request_id, cheat_get_maneuvers_of, json_req);
463}
464
465/// [`Client::cheat_get_player`](nil_client::Client::cheat_get_player)
466#[unsafe(no_mangle)]
467pub unsafe extern "C" fn nil_cheat_get_player(request_id: RequestId, json_req: *const c_char) {
468  send!(request_id, cheat_get_player, json_req);
469}
470
471/// [`Client::cheat_get_players`](nil_client::Client::cheat_get_players)
472#[unsafe(no_mangle)]
473pub unsafe extern "C" fn nil_cheat_get_players(request_id: RequestId, json_req: *const c_char) {
474  send!(request_id, cheat_get_players, json_req);
475}
476
477/// [`Client::cheat_get_prefecture_build_queue`](nil_client::Client::cheat_get_prefecture_build_queue)
478#[unsafe(no_mangle)]
479pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queue(
480  request_id: RequestId,
481  json_req: *const c_char,
482) {
483  send!(request_id, cheat_get_prefecture_build_queue, json_req);
484}
485
486/// [`Client::cheat_get_prefecture_build_queues`](nil_client::Client::cheat_get_prefecture_build_queues)
487#[unsafe(no_mangle)]
488pub unsafe extern "C" fn nil_cheat_get_prefecture_build_queues(
489  request_id: RequestId,
490  json_req: *const c_char,
491) {
492  send!(request_id, cheat_get_prefecture_build_queues, json_req);
493}
494
495/// [`Client::cheat_get_resources`](nil_client::Client::cheat_get_resources)
496#[unsafe(no_mangle)]
497pub unsafe extern "C" fn nil_cheat_get_resources(request_id: RequestId, json_req: *const c_char) {
498  send!(request_id, cheat_get_resources, json_req);
499}
500
501/// [`Client::cheat_get_stable_recruit_queue`](nil_client::Client::cheat_get_stable_recruit_queue)
502#[unsafe(no_mangle)]
503pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queue(
504  request_id: RequestId,
505  json_req: *const c_char,
506) {
507  send!(request_id, cheat_get_stable_recruit_queue, json_req);
508}
509
510/// [`Client::cheat_get_stable_recruit_queues`](nil_client::Client::cheat_get_stable_recruit_queues)
511#[unsafe(no_mangle)]
512pub unsafe extern "C" fn nil_cheat_get_stable_recruit_queues(
513  request_id: RequestId,
514  json_req: *const c_char,
515) {
516  send!(request_id, cheat_get_stable_recruit_queues, json_req);
517}
518
519/// [`Client::cheat_get_storage_capacity`](nil_client::Client::cheat_get_storage_capacity)
520#[unsafe(no_mangle)]
521pub unsafe extern "C" fn nil_cheat_get_storage_capacity(
522  request_id: RequestId,
523  json_req: *const c_char,
524) {
525  send!(request_id, cheat_get_storage_capacity, json_req);
526}
527
528/// [`Client::cheat_set_bot_ethics`](nil_client::Client::cheat_set_bot_ethics)
529#[unsafe(no_mangle)]
530pub unsafe extern "C" fn nil_cheat_set_bot_ethics(request_id: RequestId, json_req: *const c_char) {
531  send!(request_id, cheat_set_bot_ethics, json_req);
532}
533
534/// [`Client::cheat_set_building_level`](nil_client::Client::cheat_set_building_level)
535#[unsafe(no_mangle)]
536pub unsafe extern "C" fn nil_cheat_set_building_level(
537  request_id: RequestId,
538  json_req: *const c_char,
539) {
540  send!(request_id, cheat_set_building_level, json_req);
541}
542
543/// [`Client::cheat_set_food`](nil_client::Client::cheat_set_food)
544#[unsafe(no_mangle)]
545pub unsafe extern "C" fn nil_cheat_set_food(request_id: RequestId, json_req: *const c_char) {
546  send!(request_id, cheat_set_food, json_req);
547}
548
549/// [`Client::cheat_set_iron`](nil_client::Client::cheat_set_iron)
550#[unsafe(no_mangle)]
551pub unsafe extern "C" fn nil_cheat_set_iron(request_id: RequestId, json_req: *const c_char) {
552  send!(request_id, cheat_set_iron, json_req);
553}
554
555/// [`Client::cheat_set_market_fee`](nil_client::Client::cheat_set_market_fee)
556#[unsafe(no_mangle)]
557pub unsafe extern "C" fn nil_cheat_set_market_fee(request_id: RequestId, json_req: *const c_char) {
558  send!(request_id, cheat_set_market_fee, json_req);
559}
560
561/// [`Client::cheat_set_market_vault_resources`](nil_client::Client::cheat_set_market_vault_resources)
562#[unsafe(no_mangle)]
563pub unsafe extern "C" fn nil_cheat_set_market_vault_resources(
564  request_id: RequestId,
565  json_req: *const c_char,
566) {
567  send!(request_id, cheat_set_market_vault_resources, json_req);
568}
569
570/// [`Client::cheat_set_max_food`](nil_client::Client::cheat_set_max_food)
571#[unsafe(no_mangle)]
572pub unsafe extern "C" fn nil_cheat_set_max_food(request_id: RequestId, json_req: *const c_char) {
573  send!(request_id, cheat_set_max_food, json_req);
574}
575
576/// [`Client::cheat_set_max_infrastructure`](nil_client::Client::cheat_set_max_infrastructure)
577#[unsafe(no_mangle)]
578pub unsafe extern "C" fn nil_cheat_set_max_infrastructure(
579  request_id: RequestId,
580  json_req: *const c_char,
581) {
582  send!(request_id, cheat_set_max_infrastructure, json_req);
583}
584
585/// [`Client::cheat_set_max_iron`](nil_client::Client::cheat_set_max_iron)
586#[unsafe(no_mangle)]
587pub unsafe extern "C" fn nil_cheat_set_max_iron(request_id: RequestId, json_req: *const c_char) {
588  send!(request_id, cheat_set_max_iron, json_req);
589}
590
591/// [`Client::cheat_set_max_resources`](nil_client::Client::cheat_set_max_resources)
592#[unsafe(no_mangle)]
593pub unsafe extern "C" fn nil_cheat_set_max_resources(
594  request_id: RequestId,
595  json_req: *const c_char,
596) {
597  send!(request_id, cheat_set_max_resources, json_req);
598}
599
600/// [`Client::cheat_set_max_silo_resources`](nil_client::Client::cheat_set_max_silo_resources)
601#[unsafe(no_mangle)]
602pub unsafe extern "C" fn nil_cheat_set_max_silo_resources(
603  request_id: RequestId,
604  json_req: *const c_char,
605) {
606  send!(request_id, cheat_set_max_silo_resources, json_req);
607}
608
609/// [`Client::cheat_set_max_stone`](nil_client::Client::cheat_set_max_stone)
610#[unsafe(no_mangle)]
611pub unsafe extern "C" fn nil_cheat_set_max_stone(request_id: RequestId, json_req: *const c_char) {
612  send!(request_id, cheat_set_max_stone, json_req);
613}
614
615/// [`Client::cheat_set_max_warehouse_resources`](nil_client::Client::cheat_set_max_warehouse_resources)
616#[unsafe(no_mangle)]
617pub unsafe extern "C" fn nil_cheat_set_max_warehouse_resources(
618  request_id: RequestId,
619  json_req: *const c_char,
620) {
621  send!(request_id, cheat_set_max_warehouse_resources, json_req);
622}
623
624/// [`Client::cheat_set_max_wood`](nil_client::Client::cheat_set_max_wood)
625#[unsafe(no_mangle)]
626pub unsafe extern "C" fn nil_cheat_set_max_wood(request_id: RequestId, json_req: *const c_char) {
627  send!(request_id, cheat_set_max_wood, json_req);
628}
629
630/// [`Client::cheat_set_resources`](nil_client::Client::cheat_set_resources)
631#[unsafe(no_mangle)]
632pub unsafe extern "C" fn nil_cheat_set_resources(request_id: RequestId, json_req: *const c_char) {
633  send!(request_id, cheat_set_resources, json_req);
634}
635
636/// [`Client::cheat_set_stability`](nil_client::Client::cheat_set_stability)
637#[unsafe(no_mangle)]
638pub unsafe extern "C" fn nil_cheat_set_stability(request_id: RequestId, json_req: *const c_char) {
639  send!(request_id, cheat_set_stability, json_req);
640}
641
642/// [`Client::cheat_set_stone`](nil_client::Client::cheat_set_stone)
643#[unsafe(no_mangle)]
644pub unsafe extern "C" fn nil_cheat_set_stone(request_id: RequestId, json_req: *const c_char) {
645  send!(request_id, cheat_set_stone, json_req);
646}
647
648/// [`Client::cheat_set_wood`](nil_client::Client::cheat_set_wood)
649#[unsafe(no_mangle)]
650pub unsafe extern "C" fn nil_cheat_set_wood(request_id: RequestId, json_req: *const c_char) {
651  send!(request_id, cheat_set_wood, json_req);
652}
653
654/// [`Client::cheat_skip_round`](nil_client::Client::cheat_skip_round)
655#[unsafe(no_mangle)]
656pub unsafe extern "C" fn nil_cheat_skip_round(request_id: RequestId, json_req: *const c_char) {
657  send!(request_id, cheat_skip_round, json_req);
658}
659
660/// [`Client::cheat_spawn_bot`](nil_client::Client::cheat_spawn_bot)
661#[unsafe(no_mangle)]
662pub unsafe extern "C" fn nil_cheat_spawn_bot(request_id: RequestId, json_req: *const c_char) {
663  send!(request_id, cheat_spawn_bot, json_req);
664}
665
666/// [`Client::cheat_spawn_city`](nil_client::Client::cheat_spawn_city)
667#[unsafe(no_mangle)]
668pub unsafe extern "C" fn nil_cheat_spawn_city(request_id: RequestId, json_req: *const c_char) {
669  send!(request_id, cheat_spawn_city, json_req);
670}
671
672/// [`Client::cheat_spawn_personnel`](nil_client::Client::cheat_spawn_personnel)
673#[unsafe(no_mangle)]
674pub unsafe extern "C" fn nil_cheat_spawn_personnel(request_id: RequestId, json_req: *const c_char) {
675  send!(request_id, cheat_spawn_personnel, json_req);
676}
677
678/// [`Client::create_remote_world`](nil_client::Client::create_remote_world)
679#[unsafe(no_mangle)]
680pub unsafe extern "C" fn nil_create_remote_world(request_id: RequestId, json_req: *const c_char) {
681  send!(request_id, create_remote_world, json_req);
682}
683
684/// [`Client::create_user`](nil_client::Client::create_user)
685#[unsafe(no_mangle)]
686pub unsafe extern "C" fn nil_create_user(request_id: RequestId, json_req: *const c_char) {
687  send!(request_id, create_user, json_req);
688}
689
690/// [`Client::delete_remote_world`](nil_client::Client::delete_remote_world)
691#[unsafe(no_mangle)]
692pub unsafe extern "C" fn nil_delete_remote_world(request_id: RequestId, json_req: *const c_char) {
693  send!(request_id, delete_remote_world, json_req);
694}
695
696/// [`Client::forward_report`](nil_client::Client::forward_report)
697#[unsafe(no_mangle)]
698pub unsafe extern "C" fn nil_forward_report(request_id: RequestId, json_req: *const c_char) {
699  send!(request_id, forward_report, json_req);
700}
701
702/// [`Client::get_academy_recruit_catalog`](nil_client::Client::get_academy_recruit_catalog)
703#[unsafe(no_mangle)]
704pub unsafe extern "C" fn nil_get_academy_recruit_catalog(
705  request_id: RequestId,
706  json_req: *const c_char,
707) {
708  send!(request_id, get_academy_recruit_catalog, json_req);
709}
710
711/// [`Client::get_armies`](nil_client::Client::get_armies)
712#[unsafe(no_mangle)]
713pub unsafe extern "C" fn nil_get_armies(request_id: RequestId, json_req: *const c_char) {
714  send!(request_id, get_armies, json_req);
715}
716
717/// [`Client::get_army`](nil_client::Client::get_army)
718#[unsafe(no_mangle)]
719pub unsafe extern "C" fn nil_get_army(request_id: RequestId, json_req: *const c_char) {
720  send!(request_id, get_army, json_req);
721}
722
723/// [`Client::get_army_owner`](nil_client::Client::get_army_owner)
724#[unsafe(no_mangle)]
725pub unsafe extern "C" fn nil_get_army_owner(request_id: RequestId, json_req: *const c_char) {
726  send!(request_id, get_army_owner, json_req);
727}
728
729/// [`Client::get_bot_coords`](nil_client::Client::get_bot_coords)
730#[unsafe(no_mangle)]
731pub unsafe extern "C" fn nil_get_bot_coords(request_id: RequestId, json_req: *const c_char) {
732  send!(request_id, get_bot_coords, json_req);
733}
734
735/// [`Client::get_chat_history`](nil_client::Client::get_chat_history)
736#[unsafe(no_mangle)]
737pub unsafe extern "C" fn nil_get_chat_history(request_id: RequestId, json_req: *const c_char) {
738  send!(request_id, get_chat_history, json_req);
739}
740
741/// [`Client::get_cities`](nil_client::Client::get_cities)
742#[unsafe(no_mangle)]
743pub unsafe extern "C" fn nil_get_cities(request_id: RequestId, json_req: *const c_char) {
744  send!(request_id, get_cities, json_req);
745}
746
747/// [`Client::get_city`](nil_client::Client::get_city)
748#[unsafe(no_mangle)]
749pub unsafe extern "C" fn nil_get_city(request_id: RequestId, json_req: *const c_char) {
750  send!(request_id, get_city, json_req);
751}
752
753/// [`Client::get_city_score`](nil_client::Client::get_city_score)
754#[unsafe(no_mangle)]
755pub unsafe extern "C" fn nil_get_city_score(request_id: RequestId, json_req: *const c_char) {
756  send!(request_id, get_city_score, json_req);
757}
758
759/// [`Client::get_continent_size`](nil_client::Client::get_continent_size)
760#[unsafe(no_mangle)]
761pub unsafe extern "C" fn nil_get_continent_size(request_id: RequestId, json_req: *const c_char) {
762  send!(request_id, get_continent_size, json_req);
763}
764
765/// [`Client::get_idle_armies_at`](nil_client::Client::get_idle_armies_at)
766#[unsafe(no_mangle)]
767pub unsafe extern "C" fn nil_get_idle_armies_at(request_id: RequestId, json_req: *const c_char) {
768  send!(request_id, get_idle_armies_at, json_req);
769}
770
771/// [`Client::get_idle_armies_coords`](nil_client::Client::get_idle_armies_coords)
772#[unsafe(no_mangle)]
773pub unsafe extern "C" fn nil_get_idle_armies_coords(
774  request_id: RequestId,
775  json_req: *const c_char,
776) {
777  send!(request_id, get_idle_armies_coords, json_req);
778}
779
780/// [`Client::get_maneuver`](nil_client::Client::get_maneuver)
781#[unsafe(no_mangle)]
782pub unsafe extern "C" fn nil_get_maneuver(request_id: RequestId, json_req: *const c_char) {
783  send!(request_id, get_maneuver, json_req);
784}
785
786/// [`Client::get_market`](nil_client::Client::get_market)
787#[unsafe(no_mangle)]
788pub unsafe extern "C" fn nil_get_market(request_id: RequestId, json_req: *const c_char) {
789  send!(request_id, get_market, json_req);
790}
791
792/// [`Client::get_market_fee`](nil_client::Client::get_market_fee)
793#[unsafe(no_mangle)]
794pub unsafe extern "C" fn nil_get_market_fee(request_id: RequestId, json_req: *const c_char) {
795  send!(request_id, get_market_fee, json_req);
796}
797
798/// [`Client::get_player`](nil_client::Client::get_player)
799#[unsafe(no_mangle)]
800pub unsafe extern "C" fn nil_get_player(request_id: RequestId, json_req: *const c_char) {
801  send!(request_id, get_player, json_req);
802}
803
804/// [`Client::get_player_coords`](nil_client::Client::get_player_coords)
805#[unsafe(no_mangle)]
806pub unsafe extern "C" fn nil_get_player_coords(request_id: RequestId, json_req: *const c_char) {
807  send!(request_id, get_player_coords, json_req);
808}
809
810/// [`Client::get_player_ids`](nil_client::Client::get_player_ids)
811#[unsafe(no_mangle)]
812pub unsafe extern "C" fn nil_get_player_ids(request_id: RequestId, json_req: *const c_char) {
813  send!(request_id, get_player_ids, json_req);
814}
815
816/// [`Client::get_player_maintenance`](nil_client::Client::get_player_maintenance)
817#[unsafe(no_mangle)]
818pub unsafe extern "C" fn nil_get_player_maintenance(
819  request_id: RequestId,
820  json_req: *const c_char,
821) {
822  send!(request_id, get_player_maintenance, json_req);
823}
824
825/// [`Client::get_player_military`](nil_client::Client::get_player_military)
826#[unsafe(no_mangle)]
827pub unsafe extern "C" fn nil_get_player_military(request_id: RequestId, json_req: *const c_char) {
828  send!(request_id, get_player_military, json_req);
829}
830
831/// [`Client::get_player_status`](nil_client::Client::get_player_status)
832#[unsafe(no_mangle)]
833pub unsafe extern "C" fn nil_get_player_status(request_id: RequestId, json_req: *const c_char) {
834  send!(request_id, get_player_status, json_req);
835}
836
837/// [`Client::get_player_storage_capacity`](nil_client::Client::get_player_storage_capacity)
838#[unsafe(no_mangle)]
839pub unsafe extern "C" fn nil_get_player_storage_capacity(
840  request_id: RequestId,
841  json_req: *const c_char,
842) {
843  send!(request_id, get_player_storage_capacity, json_req);
844}
845
846/// [`Client::get_player_worlds`](nil_client::Client::get_player_worlds)
847#[unsafe(no_mangle)]
848pub unsafe extern "C" fn nil_get_player_worlds(request_id: RequestId, json_req: *const c_char) {
849  send!(request_id, get_player_worlds, json_req);
850}
851
852/// [`Client::get_precursor_coords`](nil_client::Client::get_precursor_coords)
853#[unsafe(no_mangle)]
854pub unsafe extern "C" fn nil_get_precursor_coords(request_id: RequestId, json_req: *const c_char) {
855  send!(request_id, get_precursor_coords, json_req);
856}
857
858/// [`Client::get_prefecture_build_catalog`](nil_client::Client::get_prefecture_build_catalog)
859#[unsafe(no_mangle)]
860pub unsafe extern "C" fn nil_get_prefecture_build_catalog(
861  request_id: RequestId,
862  json_req: *const c_char,
863) {
864  send!(request_id, get_prefecture_build_catalog, json_req);
865}
866
867/// [`Client::get_public_bot`](nil_client::Client::get_public_bot)
868#[unsafe(no_mangle)]
869pub unsafe extern "C" fn nil_get_public_bot(request_id: RequestId, json_req: *const c_char) {
870  send!(request_id, get_public_bot, json_req);
871}
872
873/// [`Client::get_public_bots`](nil_client::Client::get_public_bots)
874#[unsafe(no_mangle)]
875pub unsafe extern "C" fn nil_get_public_bots(request_id: RequestId, json_req: *const c_char) {
876  send!(request_id, get_public_bots, json_req);
877}
878
879/// [`Client::get_public_cities`](nil_client::Client::get_public_cities)
880#[unsafe(no_mangle)]
881pub unsafe extern "C" fn nil_get_public_cities(request_id: RequestId, json_req: *const c_char) {
882  send!(request_id, get_public_cities, json_req);
883}
884
885/// [`Client::get_public_city`](nil_client::Client::get_public_city)
886#[unsafe(no_mangle)]
887pub unsafe extern "C" fn nil_get_public_city(request_id: RequestId, json_req: *const c_char) {
888  send!(request_id, get_public_city, json_req);
889}
890
891/// [`Client::get_public_field`](nil_client::Client::get_public_field)
892#[unsafe(no_mangle)]
893pub unsafe extern "C" fn nil_get_public_field(request_id: RequestId, json_req: *const c_char) {
894  send!(request_id, get_public_field, json_req);
895}
896
897/// [`Client::get_public_fields`](nil_client::Client::get_public_fields)
898#[unsafe(no_mangle)]
899pub unsafe extern "C" fn nil_get_public_fields(request_id: RequestId, json_req: *const c_char) {
900  send!(request_id, get_public_fields, json_req);
901}
902
903/// [`Client::get_public_player`](nil_client::Client::get_public_player)
904#[unsafe(no_mangle)]
905pub unsafe extern "C" fn nil_get_public_player(request_id: RequestId, json_req: *const c_char) {
906  send!(request_id, get_public_player, json_req);
907}
908
909/// [`Client::get_public_players`](nil_client::Client::get_public_players)
910#[unsafe(no_mangle)]
911pub unsafe extern "C" fn nil_get_public_players(request_id: RequestId, json_req: *const c_char) {
912  send!(request_id, get_public_players, json_req);
913}
914
915/// [`Client::get_public_precursor`](nil_client::Client::get_public_precursor)
916#[unsafe(no_mangle)]
917pub unsafe extern "C" fn nil_get_public_precursor(request_id: RequestId, json_req: *const c_char) {
918  send!(request_id, get_public_precursor, json_req);
919}
920
921/// [`Client::get_public_precursors`](nil_client::Client::get_public_precursors)
922#[unsafe(no_mangle)]
923pub unsafe extern "C" fn nil_get_public_precursors(request_id: RequestId, json_req: *const c_char) {
924  send!(request_id, get_public_precursors, json_req);
925}
926
927/// [`Client::get_rank`](nil_client::Client::get_rank)
928#[unsafe(no_mangle)]
929pub unsafe extern "C" fn nil_get_rank(request_id: RequestId, json_req: *const c_char) {
930  send!(request_id, get_rank, json_req);
931}
932
933/// [`Client::get_ranking`](nil_client::Client::get_ranking)
934#[unsafe(no_mangle)]
935pub unsafe extern "C" fn nil_get_ranking(request_id: RequestId, json_req: *const c_char) {
936  send!(request_id, get_ranking, json_req);
937}
938
939/// [`Client::get_remote_world`](nil_client::Client::get_remote_world)
940#[unsafe(no_mangle)]
941pub unsafe extern "C" fn nil_get_remote_world(request_id: RequestId, json_req: *const c_char) {
942  send!(request_id, get_remote_world, json_req);
943}
944
945/// [`Client::get_remote_world_limit`](nil_client::Client::get_remote_world_limit)
946#[unsafe(no_mangle)]
947pub unsafe extern "C" fn nil_get_remote_world_limit(request_id: RequestId) {
948  send!(request_id, get_remote_world_limit);
949}
950
951/// [`Client::get_remote_world_limit_per_user`](nil_client::Client::get_remote_world_limit_per_user)
952#[unsafe(no_mangle)]
953pub unsafe extern "C" fn nil_get_remote_world_limit_per_user(request_id: RequestId) {
954  send!(request_id, get_remote_world_limit_per_user);
955}
956
957/// [`Client::get_remote_worlds`](nil_client::Client::get_remote_worlds)
958#[unsafe(no_mangle)]
959pub unsafe extern "C" fn nil_get_remote_worlds(request_id: RequestId) {
960  send!(request_id, get_remote_worlds);
961}
962
963/// [`Client::get_round`](nil_client::Client::get_round)
964#[unsafe(no_mangle)]
965pub unsafe extern "C" fn nil_get_round(request_id: RequestId, json_req: *const c_char) {
966  send!(request_id, get_round, json_req);
967}
968
969/// [`Client::get_server_kind`](nil_client::Client::get_server_kind)
970#[unsafe(no_mangle)]
971pub unsafe extern "C" fn nil_get_server_kind(request_id: RequestId) {
972  send!(request_id, get_server_kind);
973}
974
975/// [`Client::get_stable_recruit_catalog`](nil_client::Client::get_stable_recruit_catalog)
976#[unsafe(no_mangle)]
977pub unsafe extern "C" fn nil_get_stable_recruit_catalog(
978  request_id: RequestId,
979  json_req: *const c_char,
980) {
981  send!(request_id, get_stable_recruit_catalog, json_req);
982}
983
984/// [`Client::get_workshop_recruit_catalog`](nil_client::Client::get_workshop_recruit_catalog)
985#[unsafe(no_mangle)]
986pub unsafe extern "C" fn nil_get_workshop_recruit_catalog(
987  request_id: RequestId,
988  json_req: *const c_char,
989) {
990  send!(request_id, get_workshop_recruit_catalog, json_req);
991}
992
993/// [`Client::get_world_bots`](nil_client::Client::get_world_bots)
994#[unsafe(no_mangle)]
995pub unsafe extern "C" fn nil_get_world_bots(request_id: RequestId, json_req: *const c_char) {
996  send!(request_id, get_world_bots, json_req);
997}
998
999/// [`Client::get_world_config`](nil_client::Client::get_world_config)
1000#[unsafe(no_mangle)]
1001pub unsafe extern "C" fn nil_get_world_config(request_id: RequestId, json_req: *const c_char) {
1002  send!(request_id, get_world_config, json_req);
1003}
1004
1005/// [`Client::get_world_personnel`](nil_client::Client::get_world_personnel)
1006#[unsafe(no_mangle)]
1007pub unsafe extern "C" fn nil_get_world_personnel(request_id: RequestId, json_req: *const c_char) {
1008  send!(request_id, get_world_personnel, json_req);
1009}
1010
1011/// [`Client::get_world_players`](nil_client::Client::get_world_players)
1012#[unsafe(no_mangle)]
1013pub unsafe extern "C" fn nil_get_world_players(request_id: RequestId, json_req: *const c_char) {
1014  send!(request_id, get_world_players, json_req);
1015}
1016
1017/// [`Client::get_world_precursors`](nil_client::Client::get_world_precursors)
1018#[unsafe(no_mangle)]
1019pub unsafe extern "C" fn nil_get_world_precursors(request_id: RequestId, json_req: *const c_char) {
1020  send!(request_id, get_world_precursors, json_req);
1021}
1022
1023/// [`Client::get_world_rulers`](nil_client::Client::get_world_rulers)
1024#[unsafe(no_mangle)]
1025pub unsafe extern "C" fn nil_get_world_rulers(request_id: RequestId, json_req: *const c_char) {
1026  send!(request_id, get_world_rulers, json_req);
1027}
1028
1029/// [`Client::get_world_stats`](nil_client::Client::get_world_stats)
1030#[unsafe(no_mangle)]
1031pub unsafe extern "C" fn nil_get_world_stats(request_id: RequestId, json_req: *const c_char) {
1032  send!(request_id, get_world_stats, json_req);
1033}
1034
1035/// [`Client::player_exists`](nil_client::Client::player_exists)
1036#[unsafe(no_mangle)]
1037pub unsafe extern "C" fn nil_player_exists(request_id: RequestId, json_req: *const c_char) {
1038  send!(request_id, player_exists, json_req);
1039}
1040
1041/// [`Client::push_chat_message`](nil_client::Client::push_chat_message)
1042#[unsafe(no_mangle)]
1043pub unsafe extern "C" fn nil_push_chat_message(request_id: RequestId, json_req: *const c_char) {
1044  send!(request_id, push_chat_message, json_req);
1045}
1046
1047/// [`Client::rename_city`](nil_client::Client::rename_city)
1048#[unsafe(no_mangle)]
1049pub unsafe extern "C" fn nil_rename_city(request_id: RequestId, json_req: *const c_char) {
1050  send!(request_id, rename_city, json_req);
1051}
1052
1053/// [`Client::request_maneuver`](nil_client::Client::request_maneuver)
1054#[unsafe(no_mangle)]
1055pub unsafe extern "C" fn nil_request_maneuver(request_id: RequestId, json_req: *const c_char) {
1056  send!(request_id, request_maneuver, json_req);
1057}
1058
1059/// [`Client::save_local_world`](nil_client::Client::save_local_world)
1060#[unsafe(no_mangle)]
1061pub unsafe extern "C" fn nil_save_local_world(request_id: RequestId, json_req: *const c_char) {
1062  send!(request_id, save_local_world, json_req);
1063}
1064
1065/// [`Client::search_city`](nil_client::Client::search_city)
1066#[unsafe(no_mangle)]
1067pub unsafe extern "C" fn nil_search_city(request_id: RequestId, json_req: *const c_char) {
1068  send!(request_id, search_city, json_req);
1069}
1070
1071/// [`Client::search_public_city`](nil_client::Client::search_public_city)
1072#[unsafe(no_mangle)]
1073pub unsafe extern "C" fn nil_search_public_city(request_id: RequestId, json_req: *const c_char) {
1074  send!(request_id, search_public_city, json_req);
1075}
1076
1077/// [`Client::sell_resources`](nil_client::Client::sell_resources)
1078#[unsafe(no_mangle)]
1079pub unsafe extern "C" fn nil_sell_resources(request_id: RequestId, json_req: *const c_char) {
1080  send!(request_id, sell_resources, json_req);
1081}
1082
1083/// [`Client::send_resources`](nil_client::Client::send_resources)
1084#[unsafe(no_mangle)]
1085pub unsafe extern "C" fn nil_send_resources(request_id: RequestId, json_req: *const c_char) {
1086  send!(request_id, send_resources, json_req);
1087}
1088
1089/// [`Client::version`](nil_client::Client::version)
1090#[unsafe(no_mangle)]
1091pub unsafe extern "C" fn nil_server_version(request_id: RequestId) {
1092  send!(request_id, version);
1093}
1094
1095/// [`Client::set_player_ready`](nil_client::Client::set_player_ready)
1096#[unsafe(no_mangle)]
1097pub unsafe extern "C" fn nil_set_player_ready(request_id: RequestId, json_req: *const c_char) {
1098  send!(request_id, set_player_ready, json_req);
1099}
1100
1101/// [`Client::set_player_status`](nil_client::Client::set_player_status)
1102#[unsafe(no_mangle)]
1103pub unsafe extern "C" fn nil_set_player_status(request_id: RequestId, json_req: *const c_char) {
1104  send!(request_id, set_player_status, json_req);
1105}
1106
1107/// [`Client::simulate_battle`](nil_client::Client::simulate_battle)
1108#[unsafe(no_mangle)]
1109pub unsafe extern "C" fn nil_simulate_battle(request_id: RequestId, json_req: *const c_char) {
1110  send!(request_id, simulate_battle, json_req);
1111}
1112
1113/// [`Client::spawn_player`](nil_client::Client::spawn_player)
1114#[unsafe(no_mangle)]
1115pub unsafe extern "C" fn nil_spawn_player(request_id: RequestId, json_req: *const c_char) {
1116  send!(request_id, spawn_player, json_req);
1117}
1118
1119/// [`Client::start_round`](nil_client::Client::start_round)
1120#[unsafe(no_mangle)]
1121pub unsafe extern "C" fn nil_start_round(request_id: RequestId, json_req: *const c_char) {
1122  send!(request_id, start_round, json_req);
1123}
1124
1125/// [`Client::toggle_building`](nil_client::Client::toggle_building)
1126#[unsafe(no_mangle)]
1127pub unsafe extern "C" fn nil_toggle_building(request_id: RequestId, json_req: *const c_char) {
1128  send!(request_id, toggle_building, json_req);
1129}
1130
1131/// [`Client::user_exists`](nil_client::Client::user_exists)
1132#[unsafe(no_mangle)]
1133pub unsafe extern "C" fn nil_user_exists(request_id: RequestId, json_req: *const c_char) {
1134  send!(request_id, user_exists, json_req);
1135}
1136
1137/// [`Client::validate_token`](nil_client::Client::validate_token)
1138#[unsafe(no_mangle)]
1139pub unsafe extern "C" fn nil_validate_token(request_id: RequestId, json_req: *const c_char) {
1140  send!(request_id, validate_token, json_req);
1141}