Skip to main content

wackasm_opencomputers/
components.rs

1// @generated by tools/gen_components.py from OpenComputers' @Callback
2// annotations (tools/callbacks.json). Do not edit by hand; regenerate.
3
4//! Typed wrappers for every OpenComputers component.
5//!
6//! One struct per component type, one method per callback. The docs on
7//! each method are OpenComputers' own, followed by the Lua signature.
8//! Find components with [`Component::first`] or [`Component::all`].
9//! With the `async` feature, each method also has an `_async` twin that
10//! doesn't block (see `crate::task`).
11
12#![allow(clippy::too_many_arguments)]
13
14use crate::{
15    component::{Address, Component, FromReply, args, single},
16    error::Result,
17    value::{Handle, Number, OcString, Value},
18};
19
20/// The `assembler` component (2 methods).
21///
22/// Provided by OpenComputers' `Assembler`.
23#[derive(Clone, Debug, PartialEq, Eq, Hash)]
24pub struct Assembler(pub Address);
25
26impl Component for Assembler {
27    const KIND: &'static str = "assembler";
28    fn from_address(address: Address) -> Self {
29        Self(address)
30    }
31    fn address(&self) -> &Address {
32        &self.0
33    }
34}
35
36impl Assembler {
37    /// Start assembling, if possible. Returns whether assembly was started or not.
38    ///
39    /// Lua: `assembler.start():boolean`
40    /// Indirect call: waits for the next server tick.
41    pub fn start(&self) -> Result<bool> {
42        let args = args(vec![]);
43        let reply = self.invoke("start", args)?;
44        single::<bool>(reply)
45    }
46
47    /// [`Self::start`] without blocking: the call is queued, and
48    /// the program keeps running until the result comes back; see [`crate::task`].
49    #[cfg(feature = "async")]
50    pub async fn start_async(&self) -> Result<bool> {
51        let args = args(vec![]);
52        let reply = self.invoke_async("start", args).await?;
53        single::<bool>(reply)
54    }
55
56    /// The current state of the assembler, `busy' or `idle', followed by the progress or template validity, respectively.
57    ///
58    /// Lua: `assembler.status(): string, number or boolean`
59    /// Indirect call: waits for the next server tick.
60    pub fn status(&self) -> Result<(OcString, Value)> {
61        let args = args(vec![]);
62        let reply = self.invoke("status", args)?;
63        FromReply::from_reply(reply)
64    }
65
66    /// [`Self::status`] without blocking: the call is queued, and
67    /// the program keeps running until the result comes back; see [`crate::task`].
68    #[cfg(feature = "async")]
69    pub async fn status_async(&self) -> Result<(OcString, Value)> {
70        let args = args(vec![]);
71        let reply = self.invoke_async("status", args).await?;
72        FromReply::from_reply(reply)
73    }
74}
75
76/// The `barcode_reader` component (0 methods).
77///
78/// Provided by OpenComputers' `UpgradeBarcodeReader`.
79#[derive(Clone, Debug, PartialEq, Eq, Hash)]
80pub struct BarcodeReader(pub Address);
81
82impl Component for BarcodeReader {
83    const KIND: &'static str = "barcode_reader";
84    fn from_address(address: Address) -> Self {
85        Self(address)
86    }
87    fn address(&self) -> &Address {
88        &self.0
89    }
90}
91
92/// The `beacon` component (3 methods).
93///
94/// Provided by OpenComputers' `DriverBeacon$Environment`.
95#[derive(Clone, Debug, PartialEq, Eq, Hash)]
96pub struct Beacon(pub Address);
97
98impl Component for Beacon {
99    const KIND: &'static str = "beacon";
100    fn from_address(address: Address) -> Self {
101        Self(address)
102    }
103    fn address(&self) -> &Address {
104        &self.0
105    }
106}
107
108impl Beacon {
109    /// Get the number of levels for this beacon.
110    ///
111    /// Lua: `beacon.getLevels():number`
112    /// Indirect call: waits for the next server tick.
113    pub fn get_levels(&self) -> Result<Number> {
114        let args = args(vec![]);
115        let reply = self.invoke("getLevels", args)?;
116        single::<Number>(reply)
117    }
118
119    /// [`Self::get_levels`] without blocking: the call is queued, and
120    /// the program keeps running until the result comes back; see [`crate::task`].
121    #[cfg(feature = "async")]
122    pub async fn get_levels_async(&self) -> Result<Number> {
123        let args = args(vec![]);
124        let reply = self.invoke_async("getLevels", args).await?;
125        single::<Number>(reply)
126    }
127
128    /// Get the name of the active primary effect.
129    ///
130    /// Lua: `beacon.getPrimaryEffect():string`
131    /// Indirect call: waits for the next server tick.
132    pub fn get_primary_effect(&self) -> Result<OcString> {
133        let args = args(vec![]);
134        let reply = self.invoke("getPrimaryEffect", args)?;
135        single::<OcString>(reply)
136    }
137
138    /// [`Self::get_primary_effect`] without blocking: the call is queued, and
139    /// the program keeps running until the result comes back; see [`crate::task`].
140    #[cfg(feature = "async")]
141    pub async fn get_primary_effect_async(&self) -> Result<OcString> {
142        let args = args(vec![]);
143        let reply = self.invoke_async("getPrimaryEffect", args).await?;
144        single::<OcString>(reply)
145    }
146
147    /// Get the name of the active secondary effect.
148    ///
149    /// Lua: `beacon.getSecondaryEffect():string`
150    /// Indirect call: waits for the next server tick.
151    pub fn get_secondary_effect(&self) -> Result<OcString> {
152        let args = args(vec![]);
153        let reply = self.invoke("getSecondaryEffect", args)?;
154        single::<OcString>(reply)
155    }
156
157    /// [`Self::get_secondary_effect`] without blocking: the call is queued, and
158    /// the program keeps running until the result comes back; see [`crate::task`].
159    #[cfg(feature = "async")]
160    pub async fn get_secondary_effect_async(&self) -> Result<OcString> {
161        let args = args(vec![]);
162        let reply = self.invoke_async("getSecondaryEffect", args).await?;
163        single::<OcString>(reply)
164    }
165}
166
167/// The `brewing_stand` component (1 methods).
168///
169/// Provided by OpenComputers' `DriverBrewingStand$Environment`.
170#[derive(Clone, Debug, PartialEq, Eq, Hash)]
171pub struct BrewingStand(pub Address);
172
173impl Component for BrewingStand {
174    const KIND: &'static str = "brewing_stand";
175    fn from_address(address: Address) -> Self {
176        Self(address)
177    }
178    fn address(&self) -> &Address {
179        &self.0
180    }
181}
182
183impl BrewingStand {
184    /// Get the number of ticks remaining of the current brewing operation.
185    ///
186    /// Lua: `brewing_stand.getBrewTime():number`
187    /// Indirect call: waits for the next server tick.
188    pub fn get_brew_time(&self) -> Result<Number> {
189        let args = args(vec![]);
190        let reply = self.invoke("getBrewTime", args)?;
191        single::<Number>(reply)
192    }
193
194    /// [`Self::get_brew_time`] without blocking: the call is queued, and
195    /// the program keeps running until the result comes back; see [`crate::task`].
196    #[cfg(feature = "async")]
197    pub async fn get_brew_time_async(&self) -> Result<Number> {
198        let args = args(vec![]);
199        let reply = self.invoke_async("getBrewTime", args).await?;
200        single::<Number>(reply)
201    }
202}
203
204/// The `chunkloader` component (2 methods).
205///
206/// Provided by OpenComputers' `UpgradeChunkloader, UpgradeChunkloaderBase`.
207#[derive(Clone, Debug, PartialEq, Eq, Hash)]
208pub struct Chunkloader(pub Address);
209
210impl Component for Chunkloader {
211    const KIND: &'static str = "chunkloader";
212    fn from_address(address: Address) -> Self {
213        Self(address)
214    }
215    fn address(&self) -> &Address {
216        &self.0
217    }
218}
219
220impl Chunkloader {
221    /// Gets whether the chunkloader is currently active.
222    ///
223    /// Lua: `chunkloader.isActive():boolean`
224    /// Indirect call: waits for the next server tick.
225    pub fn is_active(&self) -> Result<bool> {
226        let args = args(vec![]);
227        let reply = self.invoke("isActive", args)?;
228        single::<bool>(reply)
229    }
230
231    /// [`Self::is_active`] without blocking: the call is queued, and
232    /// the program keeps running until the result comes back; see [`crate::task`].
233    #[cfg(feature = "async")]
234    pub async fn is_active_async(&self) -> Result<bool> {
235        let args = args(vec![]);
236        let reply = self.invoke_async("isActive", args).await?;
237        single::<bool>(reply)
238    }
239
240    /// Enables or disables the chunkloader, returns true if active changed
241    ///
242    /// Lua: `chunkloader.setActive(enabled:boolean):boolean`
243    /// Indirect call: waits for the next server tick.
244    pub fn set_active(&self, enabled: bool) -> Result<bool> {
245        let args = args(vec![Some(Value::Bool(enabled))]);
246        let reply = self.invoke("setActive", args)?;
247        single::<bool>(reply)
248    }
249
250    /// [`Self::set_active`] without blocking: the call is queued, and
251    /// the program keeps running until the result comes back; see [`crate::task`].
252    #[cfg(feature = "async")]
253    pub async fn set_active_async(&self, enabled: bool) -> Result<bool> {
254        let args = args(vec![Some(Value::Bool(enabled))]);
255        let reply = self.invoke_async("setActive", args).await?;
256        single::<bool>(reply)
257    }
258}
259
260/// The `command_block` component (3 methods).
261///
262/// Provided by OpenComputers' `DriverCommandBlock$Environment`.
263#[derive(Clone, Debug, PartialEq, Eq, Hash)]
264pub struct CommandBlock(pub Address);
265
266impl Component for CommandBlock {
267    const KIND: &'static str = "command_block";
268    fn from_address(address: Address) -> Self {
269        Self(address)
270    }
271    fn address(&self) -> &Address {
272        &self.0
273    }
274}
275
276impl CommandBlock {
277    /// Execute the currently set command. This has a slight delay to allow the command block to properly update.
278    ///
279    /// Lua: `command_block.executeCommand():number`
280    /// Indirect call: waits for the next server tick.
281    pub fn execute_command(&self) -> Result<Number> {
282        let args = args(vec![]);
283        let reply = self.invoke("executeCommand", args)?;
284        single::<Number>(reply)
285    }
286
287    /// [`Self::execute_command`] without blocking: the call is queued, and
288    /// the program keeps running until the result comes back; see [`crate::task`].
289    #[cfg(feature = "async")]
290    pub async fn execute_command_async(&self) -> Result<Number> {
291        let args = args(vec![]);
292        let reply = self.invoke_async("executeCommand", args).await?;
293        single::<Number>(reply)
294    }
295
296    /// Get the command currently set in this command block.
297    ///
298    /// Lua: `command_block.getCommand():string`
299    /// Direct call (runs immediately, drawing on the per-tick budget).
300    pub fn get_command(&self) -> Result<OcString> {
301        let args = args(vec![]);
302        let reply = self.invoke("getCommand", args)?;
303        single::<OcString>(reply)
304    }
305
306    /// [`Self::get_command`] without blocking: the call is queued, and
307    /// the program keeps running until the result comes back; see [`crate::task`].
308    #[cfg(feature = "async")]
309    pub async fn get_command_async(&self) -> Result<OcString> {
310        let args = args(vec![]);
311        let reply = self.invoke_async("getCommand", args).await?;
312        single::<OcString>(reply)
313    }
314
315    /// Set the specified command for the command block.
316    ///
317    /// Lua: `command_block.setCommand(value:string)`
318    /// Indirect call: waits for the next server tick.
319    pub fn set_command(&self, value: impl AsRef<[u8]>) -> Result<()> {
320        let args = args(vec![Some(Value::text(value.as_ref()))]);
321        let reply = self.invoke("setCommand", args)?;
322        FromReply::from_reply(reply)
323    }
324
325    /// [`Self::set_command`] without blocking: the call is queued, and
326    /// the program keeps running until the result comes back; see [`crate::task`].
327    #[cfg(feature = "async")]
328    pub async fn set_command_async(&self, value: impl AsRef<[u8]>) -> Result<()> {
329        let args = args(vec![Some(Value::text(value.as_ref()))]);
330        let reply = self.invoke_async("setCommand", args).await?;
331        FromReply::from_reply(reply)
332    }
333}
334
335/// The `comparator` component (1 methods).
336///
337/// Provided by OpenComputers' `DriverComparator$Environment`.
338#[derive(Clone, Debug, PartialEq, Eq, Hash)]
339pub struct Comparator(pub Address);
340
341impl Component for Comparator {
342    const KIND: &'static str = "comparator";
343    fn from_address(address: Address) -> Self {
344        Self(address)
345    }
346    fn address(&self) -> &Address {
347        &self.0
348    }
349}
350
351impl Comparator {
352    /// Get the strength of the comparators output signal.
353    ///
354    /// Lua: `comparator.getOutputSignal():number`
355    /// Indirect call: waits for the next server tick.
356    pub fn get_output_signal(&self) -> Result<Number> {
357        let args = args(vec![]);
358        let reply = self.invoke("getOutputSignal", args)?;
359        single::<Number>(reply)
360    }
361
362    /// [`Self::get_output_signal`] without blocking: the call is queued, and
363    /// the program keeps running until the result comes back; see [`crate::task`].
364    #[cfg(feature = "async")]
365    pub async fn get_output_signal_async(&self) -> Result<Number> {
366        let args = args(vec![]);
367        let reply = self.invoke_async("getOutputSignal", args).await?;
368        single::<Number>(reply)
369    }
370}
371
372/// The `computer` component (6 methods).
373///
374/// Provided by OpenComputers' `MachineBase`.
375#[derive(Clone, Debug, PartialEq, Eq, Hash)]
376pub struct Computer(pub Address);
377
378impl Component for Computer {
379    const KIND: &'static str = "computer";
380    fn from_address(address: Address) -> Self {
381        Self(address)
382    }
383    fn address(&self) -> &Address {
384        &self.0
385    }
386}
387
388impl Computer {
389    /// Plays a tone, useful to alert users via audible feedback.
390    ///
391    /// Lua: `computer.beep([frequency:string or number[, duration:number]])`
392    /// Indirect call: waits for the next server tick.
393    pub fn beep(&self, frequency: Option<Value>, duration: Option<Number>) -> Result<()> {
394        let args = args(vec![frequency, duration.map(Value::Number)]);
395        let reply = self.invoke("beep", args)?;
396        FromReply::from_reply(reply)
397    }
398
399    /// [`Self::beep`] without blocking: the call is queued, and
400    /// the program keeps running until the result comes back; see [`crate::task`].
401    #[cfg(feature = "async")]
402    pub async fn beep_async(&self, frequency: Option<Value>, duration: Option<Number>) -> Result<()> {
403        let args = args(vec![frequency, duration.map(Value::Number)]);
404        let reply = self.invoke_async("beep", args).await?;
405        FromReply::from_reply(reply)
406    }
407
408    /// Collect information on all connected devices.
409    ///
410    /// Lua: `computer.getDeviceInfo():table`
411    /// Indirect call: waits for the next server tick.
412    pub fn get_device_info(&self) -> Result<Value> {
413        let args = args(vec![]);
414        let reply = self.invoke("getDeviceInfo", args)?;
415        single::<Value>(reply)
416    }
417
418    /// [`Self::get_device_info`] without blocking: the call is queued, and
419    /// the program keeps running until the result comes back; see [`crate::task`].
420    #[cfg(feature = "async")]
421    pub async fn get_device_info_async(&self) -> Result<Value> {
422        let args = args(vec![]);
423        let reply = self.invoke_async("getDeviceInfo", args).await?;
424        single::<Value>(reply)
425    }
426
427    /// Returns a map of program name to disk label for known programs.
428    ///
429    /// Lua: `computer.getProgramLocations():table`
430    /// Indirect call: waits for the next server tick.
431    pub fn get_program_locations(&self) -> Result<Value> {
432        let args = args(vec![]);
433        let reply = self.invoke("getProgramLocations", args)?;
434        single::<Value>(reply)
435    }
436
437    /// [`Self::get_program_locations`] without blocking: the call is queued, and
438    /// the program keeps running until the result comes back; see [`crate::task`].
439    #[cfg(feature = "async")]
440    pub async fn get_program_locations_async(&self) -> Result<Value> {
441        let args = args(vec![]);
442        let reply = self.invoke_async("getProgramLocations", args).await?;
443        single::<Value>(reply)
444    }
445
446    /// Returns whether the computer is running.
447    ///
448    /// Lua: `computer.isRunning():boolean`
449    /// Direct call (runs immediately, drawing on the per-tick budget).
450    pub fn is_running(&self) -> Result<bool> {
451        let args = args(vec![]);
452        let reply = self.invoke("isRunning", args)?;
453        single::<bool>(reply)
454    }
455
456    /// [`Self::is_running`] without blocking: the call is queued, and
457    /// the program keeps running until the result comes back; see [`crate::task`].
458    #[cfg(feature = "async")]
459    pub async fn is_running_async(&self) -> Result<bool> {
460        let args = args(vec![]);
461        let reply = self.invoke_async("isRunning", args).await?;
462        single::<bool>(reply)
463    }
464
465    /// Starts the computer. Returns true if the state changed.
466    ///
467    /// Lua: `computer.start():boolean`
468    /// Indirect call: waits for the next server tick.
469    pub fn start(&self) -> Result<bool> {
470        let args = args(vec![]);
471        let reply = self.invoke("start", args)?;
472        single::<bool>(reply)
473    }
474
475    /// [`Self::start`] without blocking: the call is queued, and
476    /// the program keeps running until the result comes back; see [`crate::task`].
477    #[cfg(feature = "async")]
478    pub async fn start_async(&self) -> Result<bool> {
479        let args = args(vec![]);
480        let reply = self.invoke_async("start", args).await?;
481        single::<bool>(reply)
482    }
483
484    /// Stops the computer. Returns true if the state changed.
485    ///
486    /// Lua: `computer.stop():boolean`
487    /// Indirect call: waits for the next server tick.
488    pub fn stop(&self) -> Result<bool> {
489        let args = args(vec![]);
490        let reply = self.invoke("stop", args)?;
491        single::<bool>(reply)
492    }
493
494    /// [`Self::stop`] without blocking: the call is queued, and
495    /// the program keeps running until the result comes back; see [`crate::task`].
496    #[cfg(feature = "async")]
497    pub async fn stop_async(&self) -> Result<bool> {
498        let args = args(vec![]);
499        let reply = self.invoke_async("stop", args).await?;
500        single::<bool>(reply)
501    }
502}
503
504/// The `crafting` component (1 methods).
505///
506/// Provided by OpenComputers' `UpgradeCrafting, UpgradeCraftingBase`.
507#[derive(Clone, Debug, PartialEq, Eq, Hash)]
508pub struct Crafting(pub Address);
509
510impl Component for Crafting {
511    const KIND: &'static str = "crafting";
512    fn from_address(address: Address) -> Self {
513        Self(address)
514    }
515    fn address(&self) -> &Address {
516        &self.0
517    }
518}
519
520impl Crafting {
521    /// Tries to craft the specified number of items in the top left area of the inventory.
522    ///
523    /// Lua: `crafting.craft([count:number]):number`
524    /// Indirect call: waits for the next server tick.
525    pub fn craft(&self, count: Option<Number>) -> Result<Number> {
526        let args = args(vec![count.map(Value::Number)]);
527        let reply = self.invoke("craft", args)?;
528        single::<Number>(reply)
529    }
530
531    /// [`Self::craft`] without blocking: the call is queued, and
532    /// the program keeps running until the result comes back; see [`crate::task`].
533    #[cfg(feature = "async")]
534    pub async fn craft_async(&self, count: Option<Number>) -> Result<Number> {
535        let args = args(vec![count.map(Value::Number)]);
536        let reply = self.invoke_async("craft", args).await?;
537        single::<Number>(reply)
538    }
539}
540
541/// The `data` component (16 methods).
542///
543/// Provided by OpenComputers' `DataCard, DataCard$Tier1, DataCard$Tier2, DataCard$Tier3`.
544#[derive(Clone, Debug, PartialEq, Eq, Hash)]
545pub struct Data(pub Address);
546
547impl Component for Data {
548    const KIND: &'static str = "data";
549    fn from_address(address: Address) -> Self {
550        Self(address)
551    }
552    fn address(&self) -> &Address {
553        &self.0
554    }
555}
556
557impl Data {
558    /// Computes CRC-32 hash of the data. Result is binary data.
559    ///
560    /// Lua: `data.crc32(data:string):string`
561    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 32).
562    pub fn crc32(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
563        let args = args(vec![Some(Value::text(data.as_ref()))]);
564        let reply = self.invoke("crc32", args)?;
565        single::<OcString>(reply)
566    }
567
568    /// [`Self::crc32`] without blocking: the call is queued, and
569    /// the program keeps running until the result comes back; see [`crate::task`].
570    #[cfg(feature = "async")]
571    pub async fn crc32_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
572        let args = args(vec![Some(Value::text(data.as_ref()))]);
573        let reply = self.invoke_async("crc32", args).await?;
574        single::<OcString>(reply)
575    }
576
577    /// Applies base64 decoding to the data.
578    ///
579    /// Lua: `data.decode64(data:string):string`
580    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 32).
581    pub fn decode64(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
582        let args = args(vec![Some(Value::text(data.as_ref()))]);
583        let reply = self.invoke("decode64", args)?;
584        single::<OcString>(reply)
585    }
586
587    /// [`Self::decode64`] without blocking: the call is queued, and
588    /// the program keeps running until the result comes back; see [`crate::task`].
589    #[cfg(feature = "async")]
590    pub async fn decode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
591        let args = args(vec![Some(Value::text(data.as_ref()))]);
592        let reply = self.invoke_async("decode64", args).await?;
593        single::<OcString>(reply)
594    }
595
596    /// Decode gzipped binary NBT data.
597    ///
598    /// Lua: `data.decodeNBT(data:string):table`
599    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 32).
600    pub fn decode_nbt(&self, data: impl AsRef<[u8]>) -> Result<Value> {
601        let args = args(vec![Some(Value::text(data.as_ref()))]);
602        let reply = self.invoke("decodeNBT", args)?;
603        single::<Value>(reply)
604    }
605
606    /// [`Self::decode_nbt`] without blocking: the call is queued, and
607    /// the program keeps running until the result comes back; see [`crate::task`].
608    #[cfg(feature = "async")]
609    pub async fn decode_nbt_async(&self, data: impl AsRef<[u8]>) -> Result<Value> {
610        let args = args(vec![Some(Value::text(data.as_ref()))]);
611        let reply = self.invoke_async("decodeNBT", args).await?;
612        single::<Value>(reply)
613    }
614
615    /// Decrypt data with AES.
616    ///
617    /// Lua: `data.decrypt(data:string, key:string, iv:string):string`
618    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 8).
619    pub fn decrypt(&self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>) -> Result<OcString> {
620        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(key.as_ref())), Some(Value::text(iv.as_ref()))]);
621        let reply = self.invoke("decrypt", args)?;
622        single::<OcString>(reply)
623    }
624
625    /// [`Self::decrypt`] without blocking: the call is queued, and
626    /// the program keeps running until the result comes back; see [`crate::task`].
627    #[cfg(feature = "async")]
628    pub async fn decrypt_async(&self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>) -> Result<OcString> {
629        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(key.as_ref())), Some(Value::text(iv.as_ref()))]);
630        let reply = self.invoke_async("decrypt", args).await?;
631        single::<OcString>(reply)
632    }
633
634    /// Applies deflate compression to the data.
635    ///
636    /// Lua: `data.deflate(data:string):string`
637    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 4).
638    pub fn deflate(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
639        let args = args(vec![Some(Value::text(data.as_ref()))]);
640        let reply = self.invoke("deflate", args)?;
641        single::<OcString>(reply)
642    }
643
644    /// [`Self::deflate`] without blocking: the call is queued, and
645    /// the program keeps running until the result comes back; see [`crate::task`].
646    #[cfg(feature = "async")]
647    pub async fn deflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
648        let args = args(vec![Some(Value::text(data.as_ref()))]);
649        let reply = self.invoke_async("deflate", args).await?;
650        single::<OcString>(reply)
651    }
652
653    /// Restores key from its string representation.
654    ///
655    /// Lua: `data.deserializeKey(data:string, type:string):userdata`
656    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 8).
657    pub fn deserialize_key(&self, data: impl AsRef<[u8]>, r#type: impl AsRef<[u8]>) -> Result<Handle> {
658        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(r#type.as_ref()))]);
659        let reply = self.invoke("deserializeKey", args)?;
660        single::<Handle>(reply)
661    }
662
663    /// [`Self::deserialize_key`] without blocking: the call is queued, and
664    /// the program keeps running until the result comes back; see [`crate::task`].
665    #[cfg(feature = "async")]
666    pub async fn deserialize_key_async(&self, data: impl AsRef<[u8]>, r#type: impl AsRef<[u8]>) -> Result<Handle> {
667        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(r#type.as_ref()))]);
668        let reply = self.invoke_async("deserializeKey", args).await?;
669        single::<Handle>(reply)
670    }
671
672    /// Generates a shared key. ecdh(a.priv, b.pub) == ecdh(b.priv, a.pub)
673    ///
674    /// Lua: `data.ecdh(priv:userdata, pub:userdata):string`
675    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 1).
676    pub fn ecdh(&self, r#priv: Handle, r#pub: Handle) -> Result<OcString> {
677        let args = args(vec![Some(Value::Handle(r#priv)), Some(Value::Handle(r#pub))]);
678        let reply = self.invoke("ecdh", args)?;
679        single::<OcString>(reply)
680    }
681
682    /// [`Self::ecdh`] without blocking: the call is queued, and
683    /// the program keeps running until the result comes back; see [`crate::task`].
684    #[cfg(feature = "async")]
685    pub async fn ecdh_async(&self, r#priv: Handle, r#pub: Handle) -> Result<OcString> {
686        let args = args(vec![Some(Value::Handle(r#priv)), Some(Value::Handle(r#pub))]);
687        let reply = self.invoke_async("ecdh", args).await?;
688        single::<OcString>(reply)
689    }
690
691    /// Signs or verifies data.
692    ///
693    /// Lua: `data.ecdsa(data:string, key:userdata[, sig:string]):string or boolean`
694    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 1).
695    pub fn ecdsa(&self, data: impl AsRef<[u8]>, key: Handle, sig: Option<&str>) -> Result<Value> {
696        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::Handle(key)), sig.map(Value::from)]);
697        let reply = self.invoke("ecdsa", args)?;
698        single::<Value>(reply)
699    }
700
701    /// [`Self::ecdsa`] without blocking: the call is queued, and
702    /// the program keeps running until the result comes back; see [`crate::task`].
703    #[cfg(feature = "async")]
704    pub async fn ecdsa_async(&self, data: impl AsRef<[u8]>, key: Handle, sig: Option<&str>) -> Result<Value> {
705        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::Handle(key)), sig.map(Value::from)]);
706        let reply = self.invoke_async("ecdsa", args).await?;
707        single::<Value>(reply)
708    }
709
710    /// Applies base64 encoding to the data.
711    ///
712    /// Lua: `data.encode64(data:string):string`
713    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 32).
714    pub fn encode64(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
715        let args = args(vec![Some(Value::text(data.as_ref()))]);
716        let reply = self.invoke("encode64", args)?;
717        single::<OcString>(reply)
718    }
719
720    /// [`Self::encode64`] without blocking: the call is queued, and
721    /// the program keeps running until the result comes back; see [`crate::task`].
722    #[cfg(feature = "async")]
723    pub async fn encode64_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
724        let args = args(vec![Some(Value::text(data.as_ref()))]);
725        let reply = self.invoke_async("encode64", args).await?;
726        single::<OcString>(reply)
727    }
728
729    /// Encrypt data with AES. Result is binary data.
730    ///
731    /// Lua: `data.encrypt(data:string, key:string, iv:string):string`
732    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 8).
733    pub fn encrypt(&self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>) -> Result<OcString> {
734        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(key.as_ref())), Some(Value::text(iv.as_ref()))]);
735        let reply = self.invoke("encrypt", args)?;
736        single::<OcString>(reply)
737    }
738
739    /// [`Self::encrypt`] without blocking: the call is queued, and
740    /// the program keeps running until the result comes back; see [`crate::task`].
741    #[cfg(feature = "async")]
742    pub async fn encrypt_async(&self, data: impl AsRef<[u8]>, key: impl AsRef<[u8]>, iv: impl AsRef<[u8]>) -> Result<OcString> {
743        let args = args(vec![Some(Value::text(data.as_ref())), Some(Value::text(key.as_ref())), Some(Value::text(iv.as_ref()))]);
744        let reply = self.invoke_async("encrypt", args).await?;
745        single::<OcString>(reply)
746    }
747
748    /// Generates key pair. Returns: public, private keys. Allowed key lengths: 256, 384 bits.
749    ///
750    /// Lua: `data.generateKeyPair([bitLen:number]):userdata, userdata`
751    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 1).
752    pub fn generate_key_pair(&self, bit_len: Option<Number>) -> Result<(Handle, Handle)> {
753        let args = args(vec![bit_len.map(Value::Number)]);
754        let reply = self.invoke("generateKeyPair", args)?;
755        FromReply::from_reply(reply)
756    }
757
758    /// [`Self::generate_key_pair`] without blocking: the call is queued, and
759    /// the program keeps running until the result comes back; see [`crate::task`].
760    #[cfg(feature = "async")]
761    pub async fn generate_key_pair_async(&self, bit_len: Option<Number>) -> Result<(Handle, Handle)> {
762        let args = args(vec![bit_len.map(Value::Number)]);
763        let reply = self.invoke_async("generateKeyPair", args).await?;
764        FromReply::from_reply(reply)
765    }
766
767    /// The maximum size of data that can be passed to other functions of the card.
768    ///
769    /// Lua: `data.getLimit():number`
770    /// Direct call (runs immediately, drawing on the per-tick budget).
771    pub fn get_limit(&self) -> Result<Number> {
772        let args = args(vec![]);
773        let reply = self.invoke("getLimit", args)?;
774        single::<Number>(reply)
775    }
776
777    /// [`Self::get_limit`] without blocking: the call is queued, and
778    /// the program keeps running until the result comes back; see [`crate::task`].
779    #[cfg(feature = "async")]
780    pub async fn get_limit_async(&self) -> Result<Number> {
781        let args = args(vec![]);
782        let reply = self.invoke_async("getLimit", args).await?;
783        single::<Number>(reply)
784    }
785
786    /// Applies inflate decompression to the data.
787    ///
788    /// Lua: `data.inflate(data:string):string`
789    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 4).
790    pub fn inflate(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
791        let args = args(vec![Some(Value::text(data.as_ref()))]);
792        let reply = self.invoke("inflate", args)?;
793        single::<OcString>(reply)
794    }
795
796    /// [`Self::inflate`] without blocking: the call is queued, and
797    /// the program keeps running until the result comes back; see [`crate::task`].
798    #[cfg(feature = "async")]
799    pub async fn inflate_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
800        let args = args(vec![Some(Value::text(data.as_ref()))]);
801        let reply = self.invoke_async("inflate", args).await?;
802        single::<OcString>(reply)
803    }
804
805    /// Computes MD5 hash of the data. Result is binary data.
806    ///
807    /// Lua: `data.md5(data:string):string`
808    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 8).
809    pub fn md5(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
810        let args = args(vec![Some(Value::text(data.as_ref()))]);
811        let reply = self.invoke("md5", args)?;
812        single::<OcString>(reply)
813    }
814
815    /// [`Self::md5`] without blocking: the call is queued, and
816    /// the program keeps running until the result comes back; see [`crate::task`].
817    #[cfg(feature = "async")]
818    pub async fn md5_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
819        let args = args(vec![Some(Value::text(data.as_ref()))]);
820        let reply = self.invoke_async("md5", args).await?;
821        single::<OcString>(reply)
822    }
823
824    /// Generates secure random binary data.
825    ///
826    /// Lua: `data.random(len:number):string`
827    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 4).
828    pub fn random(&self, len: impl Into<Number>) -> Result<OcString> {
829        let args = args(vec![Some(Value::Number(len.into()))]);
830        let reply = self.invoke("random", args)?;
831        single::<OcString>(reply)
832    }
833
834    /// [`Self::random`] without blocking: the call is queued, and
835    /// the program keeps running until the result comes back; see [`crate::task`].
836    #[cfg(feature = "async")]
837    pub async fn random_async(&self, len: impl Into<Number>) -> Result<OcString> {
838        let args = args(vec![Some(Value::Number(len.into()))]);
839        let reply = self.invoke_async("random", args).await?;
840        single::<OcString>(reply)
841    }
842
843    /// Computes SHA2-256 hash of the data. Result is binary data.
844    ///
845    /// Lua: `data.sha256(data:string):string`
846    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 4).
847    pub fn sha256(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
848        let args = args(vec![Some(Value::text(data.as_ref()))]);
849        let reply = self.invoke("sha256", args)?;
850        single::<OcString>(reply)
851    }
852
853    /// [`Self::sha256`] without blocking: the call is queued, and
854    /// the program keeps running until the result comes back; see [`crate::task`].
855    #[cfg(feature = "async")]
856    pub async fn sha256_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
857        let args = args(vec![Some(Value::text(data.as_ref()))]);
858        let reply = self.invoke_async("sha256", args).await?;
859        single::<OcString>(reply)
860    }
861}
862
863/// The `database` component (7 methods).
864///
865/// Provided by OpenComputers' `UpgradeDatabase`.
866#[derive(Clone, Debug, PartialEq, Eq, Hash)]
867pub struct Database(pub Address);
868
869impl Component for Database {
870    const KIND: &'static str = "database";
871    fn from_address(address: Address) -> Self {
872        Self(address)
873    }
874    fn address(&self) -> &Address {
875        &self.0
876    }
877}
878
879impl Database {
880    /// Clears the specified slot. Returns true if there was something in the slot before.
881    ///
882    /// Lua: `database.clear(slot:number):boolean`
883    /// Indirect call: waits for the next server tick.
884    pub fn clear(&self, slot: impl Into<Number>) -> Result<bool> {
885        let args = args(vec![Some(Value::Number(slot.into()))]);
886        let reply = self.invoke("clear", args)?;
887        single::<bool>(reply)
888    }
889
890    /// [`Self::clear`] without blocking: the call is queued, and
891    /// the program keeps running until the result comes back; see [`crate::task`].
892    #[cfg(feature = "async")]
893    pub async fn clear_async(&self, slot: impl Into<Number>) -> Result<bool> {
894        let args = args(vec![Some(Value::Number(slot.into()))]);
895        let reply = self.invoke_async("clear", args).await?;
896        single::<bool>(reply)
897    }
898
899    /// Copies the data stored in this database to another database with the specified address.
900    ///
901    /// Lua: `database.clone(address:string):number`
902    /// Indirect call: waits for the next server tick.
903    pub fn clone(&self, address: impl AsRef<[u8]>) -> Result<Number> {
904        let args = args(vec![Some(Value::text(address.as_ref()))]);
905        let reply = self.invoke("clone", args)?;
906        single::<Number>(reply)
907    }
908
909    /// [`Self::clone`] without blocking: the call is queued, and
910    /// the program keeps running until the result comes back; see [`crate::task`].
911    #[cfg(feature = "async")]
912    pub async fn clone_async(&self, address: impl AsRef<[u8]>) -> Result<Number> {
913        let args = args(vec![Some(Value::text(address.as_ref()))]);
914        let reply = self.invoke_async("clone", args).await?;
915        single::<Number>(reply)
916    }
917
918    /// Computes a hash value for the item stack in the specified slot.
919    ///
920    /// Lua: `database.computeHash(slot:number):string`
921    /// Indirect call: waits for the next server tick.
922    pub fn compute_hash(&self, slot: impl Into<Number>) -> Result<OcString> {
923        let args = args(vec![Some(Value::Number(slot.into()))]);
924        let reply = self.invoke("computeHash", args)?;
925        single::<OcString>(reply)
926    }
927
928    /// [`Self::compute_hash`] without blocking: the call is queued, and
929    /// the program keeps running until the result comes back; see [`crate::task`].
930    #[cfg(feature = "async")]
931    pub async fn compute_hash_async(&self, slot: impl Into<Number>) -> Result<OcString> {
932        let args = args(vec![Some(Value::Number(slot.into()))]);
933        let reply = self.invoke_async("computeHash", args).await?;
934        single::<OcString>(reply)
935    }
936
937    /// Copies an entry to another slot, optionally to another database. Returns true if something was overwritten.
938    ///
939    /// Lua: `database.copy(fromSlot:number, toSlot:number[, address:string]):boolean`
940    /// Indirect call: waits for the next server tick.
941    pub fn copy(&self, from_slot: impl Into<Number>, to_slot: impl Into<Number>, address: Option<&str>) -> Result<bool> {
942        let args = args(vec![Some(Value::Number(from_slot.into())), Some(Value::Number(to_slot.into())), address.map(Value::from)]);
943        let reply = self.invoke("copy", args)?;
944        single::<bool>(reply)
945    }
946
947    /// [`Self::copy`] without blocking: the call is queued, and
948    /// the program keeps running until the result comes back; see [`crate::task`].
949    #[cfg(feature = "async")]
950    pub async fn copy_async(&self, from_slot: impl Into<Number>, to_slot: impl Into<Number>, address: Option<&str>) -> Result<bool> {
951        let args = args(vec![Some(Value::Number(from_slot.into())), Some(Value::Number(to_slot.into())), address.map(Value::from)]);
952        let reply = self.invoke_async("copy", args).await?;
953        single::<bool>(reply)
954    }
955
956    /// Get the representation of the item stack stored in the specified slot.
957    ///
958    /// Lua: `database.get(slot:number):table`
959    /// Indirect call: waits for the next server tick.
960    pub fn get(&self, slot: impl Into<Number>) -> Result<Value> {
961        let args = args(vec![Some(Value::Number(slot.into()))]);
962        let reply = self.invoke("get", args)?;
963        single::<Value>(reply)
964    }
965
966    /// [`Self::get`] without blocking: the call is queued, and
967    /// the program keeps running until the result comes back; see [`crate::task`].
968    #[cfg(feature = "async")]
969    pub async fn get_async(&self, slot: impl Into<Number>) -> Result<Value> {
970        let args = args(vec![Some(Value::Number(slot.into()))]);
971        let reply = self.invoke_async("get", args).await?;
972        single::<Value>(reply)
973    }
974
975    /// Get the index of an item stack with the specified hash. Returns a negative value if no such stack was found.
976    ///
977    /// Lua: `database.indexOf(hash:string):number`
978    /// Indirect call: waits for the next server tick.
979    pub fn index_of(&self, hash: impl AsRef<[u8]>) -> Result<Number> {
980        let args = args(vec![Some(Value::text(hash.as_ref()))]);
981        let reply = self.invoke("indexOf", args)?;
982        single::<Number>(reply)
983    }
984
985    /// [`Self::index_of`] without blocking: the call is queued, and
986    /// the program keeps running until the result comes back; see [`crate::task`].
987    #[cfg(feature = "async")]
988    pub async fn index_of_async(&self, hash: impl AsRef<[u8]>) -> Result<Number> {
989        let args = args(vec![Some(Value::text(hash.as_ref()))]);
990        let reply = self.invoke_async("indexOf", args).await?;
991        single::<Number>(reply)
992    }
993
994    /// Sets an item into the specified database slot. The NBT tag is expected in string (SNBT) format.
995    ///
996    /// Lua: `database.set(slot:number, id:string, damage:number, nbt:string):boolean`
997    /// Indirect call: waits for the next server tick.
998    pub fn set(&self, slot: impl Into<Number>, id: impl AsRef<[u8]>, damage: impl Into<Number>, nbt: impl AsRef<[u8]>) -> Result<bool> {
999        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(id.as_ref())), Some(Value::Number(damage.into())), Some(Value::text(nbt.as_ref()))]);
1000        let reply = self.invoke("set", args)?;
1001        single::<bool>(reply)
1002    }
1003
1004    /// [`Self::set`] without blocking: the call is queued, and
1005    /// the program keeps running until the result comes back; see [`crate::task`].
1006    #[cfg(feature = "async")]
1007    pub async fn set_async(&self, slot: impl Into<Number>, id: impl AsRef<[u8]>, damage: impl Into<Number>, nbt: impl AsRef<[u8]>) -> Result<bool> {
1008        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(id.as_ref())), Some(Value::Number(damage.into())), Some(Value::text(nbt.as_ref()))]);
1009        let reply = self.invoke_async("set", args).await?;
1010        single::<bool>(reply)
1011    }
1012}
1013
1014/// The `debug` component (15 methods).
1015///
1016/// Provided by OpenComputers' `DebugCard, DebugCardBase`.
1017#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1018pub struct Debug(pub Address);
1019
1020impl Component for Debug {
1021    const KIND: &'static str = "debug";
1022    fn from_address(address: Address) -> Self {
1023        Self(address)
1024    }
1025    fn address(&self) -> &Address {
1026        &self.0
1027    }
1028}
1029
1030impl Debug {
1031    /// Changes the component network's energy buffer by the specified delta.
1032    ///
1033    /// Lua: `debug.changeBuffer(value:number):number`
1034    /// Indirect call: waits for the next server tick.
1035    pub fn change_buffer(&self, value: impl Into<Number>) -> Result<Number> {
1036        let args = args(vec![Some(Value::Number(value.into()))]);
1037        let reply = self.invoke("changeBuffer", args)?;
1038        single::<Number>(reply)
1039    }
1040
1041    /// [`Self::change_buffer`] without blocking: the call is queued, and
1042    /// the program keeps running until the result comes back; see [`crate::task`].
1043    #[cfg(feature = "async")]
1044    pub async fn change_buffer_async(&self, value: impl Into<Number>) -> Result<Number> {
1045        let args = args(vec![Some(Value::Number(value.into()))]);
1046        let reply = self.invoke_async("changeBuffer", args).await?;
1047        single::<Number>(reply)
1048    }
1049
1050    /// Add a component block at the specified coordinates to the computer network.
1051    ///
1052    /// Lua: `debug.connectToBlock(x:number, y:number, z:number):boolean`
1053    /// Indirect call: waits for the next server tick.
1054    pub fn connect_to_block(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
1055        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
1056        let reply = self.invoke("connectToBlock", args)?;
1057        single::<bool>(reply)
1058    }
1059
1060    /// [`Self::connect_to_block`] without blocking: the call is queued, and
1061    /// the program keeps running until the result comes back; see [`crate::task`].
1062    #[cfg(feature = "async")]
1063    pub async fn connect_to_block_async(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
1064        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
1065        let reply = self.invoke_async("connectToBlock", args).await?;
1066        single::<bool>(reply)
1067    }
1068
1069    /// Get the entity of a player.
1070    ///
1071    /// Lua: `debug.getPlayer(name:string):userdata`
1072    /// Indirect call: waits for the next server tick.
1073    pub fn get_player(&self, name: impl AsRef<[u8]>) -> Result<Handle> {
1074        let args = args(vec![Some(Value::text(name.as_ref()))]);
1075        let reply = self.invoke("getPlayer", args)?;
1076        single::<Handle>(reply)
1077    }
1078
1079    /// [`Self::get_player`] without blocking: the call is queued, and
1080    /// the program keeps running until the result comes back; see [`crate::task`].
1081    #[cfg(feature = "async")]
1082    pub async fn get_player_async(&self, name: impl AsRef<[u8]>) -> Result<Handle> {
1083        let args = args(vec![Some(Value::text(name.as_ref()))]);
1084        let reply = self.invoke_async("getPlayer", args).await?;
1085        single::<Handle>(reply)
1086    }
1087
1088    /// Get a list of currently logged-in players.
1089    ///
1090    /// Lua: `debug.getPlayers():table`
1091    /// Indirect call: waits for the next server tick.
1092    pub fn get_players(&self) -> Result<Value> {
1093        let args = args(vec![]);
1094        let reply = self.invoke("getPlayers", args)?;
1095        single::<Value>(reply)
1096    }
1097
1098    /// [`Self::get_players`] without blocking: the call is queued, and
1099    /// the program keeps running until the result comes back; see [`crate::task`].
1100    #[cfg(feature = "async")]
1101    pub async fn get_players_async(&self) -> Result<Value> {
1102        let args = args(vec![]);
1103        let reply = self.invoke_async("getPlayers", args).await?;
1104        single::<Value>(reply)
1105    }
1106
1107    /// Get the scoreboard object for the world
1108    ///
1109    /// Lua: `debug.getScoreboard():userdata`
1110    /// Indirect call: waits for the next server tick.
1111    pub fn get_scoreboard(&self) -> Result<Handle> {
1112        let args = args(vec![]);
1113        let reply = self.invoke("getScoreboard", args)?;
1114        single::<Handle>(reply)
1115    }
1116
1117    /// [`Self::get_scoreboard`] without blocking: the call is queued, and
1118    /// the program keeps running until the result comes back; see [`crate::task`].
1119    #[cfg(feature = "async")]
1120    pub async fn get_scoreboard_async(&self) -> Result<Handle> {
1121        let args = args(vec![]);
1122        let reply = self.invoke_async("getScoreboard", args).await?;
1123        single::<Handle>(reply)
1124    }
1125
1126    /// Get the world object of the container.
1127    ///
1128    /// Lua: `debug.getWorld():userdata`
1129    /// Indirect call: waits for the next server tick.
1130    pub fn get_world(&self) -> Result<Handle> {
1131        let args = args(vec![]);
1132        let reply = self.invoke("getWorld", args)?;
1133        single::<Handle>(reply)
1134    }
1135
1136    /// [`Self::get_world`] without blocking: the call is queued, and
1137    /// the program keeps running until the result comes back; see [`crate::task`].
1138    #[cfg(feature = "async")]
1139    pub async fn get_world_async(&self) -> Result<Handle> {
1140        let args = args(vec![]);
1141        let reply = self.invoke_async("getWorld", args).await?;
1142        single::<Handle>(reply)
1143    }
1144
1145    /// Get the container's X position in the world.
1146    ///
1147    /// Lua: `debug.getX():number`
1148    /// Indirect call: waits for the next server tick.
1149    pub fn get_x(&self) -> Result<Number> {
1150        let args = args(vec![]);
1151        let reply = self.invoke("getX", args)?;
1152        single::<Number>(reply)
1153    }
1154
1155    /// [`Self::get_x`] without blocking: the call is queued, and
1156    /// the program keeps running until the result comes back; see [`crate::task`].
1157    #[cfg(feature = "async")]
1158    pub async fn get_x_async(&self) -> Result<Number> {
1159        let args = args(vec![]);
1160        let reply = self.invoke_async("getX", args).await?;
1161        single::<Number>(reply)
1162    }
1163
1164    /// Get the container's Y position in the world.
1165    ///
1166    /// Lua: `debug.getY():number`
1167    /// Indirect call: waits for the next server tick.
1168    pub fn get_y(&self) -> Result<Number> {
1169        let args = args(vec![]);
1170        let reply = self.invoke("getY", args)?;
1171        single::<Number>(reply)
1172    }
1173
1174    /// [`Self::get_y`] without blocking: the call is queued, and
1175    /// the program keeps running until the result comes back; see [`crate::task`].
1176    #[cfg(feature = "async")]
1177    pub async fn get_y_async(&self) -> Result<Number> {
1178        let args = args(vec![]);
1179        let reply = self.invoke_async("getY", args).await?;
1180        single::<Number>(reply)
1181    }
1182
1183    /// Get the container's Z position in the world.
1184    ///
1185    /// Lua: `debug.getZ():number`
1186    /// Indirect call: waits for the next server tick.
1187    pub fn get_z(&self) -> Result<Number> {
1188        let args = args(vec![]);
1189        let reply = self.invoke("getZ", args)?;
1190        single::<Number>(reply)
1191    }
1192
1193    /// [`Self::get_z`] without blocking: the call is queued, and
1194    /// the program keeps running until the result comes back; see [`crate::task`].
1195    #[cfg(feature = "async")]
1196    pub async fn get_z_async(&self) -> Result<Number> {
1197        let args = args(vec![]);
1198        let reply = self.invoke_async("getZ", args).await?;
1199        single::<Number>(reply)
1200    }
1201
1202    /// Get whether a mod or API is loaded.
1203    ///
1204    /// Lua: `debug.isModLoaded(name:string):boolean`
1205    /// Indirect call: waits for the next server tick.
1206    pub fn is_mod_loaded(&self, name: impl AsRef<[u8]>) -> Result<bool> {
1207        let args = args(vec![Some(Value::text(name.as_ref()))]);
1208        let reply = self.invoke("isModLoaded", args)?;
1209        single::<bool>(reply)
1210    }
1211
1212    /// [`Self::is_mod_loaded`] without blocking: the call is queued, and
1213    /// the program keeps running until the result comes back; see [`crate::task`].
1214    #[cfg(feature = "async")]
1215    pub async fn is_mod_loaded_async(&self, name: impl AsRef<[u8]>) -> Result<bool> {
1216        let args = args(vec![Some(Value::text(name.as_ref()))]);
1217        let reply = self.invoke_async("isModLoaded", args).await?;
1218        single::<bool>(reply)
1219    }
1220
1221    /// Runs an arbitrary command using a fake player.
1222    ///
1223    /// Lua: `debug.runCommand(command:string):number`
1224    /// Indirect call: waits for the next server tick.
1225    pub fn run_command(&self, command: impl AsRef<[u8]>) -> Result<Number> {
1226        let args = args(vec![Some(Value::text(command.as_ref()))]);
1227        let reply = self.invoke("runCommand", args)?;
1228        single::<Number>(reply)
1229    }
1230
1231    /// [`Self::run_command`] without blocking: the call is queued, and
1232    /// the program keeps running until the result comes back; see [`crate::task`].
1233    #[cfg(feature = "async")]
1234    pub async fn run_command_async(&self, command: impl AsRef<[u8]>) -> Result<Number> {
1235        let args = args(vec![Some(Value::text(command.as_ref()))]);
1236        let reply = self.invoke_async("runCommand", args).await?;
1237        single::<Number>(reply)
1238    }
1239
1240    /// returns contents at the location in the host world
1241    ///
1242    /// Lua: `debug.scanContentsAt(x: number, y: number, z: number):boolean, string, table`
1243    /// Indirect call: waits for the next server tick.
1244    pub fn scan_contents_at(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<(bool, OcString, Value)> {
1245        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
1246        let reply = self.invoke("scanContentsAt", args)?;
1247        FromReply::from_reply(reply)
1248    }
1249
1250    /// [`Self::scan_contents_at`] without blocking: the call is queued, and
1251    /// the program keeps running until the result comes back; see [`crate::task`].
1252    #[cfg(feature = "async")]
1253    pub async fn scan_contents_at_async(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<(bool, OcString, Value)> {
1254        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
1255        let reply = self.invoke_async("scanContentsAt", args).await?;
1256        FromReply::from_reply(reply)
1257    }
1258
1259    /// Sends text to the specified player's clipboard if possible.
1260    ///
1261    /// Lua: `debug.sendToClipboard(player:string, text:string)`
1262    /// Indirect call: waits for the next server tick.
1263    pub fn send_to_clipboard(&self, player: impl AsRef<[u8]>, text: impl AsRef<[u8]>) -> Result<()> {
1264        let args = args(vec![Some(Value::text(player.as_ref())), Some(Value::text(text.as_ref()))]);
1265        let reply = self.invoke("sendToClipboard", args)?;
1266        FromReply::from_reply(reply)
1267    }
1268
1269    /// [`Self::send_to_clipboard`] without blocking: the call is queued, and
1270    /// the program keeps running until the result comes back; see [`crate::task`].
1271    #[cfg(feature = "async")]
1272    pub async fn send_to_clipboard_async(&self, player: impl AsRef<[u8]>, text: impl AsRef<[u8]>) -> Result<()> {
1273        let args = args(vec![Some(Value::text(player.as_ref())), Some(Value::text(text.as_ref()))]);
1274        let reply = self.invoke_async("sendToClipboard", args).await?;
1275        FromReply::from_reply(reply)
1276    }
1277
1278    /// Sends data to the debug card with the specified address.
1279    ///
1280    /// Lua: `debug.sendToDebugCard(address:string, data...)`
1281    /// Indirect call: waits for the next server tick.
1282    pub fn send_to_debug_card(&self, address: impl AsRef<[u8]>, data: &[Value]) -> Result<()> {
1283        let mut args: Vec<Value> = vec![Some(Value::text(address.as_ref()))].into_iter().map(Option::unwrap_or_default).collect();
1284        args.extend_from_slice(data);
1285        let reply = self.invoke("sendToDebugCard", args)?;
1286        FromReply::from_reply(reply)
1287    }
1288
1289    /// [`Self::send_to_debug_card`] without blocking: the call is queued, and
1290    /// the program keeps running until the result comes back; see [`crate::task`].
1291    #[cfg(feature = "async")]
1292    pub async fn send_to_debug_card_async(&self, address: impl AsRef<[u8]>, data: &[Value]) -> Result<()> {
1293        let mut args: Vec<Value> = vec![Some(Value::text(address.as_ref()))].into_iter().map(Option::unwrap_or_default).collect();
1294        args.extend_from_slice(data);
1295        let reply = self.invoke_async("sendToDebugCard", args).await?;
1296        FromReply::from_reply(reply)
1297    }
1298
1299    /// Test method for user-data and general value conversion.
1300    ///
1301    /// Lua: `debug.test():userdata`
1302    /// Indirect call: waits for the next server tick.
1303    pub fn test(&self) -> Result<Handle> {
1304        let args = args(vec![]);
1305        let reply = self.invoke("test", args)?;
1306        single::<Handle>(reply)
1307    }
1308
1309    /// [`Self::test`] without blocking: the call is queued, and
1310    /// the program keeps running until the result comes back; see [`crate::task`].
1311    #[cfg(feature = "async")]
1312    pub async fn test_async(&self) -> Result<Handle> {
1313        let args = args(vec![]);
1314        let reply = self.invoke_async("test", args).await?;
1315        single::<Handle>(reply)
1316    }
1317}
1318
1319/// The `disk_drive` component (3 methods).
1320///
1321/// Provided by OpenComputers' `DiskDrive, DiskDriveMountable, DiskDriveMountableBase`.
1322#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1323pub struct DiskDrive(pub Address);
1324
1325impl Component for DiskDrive {
1326    const KIND: &'static str = "disk_drive";
1327    fn from_address(address: Address) -> Self {
1328        Self(address)
1329    }
1330    fn address(&self) -> &Address {
1331        &self.0
1332    }
1333}
1334
1335impl DiskDrive {
1336    /// Eject the currently present medium from the drive.
1337    ///
1338    /// Lua: `disk_drive.eject([velocity:number]):boolean`
1339    /// Indirect call: waits for the next server tick.
1340    pub fn eject(&self, velocity: Option<Number>) -> Result<bool> {
1341        let args = args(vec![velocity.map(Value::Number)]);
1342        let reply = self.invoke("eject", args)?;
1343        single::<bool>(reply)
1344    }
1345
1346    /// [`Self::eject`] without blocking: the call is queued, and
1347    /// the program keeps running until the result comes back; see [`crate::task`].
1348    #[cfg(feature = "async")]
1349    pub async fn eject_async(&self, velocity: Option<Number>) -> Result<bool> {
1350        let args = args(vec![velocity.map(Value::Number)]);
1351        let reply = self.invoke_async("eject", args).await?;
1352        single::<bool>(reply)
1353    }
1354
1355    /// Checks whether some medium is currently in the drive.
1356    ///
1357    /// Lua: `disk_drive.isEmpty():boolean`
1358    /// Indirect call: waits for the next server tick.
1359    pub fn is_empty(&self) -> Result<bool> {
1360        let args = args(vec![]);
1361        let reply = self.invoke("isEmpty", args)?;
1362        single::<bool>(reply)
1363    }
1364
1365    /// [`Self::is_empty`] without blocking: the call is queued, and
1366    /// the program keeps running until the result comes back; see [`crate::task`].
1367    #[cfg(feature = "async")]
1368    pub async fn is_empty_async(&self) -> Result<bool> {
1369        let args = args(vec![]);
1370        let reply = self.invoke_async("isEmpty", args).await?;
1371        single::<bool>(reply)
1372    }
1373
1374    /// Return the internal floppy disk address
1375    ///
1376    /// Lua: `disk_drive.media(): string`
1377    /// Indirect call: waits for the next server tick.
1378    pub fn media(&self) -> Result<OcString> {
1379        let args = args(vec![]);
1380        let reply = self.invoke("media", args)?;
1381        single::<OcString>(reply)
1382    }
1383
1384    /// [`Self::media`] without blocking: the call is queued, and
1385    /// the program keeps running until the result comes back; see [`crate::task`].
1386    #[cfg(feature = "async")]
1387    pub async fn media_async(&self) -> Result<OcString> {
1388        let args = args(vec![]);
1389        let reply = self.invoke_async("media", args).await?;
1390        single::<OcString>(reply)
1391    }
1392}
1393
1394/// The `drive` component (9 methods).
1395///
1396/// Provided by OpenComputers' `Drive`.
1397#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1398pub struct Drive(pub Address);
1399
1400impl Component for Drive {
1401    const KIND: &'static str = "drive";
1402    fn from_address(address: Address) -> Self {
1403        Self(address)
1404    }
1405    fn address(&self) -> &Address {
1406        &self.0
1407    }
1408}
1409
1410impl Drive {
1411    /// Returns the total capacity of the drive, in bytes.
1412    ///
1413    /// Lua: `drive.getCapacity():number`
1414    /// Direct call (runs immediately, drawing on the per-tick budget).
1415    pub fn get_capacity(&self) -> Result<Number> {
1416        let args = args(vec![]);
1417        let reply = self.invoke("getCapacity", args)?;
1418        single::<Number>(reply)
1419    }
1420
1421    /// [`Self::get_capacity`] without blocking: the call is queued, and
1422    /// the program keeps running until the result comes back; see [`crate::task`].
1423    #[cfg(feature = "async")]
1424    pub async fn get_capacity_async(&self) -> Result<Number> {
1425        let args = args(vec![]);
1426        let reply = self.invoke_async("getCapacity", args).await?;
1427        single::<Number>(reply)
1428    }
1429
1430    /// Get the current label of the drive.
1431    ///
1432    /// Lua: `drive.getLabel():string`
1433    /// Direct call (runs immediately, drawing on the per-tick budget).
1434    pub fn get_label(&self) -> Result<OcString> {
1435        let args = args(vec![]);
1436        let reply = self.invoke("getLabel", args)?;
1437        single::<OcString>(reply)
1438    }
1439
1440    /// [`Self::get_label`] without blocking: the call is queued, and
1441    /// the program keeps running until the result comes back; see [`crate::task`].
1442    #[cfg(feature = "async")]
1443    pub async fn get_label_async(&self) -> Result<OcString> {
1444        let args = args(vec![]);
1445        let reply = self.invoke_async("getLabel", args).await?;
1446        single::<OcString>(reply)
1447    }
1448
1449    /// Returns the number of platters in the drive.
1450    ///
1451    /// Lua: `drive.getPlatterCount():number`
1452    /// Direct call (runs immediately, drawing on the per-tick budget).
1453    pub fn get_platter_count(&self) -> Result<Number> {
1454        let args = args(vec![]);
1455        let reply = self.invoke("getPlatterCount", args)?;
1456        single::<Number>(reply)
1457    }
1458
1459    /// [`Self::get_platter_count`] without blocking: the call is queued, and
1460    /// the program keeps running until the result comes back; see [`crate::task`].
1461    #[cfg(feature = "async")]
1462    pub async fn get_platter_count_async(&self) -> Result<Number> {
1463        let args = args(vec![]);
1464        let reply = self.invoke_async("getPlatterCount", args).await?;
1465        single::<Number>(reply)
1466    }
1467
1468    /// Returns the size of a single sector on the drive, in bytes.
1469    ///
1470    /// Lua: `drive.getSectorSize():number`
1471    /// Direct call (runs immediately, drawing on the per-tick budget).
1472    pub fn get_sector_size(&self) -> Result<Number> {
1473        let args = args(vec![]);
1474        let reply = self.invoke("getSectorSize", args)?;
1475        single::<Number>(reply)
1476    }
1477
1478    /// [`Self::get_sector_size`] without blocking: the call is queued, and
1479    /// the program keeps running until the result comes back; see [`crate::task`].
1480    #[cfg(feature = "async")]
1481    pub async fn get_sector_size_async(&self) -> Result<Number> {
1482        let args = args(vec![]);
1483        let reply = self.invoke_async("getSectorSize", args).await?;
1484        single::<Number>(reply)
1485    }
1486
1487    /// Read a single byte at the specified offset.
1488    ///
1489    /// Lua: `drive.readByte(offset:number):number`
1490    /// Direct call (runs immediately, drawing on the per-tick budget).
1491    pub fn read_byte(&self, offset: impl Into<Number>) -> Result<Number> {
1492        let args = args(vec![Some(Value::Number(offset.into()))]);
1493        let reply = self.invoke("readByte", args)?;
1494        single::<Number>(reply)
1495    }
1496
1497    /// [`Self::read_byte`] without blocking: the call is queued, and
1498    /// the program keeps running until the result comes back; see [`crate::task`].
1499    #[cfg(feature = "async")]
1500    pub async fn read_byte_async(&self, offset: impl Into<Number>) -> Result<Number> {
1501        let args = args(vec![Some(Value::Number(offset.into()))]);
1502        let reply = self.invoke_async("readByte", args).await?;
1503        single::<Number>(reply)
1504    }
1505
1506    /// Read the current contents of the specified sector.
1507    ///
1508    /// Lua: `drive.readSector(sector:number):string`
1509    /// Direct call (runs immediately, drawing on the per-tick budget).
1510    pub fn read_sector(&self, sector: impl Into<Number>) -> Result<OcString> {
1511        let args = args(vec![Some(Value::Number(sector.into()))]);
1512        let reply = self.invoke("readSector", args)?;
1513        single::<OcString>(reply)
1514    }
1515
1516    /// [`Self::read_sector`] without blocking: the call is queued, and
1517    /// the program keeps running until the result comes back; see [`crate::task`].
1518    #[cfg(feature = "async")]
1519    pub async fn read_sector_async(&self, sector: impl Into<Number>) -> Result<OcString> {
1520        let args = args(vec![Some(Value::Number(sector.into()))]);
1521        let reply = self.invoke_async("readSector", args).await?;
1522        single::<OcString>(reply)
1523    }
1524
1525    /// Sets the label of the drive. Returns the new value, which may be truncated.
1526    ///
1527    /// Lua: `drive.setLabel(value:string):string`
1528    /// Indirect call: waits for the next server tick.
1529    pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
1530        let args = args(vec![Some(Value::text(value.as_ref()))]);
1531        let reply = self.invoke("setLabel", args)?;
1532        single::<OcString>(reply)
1533    }
1534
1535    /// [`Self::set_label`] without blocking: the call is queued, and
1536    /// the program keeps running until the result comes back; see [`crate::task`].
1537    #[cfg(feature = "async")]
1538    pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
1539        let args = args(vec![Some(Value::text(value.as_ref()))]);
1540        let reply = self.invoke_async("setLabel", args).await?;
1541        single::<OcString>(reply)
1542    }
1543
1544    /// Write a single byte to the specified offset.
1545    ///
1546    /// Lua: `drive.writeByte(offset:number, value:number)`
1547    /// Direct call (runs immediately, drawing on the per-tick budget).
1548    pub fn write_byte(&self, offset: impl Into<Number>, value: impl Into<Number>) -> Result<()> {
1549        let args = args(vec![Some(Value::Number(offset.into())), Some(Value::Number(value.into()))]);
1550        let reply = self.invoke("writeByte", args)?;
1551        FromReply::from_reply(reply)
1552    }
1553
1554    /// [`Self::write_byte`] without blocking: the call is queued, and
1555    /// the program keeps running until the result comes back; see [`crate::task`].
1556    #[cfg(feature = "async")]
1557    pub async fn write_byte_async(&self, offset: impl Into<Number>, value: impl Into<Number>) -> Result<()> {
1558        let args = args(vec![Some(Value::Number(offset.into())), Some(Value::Number(value.into()))]);
1559        let reply = self.invoke_async("writeByte", args).await?;
1560        FromReply::from_reply(reply)
1561    }
1562
1563    /// Write the specified contents to the specified sector.
1564    ///
1565    /// Lua: `drive.writeSector(sector:number, value:string)`
1566    /// Direct call (runs immediately, drawing on the per-tick budget).
1567    pub fn write_sector(&self, sector: impl Into<Number>, value: impl AsRef<[u8]>) -> Result<()> {
1568        let args = args(vec![Some(Value::Number(sector.into())), Some(Value::text(value.as_ref()))]);
1569        let reply = self.invoke("writeSector", args)?;
1570        FromReply::from_reply(reply)
1571    }
1572
1573    /// [`Self::write_sector`] without blocking: the call is queued, and
1574    /// the program keeps running until the result comes back; see [`crate::task`].
1575    #[cfg(feature = "async")]
1576    pub async fn write_sector_async(&self, sector: impl Into<Number>, value: impl AsRef<[u8]>) -> Result<()> {
1577        let args = args(vec![Some(Value::Number(sector.into())), Some(Value::text(value.as_ref()))]);
1578        let reply = self.invoke_async("writeSector", args).await?;
1579        FromReply::from_reply(reply)
1580    }
1581}
1582
1583/// The `drone` component (33 methods).
1584///
1585/// Provided by OpenComputers' `Drone, DroneBase`.
1586#[derive(Clone, Debug, PartialEq, Eq, Hash)]
1587pub struct Drone(pub Address);
1588
1589impl Component for Drone {
1590    const KIND: &'static str = "drone";
1591    fn from_address(address: Address) -> Self {
1592        Self(address)
1593    }
1594    fn address(&self) -> &Address {
1595        &self.0
1596    }
1597}
1598
1599impl Drone {
1600    /// Compare the block on the specified side with the one in the selected slot. Returns true if equal.
1601    ///
1602    /// Lua: `drone.compare(side:number[, fuzzy:boolean=false]):boolean`
1603    /// Indirect call: waits for the next server tick.
1604    /// `fuzzy` defaults to `false`.
1605    pub fn compare(&self, side: impl Into<Number>, fuzzy: Option<bool>) -> Result<bool> {
1606        let args = args(vec![Some(Value::Number(side.into())), fuzzy.map(Value::Bool)]);
1607        let reply = self.invoke("compare", args)?;
1608        single::<bool>(reply)
1609    }
1610
1611    /// [`Self::compare`] without blocking: the call is queued, and
1612    /// the program keeps running until the result comes back; see [`crate::task`].
1613    #[cfg(feature = "async")]
1614    pub async fn compare_async(&self, side: impl Into<Number>, fuzzy: Option<bool>) -> Result<bool> {
1615        let args = args(vec![Some(Value::Number(side.into())), fuzzy.map(Value::Bool)]);
1616        let reply = self.invoke_async("compare", args).await?;
1617        single::<bool>(reply)
1618    }
1619
1620    /// Compare the fluid in the selected tank with the fluid in the specified tank on the specified side. Returns true if equal.
1621    ///
1622    /// Lua: `drone.compareFluid(side:number [, tank:number]):boolean`
1623    /// Indirect call: waits for the next server tick.
1624    pub fn compare_fluid(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<bool> {
1625        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
1626        let reply = self.invoke("compareFluid", args)?;
1627        single::<bool>(reply)
1628    }
1629
1630    /// [`Self::compare_fluid`] without blocking: the call is queued, and
1631    /// the program keeps running until the result comes back; see [`crate::task`].
1632    #[cfg(feature = "async")]
1633    pub async fn compare_fluid_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<bool> {
1634        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
1635        let reply = self.invoke_async("compareFluid", args).await?;
1636        single::<bool>(reply)
1637    }
1638
1639    /// Compares the fluids in the selected and the specified tank. Returns true if equal.
1640    ///
1641    /// Lua: `drone.compareFluidTo(index:number):boolean`
1642    /// Indirect call: waits for the next server tick.
1643    pub fn compare_fluid_to(&self, index: impl Into<Number>) -> Result<bool> {
1644        let args = args(vec![Some(Value::Number(index.into()))]);
1645        let reply = self.invoke("compareFluidTo", args)?;
1646        single::<bool>(reply)
1647    }
1648
1649    /// [`Self::compare_fluid_to`] without blocking: the call is queued, and
1650    /// the program keeps running until the result comes back; see [`crate::task`].
1651    #[cfg(feature = "async")]
1652    pub async fn compare_fluid_to_async(&self, index: impl Into<Number>) -> Result<bool> {
1653        let args = args(vec![Some(Value::Number(index.into()))]);
1654        let reply = self.invoke_async("compareFluidTo", args).await?;
1655        single::<bool>(reply)
1656    }
1657
1658    /// Compare the contents of the selected slot to the contents of the specified slot.
1659    ///
1660    /// Lua: `drone.compareTo(otherSlot:number[, checkNBT:boolean=false]):boolean`
1661    /// Indirect call: waits for the next server tick.
1662    /// `check_nbt` defaults to `false`.
1663    pub fn compare_to(&self, other_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
1664        let args = args(vec![Some(Value::Number(other_slot.into())), check_nbt.map(Value::Bool)]);
1665        let reply = self.invoke("compareTo", args)?;
1666        single::<bool>(reply)
1667    }
1668
1669    /// [`Self::compare_to`] without blocking: the call is queued, and
1670    /// the program keeps running until the result comes back; see [`crate::task`].
1671    #[cfg(feature = "async")]
1672    pub async fn compare_to_async(&self, other_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
1673        let args = args(vec![Some(Value::Number(other_slot.into())), check_nbt.map(Value::Bool)]);
1674        let reply = self.invoke_async("compareTo", args).await?;
1675        single::<bool>(reply)
1676    }
1677
1678    /// Get the number of items in the specified slot, otherwise in the selected slot.
1679    ///
1680    /// Lua: `drone.count([slot:number]):number`
1681    /// Direct call (runs immediately, drawing on the per-tick budget).
1682    pub fn count(&self, slot: Option<Number>) -> Result<Number> {
1683        let args = args(vec![slot.map(Value::Number)]);
1684        let reply = self.invoke("count", args)?;
1685        single::<Number>(reply)
1686    }
1687
1688    /// [`Self::count`] without blocking: the call is queued, and
1689    /// the program keeps running until the result comes back; see [`crate::task`].
1690    #[cfg(feature = "async")]
1691    pub async fn count_async(&self, slot: Option<Number>) -> Result<Number> {
1692        let args = args(vec![slot.map(Value::Number)]);
1693        let reply = self.invoke_async("count", args).await?;
1694        single::<Number>(reply)
1695    }
1696
1697    /// Checks the contents of the block on the specified sides and returns the findings.
1698    ///
1699    /// Lua: `drone.detect(side:number):boolean, string`
1700    /// Indirect call: waits for the next server tick.
1701    pub fn detect(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
1702        let args = args(vec![Some(Value::Number(side.into()))]);
1703        let reply = self.invoke("detect", args)?;
1704        FromReply::from_reply(reply)
1705    }
1706
1707    /// [`Self::detect`] without blocking: the call is queued, and
1708    /// the program keeps running until the result comes back; see [`crate::task`].
1709    #[cfg(feature = "async")]
1710    pub async fn detect_async(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
1711        let args = args(vec![Some(Value::Number(side.into()))]);
1712        let reply = self.invoke_async("detect", args).await?;
1713        FromReply::from_reply(reply)
1714    }
1715
1716    /// Drains the specified amount of fluid from the specified side. Returns the amount drained, or an error message.
1717    ///
1718    /// Lua: `drone.drain(side:number[, amount:number=1000]):boolean, number or string`
1719    /// Indirect call: waits for the next server tick.
1720    /// `amount` defaults to `1000`.
1721    pub fn drain(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
1722        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
1723        let reply = self.invoke("drain", args)?;
1724        FromReply::from_reply(reply)
1725    }
1726
1727    /// [`Self::drain`] without blocking: the call is queued, and
1728    /// the program keeps running until the result comes back; see [`crate::task`].
1729    #[cfg(feature = "async")]
1730    pub async fn drain_async(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
1731        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
1732        let reply = self.invoke_async("drain", args).await?;
1733        FromReply::from_reply(reply)
1734    }
1735
1736    /// Drops items from the selected slot towards the specified side.
1737    ///
1738    /// Lua: `drone.drop(side:number[, count:number=64]):boolean`
1739    /// Indirect call: waits for the next server tick.
1740    /// `count` defaults to `64`.
1741    pub fn drop(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
1742        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
1743        let reply = self.invoke("drop", args)?;
1744        single::<bool>(reply)
1745    }
1746
1747    /// [`Self::drop`] without blocking: the call is queued, and
1748    /// the program keeps running until the result comes back; see [`crate::task`].
1749    #[cfg(feature = "async")]
1750    pub async fn drop_async(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
1751        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
1752        let reply = self.invoke_async("drop", args).await?;
1753        single::<bool>(reply)
1754    }
1755
1756    /// Eject the specified amount of fluid to the specified side. Returns the amount ejected or an error message.
1757    ///
1758    /// Lua: `drone.fill(side:number[, amount:number=1000]):boolean, number or string`
1759    /// Indirect call: waits for the next server tick.
1760    /// `amount` defaults to `1000`.
1761    pub fn fill(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
1762        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
1763        let reply = self.invoke("fill", args)?;
1764        FromReply::from_reply(reply)
1765    }
1766
1767    /// [`Self::fill`] without blocking: the call is queued, and
1768    /// the program keeps running until the result comes back; see [`crate::task`].
1769    #[cfg(feature = "async")]
1770    pub async fn fill_async(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
1771        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
1772        let reply = self.invoke_async("fill", args).await?;
1773        FromReply::from_reply(reply)
1774    }
1775
1776    /// Get the currently set acceleration.
1777    ///
1778    /// Lua: `drone.getAcceleration():number`
1779    /// Indirect call: waits for the next server tick.
1780    pub fn get_acceleration(&self) -> Result<Number> {
1781        let args = args(vec![]);
1782        let reply = self.invoke("getAcceleration", args)?;
1783        single::<Number>(reply)
1784    }
1785
1786    /// [`Self::get_acceleration`] without blocking: the call is queued, and
1787    /// the program keeps running until the result comes back; see [`crate::task`].
1788    #[cfg(feature = "async")]
1789    pub async fn get_acceleration_async(&self) -> Result<Number> {
1790        let args = args(vec![]);
1791        let reply = self.invoke_async("getAcceleration", args).await?;
1792        single::<Number>(reply)
1793    }
1794
1795    /// Get the current color of the flap lights as an integer encoded RGB value (0xRRGGBB).
1796    ///
1797    /// Lua: `drone.getLightColor():number`
1798    /// Indirect call: waits for the next server tick.
1799    pub fn get_light_color(&self) -> Result<Number> {
1800        let args = args(vec![]);
1801        let reply = self.invoke("getLightColor", args)?;
1802        single::<Number>(reply)
1803    }
1804
1805    /// [`Self::get_light_color`] without blocking: the call is queued, and
1806    /// the program keeps running until the result comes back; see [`crate::task`].
1807    #[cfg(feature = "async")]
1808    pub async fn get_light_color_async(&self) -> Result<Number> {
1809        let args = args(vec![]);
1810        let reply = self.invoke_async("getLightColor", args).await?;
1811        single::<Number>(reply)
1812    }
1813
1814    /// Get the maximum velocity, in m/s.
1815    ///
1816    /// Lua: `drone.getMaxVelocity():number`
1817    /// Indirect call: waits for the next server tick.
1818    pub fn get_max_velocity(&self) -> Result<Number> {
1819        let args = args(vec![]);
1820        let reply = self.invoke("getMaxVelocity", args)?;
1821        single::<Number>(reply)
1822    }
1823
1824    /// [`Self::get_max_velocity`] without blocking: the call is queued, and
1825    /// the program keeps running until the result comes back; see [`crate::task`].
1826    #[cfg(feature = "async")]
1827    pub async fn get_max_velocity_async(&self) -> Result<Number> {
1828        let args = args(vec![]);
1829        let reply = self.invoke_async("getMaxVelocity", args).await?;
1830        single::<Number>(reply)
1831    }
1832
1833    /// Get the current distance to the target position.
1834    ///
1835    /// Lua: `drone.getOffset():number`
1836    /// Indirect call: waits for the next server tick.
1837    pub fn get_offset(&self) -> Result<Number> {
1838        let args = args(vec![]);
1839        let reply = self.invoke("getOffset", args)?;
1840        single::<Number>(reply)
1841    }
1842
1843    /// [`Self::get_offset`] without blocking: the call is queued, and
1844    /// the program keeps running until the result comes back; see [`crate::task`].
1845    #[cfg(feature = "async")]
1846    pub async fn get_offset_async(&self) -> Result<Number> {
1847        let args = args(vec![]);
1848        let reply = self.invoke_async("getOffset", args).await?;
1849        single::<Number>(reply)
1850    }
1851
1852    /// Get the status text currently being displayed in the GUI.
1853    ///
1854    /// Lua: `drone.getStatusText():string`
1855    /// Indirect call: waits for the next server tick.
1856    pub fn get_status_text(&self) -> Result<OcString> {
1857        let args = args(vec![]);
1858        let reply = self.invoke("getStatusText", args)?;
1859        single::<OcString>(reply)
1860    }
1861
1862    /// [`Self::get_status_text`] without blocking: the call is queued, and
1863    /// the program keeps running until the result comes back; see [`crate::task`].
1864    #[cfg(feature = "async")]
1865    pub async fn get_status_text_async(&self) -> Result<OcString> {
1866        let args = args(vec![]);
1867        let reply = self.invoke_async("getStatusText", args).await?;
1868        single::<OcString>(reply)
1869    }
1870
1871    /// Get the current velocity in m/s.
1872    ///
1873    /// Lua: `drone.getVelocity():number`
1874    /// Indirect call: waits for the next server tick.
1875    pub fn get_velocity(&self) -> Result<Number> {
1876        let args = args(vec![]);
1877        let reply = self.invoke("getVelocity", args)?;
1878        single::<Number>(reply)
1879    }
1880
1881    /// [`Self::get_velocity`] without blocking: the call is queued, and
1882    /// the program keeps running until the result comes back; see [`crate::task`].
1883    #[cfg(feature = "async")]
1884    pub async fn get_velocity_async(&self) -> Result<Number> {
1885        let args = args(vec![]);
1886        let reply = self.invoke_async("getVelocity", args).await?;
1887        single::<Number>(reply)
1888    }
1889
1890    /// The size of this device's internal inventory.
1891    ///
1892    /// Lua: `drone.inventorySize():number`
1893    /// Indirect call: waits for the next server tick.
1894    pub fn inventory_size(&self) -> Result<Number> {
1895        let args = args(vec![]);
1896        let reply = self.invoke("inventorySize", args)?;
1897        single::<Number>(reply)
1898    }
1899
1900    /// [`Self::inventory_size`] without blocking: the call is queued, and
1901    /// the program keeps running until the result comes back; see [`crate::task`].
1902    #[cfg(feature = "async")]
1903    pub async fn inventory_size_async(&self) -> Result<Number> {
1904        let args = args(vec![]);
1905        let reply = self.invoke_async("inventorySize", args).await?;
1906        single::<Number>(reply)
1907    }
1908
1909    /// Change the target position by the specified offset.
1910    ///
1911    /// Lua: `drone.move(dx:number, dy:number, dz:number)`
1912    /// Indirect call: waits for the next server tick.
1913    pub fn r#move(&self, dx: impl Into<Number>, dy: impl Into<Number>, dz: impl Into<Number>) -> Result<()> {
1914        let args = args(vec![Some(Value::Number(dx.into())), Some(Value::Number(dy.into())), Some(Value::Number(dz.into()))]);
1915        let reply = self.invoke("move", args)?;
1916        FromReply::from_reply(reply)
1917    }
1918
1919    /// [`Self::move`] without blocking: the call is queued, and
1920    /// the program keeps running until the result comes back; see [`crate::task`].
1921    #[cfg(feature = "async")]
1922    pub async fn move_async(&self, dx: impl Into<Number>, dy: impl Into<Number>, dz: impl Into<Number>) -> Result<()> {
1923        let args = args(vec![Some(Value::Number(dx.into())), Some(Value::Number(dy.into())), Some(Value::Number(dz.into()))]);
1924        let reply = self.invoke_async("move", args).await?;
1925        FromReply::from_reply(reply)
1926    }
1927
1928    /// Get the name of the agent.
1929    ///
1930    /// Lua: `drone.name():string`
1931    /// Indirect call: waits for the next server tick.
1932    pub fn name(&self) -> Result<OcString> {
1933        let args = args(vec![]);
1934        let reply = self.invoke("name", args)?;
1935        single::<OcString>(reply)
1936    }
1937
1938    /// [`Self::name`] without blocking: the call is queued, and
1939    /// the program keeps running until the result comes back; see [`crate::task`].
1940    #[cfg(feature = "async")]
1941    pub async fn name_async(&self) -> Result<OcString> {
1942        let args = args(vec![]);
1943        let reply = self.invoke_async("name", args).await?;
1944        single::<OcString>(reply)
1945    }
1946
1947    /// Place a block towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
1948    ///
1949    /// Lua: `drone.place(side:number[, face:number=side[, sneaky:boolean=false]]):boolean`
1950    /// Indirect call: waits for the next server tick.
1951    /// `face` defaults to `side`.
1952    /// `sneaky` defaults to `false`.
1953    pub fn place(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<bool> {
1954        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
1955        let reply = self.invoke("place", args)?;
1956        single::<bool>(reply)
1957    }
1958
1959    /// [`Self::place`] without blocking: the call is queued, and
1960    /// the program keeps running until the result comes back; see [`crate::task`].
1961    #[cfg(feature = "async")]
1962    pub async fn place_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<bool> {
1963        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
1964        let reply = self.invoke_async("place", args).await?;
1965        single::<bool>(reply)
1966    }
1967
1968    /// Get the currently selected slot; set the selected slot if specified.
1969    ///
1970    /// Lua: `drone.select([slot:number]):number`
1971    /// Indirect call: waits for the next server tick.
1972    pub fn select(&self, slot: Option<Number>) -> Result<Number> {
1973        let args = args(vec![slot.map(Value::Number)]);
1974        let reply = self.invoke("select", args)?;
1975        single::<Number>(reply)
1976    }
1977
1978    /// [`Self::select`] without blocking: the call is queued, and
1979    /// the program keeps running until the result comes back; see [`crate::task`].
1980    #[cfg(feature = "async")]
1981    pub async fn select_async(&self, slot: Option<Number>) -> Result<Number> {
1982        let args = args(vec![slot.map(Value::Number)]);
1983        let reply = self.invoke_async("select", args).await?;
1984        single::<Number>(reply)
1985    }
1986
1987    /// Select a tank and/or get the number of the currently selected tank.
1988    ///
1989    /// Lua: `drone.selectTank([index:number]):number`
1990    /// Indirect call: waits for the next server tick.
1991    pub fn select_tank(&self, index: Option<Number>) -> Result<Number> {
1992        let args = args(vec![index.map(Value::Number)]);
1993        let reply = self.invoke("selectTank", args)?;
1994        single::<Number>(reply)
1995    }
1996
1997    /// [`Self::select_tank`] without blocking: the call is queued, and
1998    /// the program keeps running until the result comes back; see [`crate::task`].
1999    #[cfg(feature = "async")]
2000    pub async fn select_tank_async(&self, index: Option<Number>) -> Result<Number> {
2001        let args = args(vec![index.map(Value::Number)]);
2002        let reply = self.invoke_async("selectTank", args).await?;
2003        single::<Number>(reply)
2004    }
2005
2006    /// Try to set the acceleration.
2007    ///
2008    /// Lua: `drone.setAcceleration(value:number):number`
2009    /// Indirect call: waits for the next server tick.
2010    pub fn set_acceleration(&self, value: impl Into<Number>) -> Result<Number> {
2011        let args = args(vec![Some(Value::Number(value.into()))]);
2012        let reply = self.invoke("setAcceleration", args)?;
2013        single::<Number>(reply)
2014    }
2015
2016    /// [`Self::set_acceleration`] without blocking: the call is queued, and
2017    /// the program keeps running until the result comes back; see [`crate::task`].
2018    #[cfg(feature = "async")]
2019    pub async fn set_acceleration_async(&self, value: impl Into<Number>) -> Result<Number> {
2020        let args = args(vec![Some(Value::Number(value.into()))]);
2021        let reply = self.invoke_async("setAcceleration", args).await?;
2022        single::<Number>(reply)
2023    }
2024
2025    /// Set the color of the flap lights to the specified integer encoded RGB value (0xRRGGBB).
2026    ///
2027    /// Lua: `drone.setLightColor(value:number):number`
2028    /// Indirect call: waits for the next server tick.
2029    pub fn set_light_color(&self, value: impl Into<Number>) -> Result<Number> {
2030        let args = args(vec![Some(Value::Number(value.into()))]);
2031        let reply = self.invoke("setLightColor", args)?;
2032        single::<Number>(reply)
2033    }
2034
2035    /// [`Self::set_light_color`] without blocking: the call is queued, and
2036    /// the program keeps running until the result comes back; see [`crate::task`].
2037    #[cfg(feature = "async")]
2038    pub async fn set_light_color_async(&self, value: impl Into<Number>) -> Result<Number> {
2039        let args = args(vec![Some(Value::Number(value.into()))]);
2040        let reply = self.invoke_async("setLightColor", args).await?;
2041        single::<Number>(reply)
2042    }
2043
2044    /// Set the status text to display in the GUI, returns new value.
2045    ///
2046    /// Lua: `drone.setStatusText(value:string):string`
2047    /// Indirect call: waits for the next server tick.
2048    pub fn set_status_text(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
2049        let args = args(vec![Some(Value::text(value.as_ref()))]);
2050        let reply = self.invoke("setStatusText", args)?;
2051        single::<OcString>(reply)
2052    }
2053
2054    /// [`Self::set_status_text`] without blocking: the call is queued, and
2055    /// the program keeps running until the result comes back; see [`crate::task`].
2056    #[cfg(feature = "async")]
2057    pub async fn set_status_text_async(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
2058        let args = args(vec![Some(Value::text(value.as_ref()))]);
2059        let reply = self.invoke_async("setStatusText", args).await?;
2060        single::<OcString>(reply)
2061    }
2062
2063    /// Get the remaining space in the specified slot, otherwise in the selected slot.
2064    ///
2065    /// Lua: `drone.space([slot:number]):number`
2066    /// Direct call (runs immediately, drawing on the per-tick budget).
2067    pub fn space(&self, slot: Option<Number>) -> Result<Number> {
2068        let args = args(vec![slot.map(Value::Number)]);
2069        let reply = self.invoke("space", args)?;
2070        single::<Number>(reply)
2071    }
2072
2073    /// [`Self::space`] without blocking: the call is queued, and
2074    /// the program keeps running until the result comes back; see [`crate::task`].
2075    #[cfg(feature = "async")]
2076    pub async fn space_async(&self, slot: Option<Number>) -> Result<Number> {
2077        let args = args(vec![slot.map(Value::Number)]);
2078        let reply = self.invoke_async("space", args).await?;
2079        single::<Number>(reply)
2080    }
2081
2082    /// Suck up items from the specified side.
2083    ///
2084    /// Lua: `drone.suck(side:number[, count:number=64]):boolean`
2085    /// Indirect call: waits for the next server tick.
2086    /// `count` defaults to `64`.
2087    pub fn suck(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
2088        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
2089        let reply = self.invoke("suck", args)?;
2090        single::<bool>(reply)
2091    }
2092
2093    /// [`Self::suck`] without blocking: the call is queued, and
2094    /// the program keeps running until the result comes back; see [`crate::task`].
2095    #[cfg(feature = "async")]
2096    pub async fn suck_async(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
2097        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
2098        let reply = self.invoke_async("suck", args).await?;
2099        single::<bool>(reply)
2100    }
2101
2102    /// Perform a 'left click' towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
2103    ///
2104    /// Lua: `drone.swing(side:number[, face:number=side[, sneaky:boolean=false]]):boolean, string`
2105    /// Indirect call: waits for the next server tick.
2106    /// `face` defaults to `side`.
2107    /// `sneaky` defaults to `false`.
2108    pub fn swing(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<(bool, OcString)> {
2109        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
2110        let reply = self.invoke("swing", args)?;
2111        FromReply::from_reply(reply)
2112    }
2113
2114    /// [`Self::swing`] without blocking: the call is queued, and
2115    /// the program keeps running until the result comes back; see [`crate::task`].
2116    #[cfg(feature = "async")]
2117    pub async fn swing_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<(bool, OcString)> {
2118        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
2119        let reply = self.invoke_async("swing", args).await?;
2120        FromReply::from_reply(reply)
2121    }
2122
2123    /// The number of tanks installed in the device.
2124    ///
2125    /// Lua: `drone.tankCount():number`
2126    /// Indirect call: waits for the next server tick.
2127    pub fn tank_count(&self) -> Result<Number> {
2128        let args = args(vec![]);
2129        let reply = self.invoke("tankCount", args)?;
2130        single::<Number>(reply)
2131    }
2132
2133    /// [`Self::tank_count`] without blocking: the call is queued, and
2134    /// the program keeps running until the result comes back; see [`crate::task`].
2135    #[cfg(feature = "async")]
2136    pub async fn tank_count_async(&self) -> Result<Number> {
2137        let args = args(vec![]);
2138        let reply = self.invoke_async("tankCount", args).await?;
2139        single::<Number>(reply)
2140    }
2141
2142    /// Get the fluid amount in the specified or selected tank.
2143    ///
2144    /// Lua: `drone.tankLevel([index:number]):number`
2145    /// Direct call (runs immediately, drawing on the per-tick budget).
2146    pub fn tank_level(&self, index: Option<Number>) -> Result<Number> {
2147        let args = args(vec![index.map(Value::Number)]);
2148        let reply = self.invoke("tankLevel", args)?;
2149        single::<Number>(reply)
2150    }
2151
2152    /// [`Self::tank_level`] without blocking: the call is queued, and
2153    /// the program keeps running until the result comes back; see [`crate::task`].
2154    #[cfg(feature = "async")]
2155    pub async fn tank_level_async(&self, index: Option<Number>) -> Result<Number> {
2156        let args = args(vec![index.map(Value::Number)]);
2157        let reply = self.invoke_async("tankLevel", args).await?;
2158        single::<Number>(reply)
2159    }
2160
2161    /// Get the remaining fluid capacity in the specified or selected tank.
2162    ///
2163    /// Lua: `drone.tankSpace([index:number]):number`
2164    /// Direct call (runs immediately, drawing on the per-tick budget).
2165    pub fn tank_space(&self, index: Option<Number>) -> Result<Number> {
2166        let args = args(vec![index.map(Value::Number)]);
2167        let reply = self.invoke("tankSpace", args)?;
2168        single::<Number>(reply)
2169    }
2170
2171    /// [`Self::tank_space`] without blocking: the call is queued, and
2172    /// the program keeps running until the result comes back; see [`crate::task`].
2173    #[cfg(feature = "async")]
2174    pub async fn tank_space_async(&self, index: Option<Number>) -> Result<Number> {
2175        let args = args(vec![index.map(Value::Number)]);
2176        let reply = self.invoke_async("tankSpace", args).await?;
2177        single::<Number>(reply)
2178    }
2179
2180    /// Move the specified amount of fluid from the selected tank into the specified tank.
2181    ///
2182    /// Lua: `drone.transferFluidTo(index:number[, count:number=1000]):boolean`
2183    /// Indirect call: waits for the next server tick.
2184    /// `count` defaults to `1000`.
2185    pub fn transfer_fluid_to(&self, index: impl Into<Number>, count: Option<Number>) -> Result<bool> {
2186        let args = args(vec![Some(Value::Number(index.into())), count.map(Value::Number)]);
2187        let reply = self.invoke("transferFluidTo", args)?;
2188        single::<bool>(reply)
2189    }
2190
2191    /// [`Self::transfer_fluid_to`] without blocking: the call is queued, and
2192    /// the program keeps running until the result comes back; see [`crate::task`].
2193    #[cfg(feature = "async")]
2194    pub async fn transfer_fluid_to_async(&self, index: impl Into<Number>, count: Option<Number>) -> Result<bool> {
2195        let args = args(vec![Some(Value::Number(index.into())), count.map(Value::Number)]);
2196        let reply = self.invoke_async("transferFluidTo", args).await?;
2197        single::<bool>(reply)
2198    }
2199
2200    /// Move up to the specified amount of items from the selected slot into the specified slot.
2201    ///
2202    /// Lua: `drone.transferTo(toSlot:number[, amount:number]):boolean`
2203    /// Indirect call: waits for the next server tick.
2204    pub fn transfer_to(&self, to_slot: impl Into<Number>, amount: Option<Number>) -> Result<bool> {
2205        let args = args(vec![Some(Value::Number(to_slot.into())), amount.map(Value::Number)]);
2206        let reply = self.invoke("transferTo", args)?;
2207        single::<bool>(reply)
2208    }
2209
2210    /// [`Self::transfer_to`] without blocking: the call is queued, and
2211    /// the program keeps running until the result comes back; see [`crate::task`].
2212    #[cfg(feature = "async")]
2213    pub async fn transfer_to_async(&self, to_slot: impl Into<Number>, amount: Option<Number>) -> Result<bool> {
2214        let args = args(vec![Some(Value::Number(to_slot.into())), amount.map(Value::Number)]);
2215        let reply = self.invoke_async("transferTo", args).await?;
2216        single::<bool>(reply)
2217    }
2218
2219    /// Perform a 'right click' towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
2220    ///
2221    /// Lua: `drone.use(side:number[, face:number=side[, sneaky:boolean=false[, duration:number=0]]]):boolean, string`
2222    /// Indirect call: waits for the next server tick.
2223    /// `face` defaults to `side`.
2224    /// `sneaky` defaults to `false`.
2225    /// `duration` defaults to `0`.
2226    pub fn r#use(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>, duration: Option<Number>) -> Result<(bool, OcString)> {
2227        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool), duration.map(Value::Number)]);
2228        let reply = self.invoke("use", args)?;
2229        FromReply::from_reply(reply)
2230    }
2231
2232    /// [`Self::use`] without blocking: the call is queued, and
2233    /// the program keeps running until the result comes back; see [`crate::task`].
2234    #[cfg(feature = "async")]
2235    pub async fn use_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>, duration: Option<Number>) -> Result<(bool, OcString)> {
2236        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool), duration.map(Value::Number)]);
2237        let reply = self.invoke_async("use", args).await?;
2238        FromReply::from_reply(reply)
2239    }
2240}
2241
2242/// The `eeprom` component (10 methods).
2243///
2244/// Provided by OpenComputers' `EEPROM`.
2245#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2246pub struct Eeprom(pub Address);
2247
2248impl Component for Eeprom {
2249    const KIND: &'static str = "eeprom";
2250    fn from_address(address: Address) -> Self {
2251        Self(address)
2252    }
2253    fn address(&self) -> &Address {
2254        &self.0
2255    }
2256}
2257
2258impl Eeprom {
2259    /// Get the currently stored byte array.
2260    ///
2261    /// Lua: `eeprom.get():string`
2262    /// Direct call (runs immediately, drawing on the per-tick budget).
2263    pub fn get(&self) -> Result<OcString> {
2264        let args = args(vec![]);
2265        let reply = self.invoke("get", args)?;
2266        single::<OcString>(reply)
2267    }
2268
2269    /// [`Self::get`] without blocking: the call is queued, and
2270    /// the program keeps running until the result comes back; see [`crate::task`].
2271    #[cfg(feature = "async")]
2272    pub async fn get_async(&self) -> Result<OcString> {
2273        let args = args(vec![]);
2274        let reply = self.invoke_async("get", args).await?;
2275        single::<OcString>(reply)
2276    }
2277
2278    /// Get the checksum of the data on this EEPROM.
2279    ///
2280    /// Lua: `eeprom.getChecksum():string`
2281    /// Direct call (runs immediately, drawing on the per-tick budget).
2282    pub fn get_checksum(&self) -> Result<OcString> {
2283        let args = args(vec![]);
2284        let reply = self.invoke("getChecksum", args)?;
2285        single::<OcString>(reply)
2286    }
2287
2288    /// [`Self::get_checksum`] without blocking: the call is queued, and
2289    /// the program keeps running until the result comes back; see [`crate::task`].
2290    #[cfg(feature = "async")]
2291    pub async fn get_checksum_async(&self) -> Result<OcString> {
2292        let args = args(vec![]);
2293        let reply = self.invoke_async("getChecksum", args).await?;
2294        single::<OcString>(reply)
2295    }
2296
2297    /// Get the currently stored byte array.
2298    ///
2299    /// Lua: `eeprom.getData():string`
2300    /// Direct call (runs immediately, drawing on the per-tick budget).
2301    pub fn get_data(&self) -> Result<OcString> {
2302        let args = args(vec![]);
2303        let reply = self.invoke("getData", args)?;
2304        single::<OcString>(reply)
2305    }
2306
2307    /// [`Self::get_data`] without blocking: the call is queued, and
2308    /// the program keeps running until the result comes back; see [`crate::task`].
2309    #[cfg(feature = "async")]
2310    pub async fn get_data_async(&self) -> Result<OcString> {
2311        let args = args(vec![]);
2312        let reply = self.invoke_async("getData", args).await?;
2313        single::<OcString>(reply)
2314    }
2315
2316    /// Get the storage capacity of this EEPROM.
2317    ///
2318    /// Lua: `eeprom.getDataSize():number`
2319    /// Direct call (runs immediately, drawing on the per-tick budget).
2320    pub fn get_data_size(&self) -> Result<Number> {
2321        let args = args(vec![]);
2322        let reply = self.invoke("getDataSize", args)?;
2323        single::<Number>(reply)
2324    }
2325
2326    /// [`Self::get_data_size`] without blocking: the call is queued, and
2327    /// the program keeps running until the result comes back; see [`crate::task`].
2328    #[cfg(feature = "async")]
2329    pub async fn get_data_size_async(&self) -> Result<Number> {
2330        let args = args(vec![]);
2331        let reply = self.invoke_async("getDataSize", args).await?;
2332        single::<Number>(reply)
2333    }
2334
2335    /// Get the label of the EEPROM.
2336    ///
2337    /// Lua: `eeprom.getLabel():string`
2338    /// Direct call (runs immediately, drawing on the per-tick budget).
2339    pub fn get_label(&self) -> Result<OcString> {
2340        let args = args(vec![]);
2341        let reply = self.invoke("getLabel", args)?;
2342        single::<OcString>(reply)
2343    }
2344
2345    /// [`Self::get_label`] without blocking: the call is queued, and
2346    /// the program keeps running until the result comes back; see [`crate::task`].
2347    #[cfg(feature = "async")]
2348    pub async fn get_label_async(&self) -> Result<OcString> {
2349        let args = args(vec![]);
2350        let reply = self.invoke_async("getLabel", args).await?;
2351        single::<OcString>(reply)
2352    }
2353
2354    /// Get the storage capacity of this EEPROM.
2355    ///
2356    /// Lua: `eeprom.getSize():number`
2357    /// Direct call (runs immediately, drawing on the per-tick budget).
2358    pub fn get_size(&self) -> Result<Number> {
2359        let args = args(vec![]);
2360        let reply = self.invoke("getSize", args)?;
2361        single::<Number>(reply)
2362    }
2363
2364    /// [`Self::get_size`] without blocking: the call is queued, and
2365    /// the program keeps running until the result comes back; see [`crate::task`].
2366    #[cfg(feature = "async")]
2367    pub async fn get_size_async(&self) -> Result<Number> {
2368        let args = args(vec![]);
2369        let reply = self.invoke_async("getSize", args).await?;
2370        single::<Number>(reply)
2371    }
2372
2373    /// Make this EEPROM readonly if it isn't already. This process cannot be reversed!
2374    ///
2375    /// Lua: `eeprom.makeReadonly(checksum:string):boolean`
2376    /// Direct call (runs immediately, drawing on the per-tick budget).
2377    pub fn make_readonly(&self, checksum: impl AsRef<[u8]>) -> Result<bool> {
2378        let args = args(vec![Some(Value::text(checksum.as_ref()))]);
2379        let reply = self.invoke("makeReadonly", args)?;
2380        single::<bool>(reply)
2381    }
2382
2383    /// [`Self::make_readonly`] without blocking: the call is queued, and
2384    /// the program keeps running until the result comes back; see [`crate::task`].
2385    #[cfg(feature = "async")]
2386    pub async fn make_readonly_async(&self, checksum: impl AsRef<[u8]>) -> Result<bool> {
2387        let args = args(vec![Some(Value::text(checksum.as_ref()))]);
2388        let reply = self.invoke_async("makeReadonly", args).await?;
2389        single::<bool>(reply)
2390    }
2391
2392    /// Overwrite the currently stored byte array.
2393    ///
2394    /// Lua: `eeprom.set(data:string)`
2395    /// Indirect call: waits for the next server tick.
2396    pub fn set(&self, data: impl AsRef<[u8]>) -> Result<()> {
2397        let args = args(vec![Some(Value::text(data.as_ref()))]);
2398        let reply = self.invoke("set", args)?;
2399        FromReply::from_reply(reply)
2400    }
2401
2402    /// [`Self::set`] without blocking: the call is queued, and
2403    /// the program keeps running until the result comes back; see [`crate::task`].
2404    #[cfg(feature = "async")]
2405    pub async fn set_async(&self, data: impl AsRef<[u8]>) -> Result<()> {
2406        let args = args(vec![Some(Value::text(data.as_ref()))]);
2407        let reply = self.invoke_async("set", args).await?;
2408        FromReply::from_reply(reply)
2409    }
2410
2411    /// Overwrite the currently stored byte array.
2412    ///
2413    /// Lua: `eeprom.setData(data:string)`
2414    /// Indirect call: waits for the next server tick.
2415    pub fn set_data(&self, data: impl AsRef<[u8]>) -> Result<()> {
2416        let args = args(vec![Some(Value::text(data.as_ref()))]);
2417        let reply = self.invoke("setData", args)?;
2418        FromReply::from_reply(reply)
2419    }
2420
2421    /// [`Self::set_data`] without blocking: the call is queued, and
2422    /// the program keeps running until the result comes back; see [`crate::task`].
2423    #[cfg(feature = "async")]
2424    pub async fn set_data_async(&self, data: impl AsRef<[u8]>) -> Result<()> {
2425        let args = args(vec![Some(Value::text(data.as_ref()))]);
2426        let reply = self.invoke_async("setData", args).await?;
2427        FromReply::from_reply(reply)
2428    }
2429
2430    /// Set the label of the EEPROM.
2431    ///
2432    /// Lua: `eeprom.setLabel(data:string):string`
2433    /// Indirect call: waits for the next server tick.
2434    pub fn set_label(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
2435        let args = args(vec![Some(Value::text(data.as_ref()))]);
2436        let reply = self.invoke("setLabel", args)?;
2437        single::<OcString>(reply)
2438    }
2439
2440    /// [`Self::set_label`] without blocking: the call is queued, and
2441    /// the program keeps running until the result comes back; see [`crate::task`].
2442    #[cfg(feature = "async")]
2443    pub async fn set_label_async(&self, data: impl AsRef<[u8]>) -> Result<OcString> {
2444        let args = args(vec![Some(Value::text(data.as_ref()))]);
2445        let reply = self.invoke_async("setLabel", args).await?;
2446        single::<OcString>(reply)
2447    }
2448}
2449
2450/// The `energy_device` component (4 methods).
2451///
2452/// Provided by OpenComputers' `DriverEnergyStorage$Environment`.
2453#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2454pub struct EnergyDevice(pub Address);
2455
2456impl Component for EnergyDevice {
2457    const KIND: &'static str = "energy_device";
2458    fn from_address(address: Address) -> Self {
2459        Self(address)
2460    }
2461    fn address(&self) -> &Address {
2462        &self.0
2463    }
2464}
2465
2466impl EnergyDevice {
2467    /// Returns whether this component can have energy extracted from the connected side.
2468    ///
2469    /// Lua: `energy_device.canExtract():boolean`
2470    /// Indirect call: waits for the next server tick.
2471    pub fn can_extract(&self) -> Result<bool> {
2472        let args = args(vec![]);
2473        let reply = self.invoke("canExtract", args)?;
2474        single::<bool>(reply)
2475    }
2476
2477    /// [`Self::can_extract`] without blocking: the call is queued, and
2478    /// the program keeps running until the result comes back; see [`crate::task`].
2479    #[cfg(feature = "async")]
2480    pub async fn can_extract_async(&self) -> Result<bool> {
2481        let args = args(vec![]);
2482        let reply = self.invoke_async("canExtract", args).await?;
2483        single::<bool>(reply)
2484    }
2485
2486    /// Returns whether this component can receive energy on the connected side.
2487    ///
2488    /// Lua: `energy_device.canReceive():boolean`
2489    /// Indirect call: waits for the next server tick.
2490    pub fn can_receive(&self) -> Result<bool> {
2491        let args = args(vec![]);
2492        let reply = self.invoke("canReceive", args)?;
2493        single::<bool>(reply)
2494    }
2495
2496    /// [`Self::can_receive`] without blocking: the call is queued, and
2497    /// the program keeps running until the result comes back; see [`crate::task`].
2498    #[cfg(feature = "async")]
2499    pub async fn can_receive_async(&self) -> Result<bool> {
2500        let args = args(vec![]);
2501        let reply = self.invoke_async("canReceive", args).await?;
2502        single::<bool>(reply)
2503    }
2504
2505    /// Returns the amount of stored energy on the connected side.
2506    ///
2507    /// Lua: `energy_device.getEnergyStored():number`
2508    /// Indirect call: waits for the next server tick.
2509    pub fn get_energy_stored(&self) -> Result<Number> {
2510        let args = args(vec![]);
2511        let reply = self.invoke("getEnergyStored", args)?;
2512        single::<Number>(reply)
2513    }
2514
2515    /// [`Self::get_energy_stored`] without blocking: the call is queued, and
2516    /// the program keeps running until the result comes back; see [`crate::task`].
2517    #[cfg(feature = "async")]
2518    pub async fn get_energy_stored_async(&self) -> Result<Number> {
2519        let args = args(vec![]);
2520        let reply = self.invoke_async("getEnergyStored", args).await?;
2521        single::<Number>(reply)
2522    }
2523
2524    /// Returns the maximum amount of stored energy on the connected side.
2525    ///
2526    /// Lua: `energy_device.getMaxEnergyStored():number`
2527    /// Indirect call: waits for the next server tick.
2528    pub fn get_max_energy_stored(&self) -> Result<Number> {
2529        let args = args(vec![]);
2530        let reply = self.invoke("getMaxEnergyStored", args)?;
2531        single::<Number>(reply)
2532    }
2533
2534    /// [`Self::get_max_energy_stored`] without blocking: the call is queued, and
2535    /// the program keeps running until the result comes back; see [`crate::task`].
2536    #[cfg(feature = "async")]
2537    pub async fn get_max_energy_stored_async(&self) -> Result<Number> {
2538        let args = args(vec![]);
2539        let reply = self.invoke_async("getMaxEnergyStored", args).await?;
2540        single::<Number>(reply)
2541    }
2542}
2543
2544/// The `experience` component (2 methods).
2545///
2546/// Provided by OpenComputers' `UpgradeExperience`.
2547#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2548pub struct Experience(pub Address);
2549
2550impl Component for Experience {
2551    const KIND: &'static str = "experience";
2552    fn from_address(address: Address) -> Self {
2553        Self(address)
2554    }
2555    fn address(&self) -> &Address {
2556        &self.0
2557    }
2558}
2559
2560impl Experience {
2561    /// Tries to consume an enchanted item to add experience to the upgrade.
2562    ///
2563    /// Lua: `experience.consume():boolean`
2564    /// Indirect call: waits for the next server tick.
2565    pub fn consume(&self) -> Result<bool> {
2566        let args = args(vec![]);
2567        let reply = self.invoke("consume", args)?;
2568        single::<bool>(reply)
2569    }
2570
2571    /// [`Self::consume`] without blocking: the call is queued, and
2572    /// the program keeps running until the result comes back; see [`crate::task`].
2573    #[cfg(feature = "async")]
2574    pub async fn consume_async(&self) -> Result<bool> {
2575        let args = args(vec![]);
2576        let reply = self.invoke_async("consume", args).await?;
2577        single::<bool>(reply)
2578    }
2579
2580    /// The current level of experience stored in this experience upgrade.
2581    ///
2582    /// Lua: `experience.level():number`
2583    /// Direct call (runs immediately, drawing on the per-tick budget).
2584    pub fn level(&self) -> Result<Number> {
2585        let args = args(vec![]);
2586        let reply = self.invoke("level", args)?;
2587        single::<Number>(reply)
2588    }
2589
2590    /// [`Self::level`] without blocking: the call is queued, and
2591    /// the program keeps running until the result comes back; see [`crate::task`].
2592    #[cfg(feature = "async")]
2593    pub async fn level_async(&self) -> Result<Number> {
2594        let args = args(vec![]);
2595        let reply = self.invoke_async("level", args).await?;
2596        single::<Number>(reply)
2597    }
2598}
2599
2600/// The `filesystem` component (18 methods).
2601///
2602/// Provided by OpenComputers' `FileSystem`.
2603#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2604pub struct Filesystem(pub Address);
2605
2606impl Component for Filesystem {
2607    const KIND: &'static str = "filesystem";
2608    fn from_address(address: Address) -> Self {
2609        Self(address)
2610    }
2611    fn address(&self) -> &Address {
2612        &self.0
2613    }
2614}
2615
2616impl Filesystem {
2617    /// Closes an open file descriptor with the specified handle.
2618    ///
2619    /// Lua: `filesystem.close(handle:userdata)`
2620    /// Direct call (runs immediately, drawing on the per-tick budget).
2621    pub fn close(&self, handle: Handle) -> Result<()> {
2622        let args = args(vec![Some(Value::Handle(handle))]);
2623        let reply = self.invoke("close", args)?;
2624        FromReply::from_reply(reply)
2625    }
2626
2627    /// [`Self::close`] without blocking: the call is queued, and
2628    /// the program keeps running until the result comes back; see [`crate::task`].
2629    #[cfg(feature = "async")]
2630    pub async fn close_async(&self, handle: Handle) -> Result<()> {
2631        let args = args(vec![Some(Value::Handle(handle))]);
2632        let reply = self.invoke_async("close", args).await?;
2633        FromReply::from_reply(reply)
2634    }
2635
2636    /// Returns whether an object exists at the specified absolute path in the file system.
2637    ///
2638    /// Lua: `filesystem.exists(path:string):boolean`
2639    /// Direct call (runs immediately, drawing on the per-tick budget).
2640    pub fn exists(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2641        let args = args(vec![Some(Value::text(path.as_ref()))]);
2642        let reply = self.invoke("exists", args)?;
2643        single::<bool>(reply)
2644    }
2645
2646    /// [`Self::exists`] without blocking: the call is queued, and
2647    /// the program keeps running until the result comes back; see [`crate::task`].
2648    #[cfg(feature = "async")]
2649    pub async fn exists_async(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2650        let args = args(vec![Some(Value::text(path.as_ref()))]);
2651        let reply = self.invoke_async("exists", args).await?;
2652        single::<bool>(reply)
2653    }
2654
2655    /// Get the current label of the drive.
2656    ///
2657    /// Lua: `filesystem.getLabel():string`
2658    /// Direct call (runs immediately, drawing on the per-tick budget).
2659    pub fn get_label(&self) -> Result<OcString> {
2660        let args = args(vec![]);
2661        let reply = self.invoke("getLabel", args)?;
2662        single::<OcString>(reply)
2663    }
2664
2665    /// [`Self::get_label`] without blocking: the call is queued, and
2666    /// the program keeps running until the result comes back; see [`crate::task`].
2667    #[cfg(feature = "async")]
2668    pub async fn get_label_async(&self) -> Result<OcString> {
2669        let args = args(vec![]);
2670        let reply = self.invoke_async("getLabel", args).await?;
2671        single::<OcString>(reply)
2672    }
2673
2674    /// Returns whether the object at the specified absolute path in the file system is a directory.
2675    ///
2676    /// Lua: `filesystem.isDirectory(path:string):boolean`
2677    /// Direct call (runs immediately, drawing on the per-tick budget).
2678    pub fn is_directory(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2679        let args = args(vec![Some(Value::text(path.as_ref()))]);
2680        let reply = self.invoke("isDirectory", args)?;
2681        single::<bool>(reply)
2682    }
2683
2684    /// [`Self::is_directory`] without blocking: the call is queued, and
2685    /// the program keeps running until the result comes back; see [`crate::task`].
2686    #[cfg(feature = "async")]
2687    pub async fn is_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2688        let args = args(vec![Some(Value::text(path.as_ref()))]);
2689        let reply = self.invoke_async("isDirectory", args).await?;
2690        single::<bool>(reply)
2691    }
2692
2693    /// Returns whether the file system is read-only.
2694    ///
2695    /// Lua: `filesystem.isReadOnly():boolean`
2696    /// Direct call (runs immediately, drawing on the per-tick budget).
2697    pub fn is_read_only(&self) -> Result<bool> {
2698        let args = args(vec![]);
2699        let reply = self.invoke("isReadOnly", args)?;
2700        single::<bool>(reply)
2701    }
2702
2703    /// [`Self::is_read_only`] without blocking: the call is queued, and
2704    /// the program keeps running until the result comes back; see [`crate::task`].
2705    #[cfg(feature = "async")]
2706    pub async fn is_read_only_async(&self) -> Result<bool> {
2707        let args = args(vec![]);
2708        let reply = self.invoke_async("isReadOnly", args).await?;
2709        single::<bool>(reply)
2710    }
2711
2712    /// Returns the (real world) timestamp of when the object at the specified absolute path in the file system was modified.
2713    ///
2714    /// Lua: `filesystem.lastModified(path:string):number`
2715    /// Direct call (runs immediately, drawing on the per-tick budget).
2716    pub fn last_modified(&self, path: impl AsRef<[u8]>) -> Result<Number> {
2717        let args = args(vec![Some(Value::text(path.as_ref()))]);
2718        let reply = self.invoke("lastModified", args)?;
2719        single::<Number>(reply)
2720    }
2721
2722    /// [`Self::last_modified`] without blocking: the call is queued, and
2723    /// the program keeps running until the result comes back; see [`crate::task`].
2724    #[cfg(feature = "async")]
2725    pub async fn last_modified_async(&self, path: impl AsRef<[u8]>) -> Result<Number> {
2726        let args = args(vec![Some(Value::text(path.as_ref()))]);
2727        let reply = self.invoke_async("lastModified", args).await?;
2728        single::<Number>(reply)
2729    }
2730
2731    /// Returns a list of names of objects in the directory at the specified absolute path in the file system.
2732    ///
2733    /// Lua: `filesystem.list(path:string):table`
2734    /// Indirect call: waits for the next server tick.
2735    pub fn list(&self, path: impl AsRef<[u8]>) -> Result<Value> {
2736        let args = args(vec![Some(Value::text(path.as_ref()))]);
2737        let reply = self.invoke("list", args)?;
2738        single::<Value>(reply)
2739    }
2740
2741    /// [`Self::list`] without blocking: the call is queued, and
2742    /// the program keeps running until the result comes back; see [`crate::task`].
2743    #[cfg(feature = "async")]
2744    pub async fn list_async(&self, path: impl AsRef<[u8]>) -> Result<Value> {
2745        let args = args(vec![Some(Value::text(path.as_ref()))]);
2746        let reply = self.invoke_async("list", args).await?;
2747        single::<Value>(reply)
2748    }
2749
2750    /// Creates a directory at the specified absolute path in the file system. Creates parent directories, if necessary.
2751    ///
2752    /// Lua: `filesystem.makeDirectory(path:string):boolean`
2753    /// Indirect call: waits for the next server tick.
2754    pub fn make_directory(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2755        let args = args(vec![Some(Value::text(path.as_ref()))]);
2756        let reply = self.invoke("makeDirectory", args)?;
2757        single::<bool>(reply)
2758    }
2759
2760    /// [`Self::make_directory`] without blocking: the call is queued, and
2761    /// the program keeps running until the result comes back; see [`crate::task`].
2762    #[cfg(feature = "async")]
2763    pub async fn make_directory_async(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2764        let args = args(vec![Some(Value::text(path.as_ref()))]);
2765        let reply = self.invoke_async("makeDirectory", args).await?;
2766        single::<bool>(reply)
2767    }
2768
2769    /// Opens a new file descriptor and returns its handle.
2770    ///
2771    /// Lua: `filesystem.open(path:string[, mode:string='r']):userdata`
2772    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 4).
2773    /// `mode` defaults to `'r'`.
2774    pub fn open(&self, path: impl AsRef<[u8]>, mode: Option<&str>) -> Result<Handle> {
2775        let args = args(vec![Some(Value::text(path.as_ref())), mode.map(Value::from)]);
2776        let reply = self.invoke("open", args)?;
2777        single::<Handle>(reply)
2778    }
2779
2780    /// [`Self::open`] without blocking: the call is queued, and
2781    /// the program keeps running until the result comes back; see [`crate::task`].
2782    #[cfg(feature = "async")]
2783    pub async fn open_async(&self, path: impl AsRef<[u8]>, mode: Option<&str>) -> Result<Handle> {
2784        let args = args(vec![Some(Value::text(path.as_ref())), mode.map(Value::from)]);
2785        let reply = self.invoke_async("open", args).await?;
2786        single::<Handle>(reply)
2787    }
2788
2789    /// Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.
2790    ///
2791    /// Lua: `filesystem.read(handle:userdata, count:number):string or nil`
2792    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 15).
2793    pub fn read(&self, handle: Handle, count: impl Into<Number>) -> Result<Option<OcString>> {
2794        let args = args(vec![Some(Value::Handle(handle)), Some(Value::Number(count.into()))]);
2795        let reply = self.invoke("read", args)?;
2796        single::<Option<OcString>>(reply)
2797    }
2798
2799    /// [`Self::read`] without blocking: the call is queued, and
2800    /// the program keeps running until the result comes back; see [`crate::task`].
2801    #[cfg(feature = "async")]
2802    pub async fn read_async(&self, handle: Handle, count: impl Into<Number>) -> Result<Option<OcString>> {
2803        let args = args(vec![Some(Value::Handle(handle)), Some(Value::Number(count.into()))]);
2804        let reply = self.invoke_async("read", args).await?;
2805        single::<Option<OcString>>(reply)
2806    }
2807
2808    /// Removes the object at the specified absolute path in the file system.
2809    ///
2810    /// Lua: `filesystem.remove(path:string):boolean`
2811    /// Indirect call: waits for the next server tick.
2812    pub fn remove(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2813        let args = args(vec![Some(Value::text(path.as_ref()))]);
2814        let reply = self.invoke("remove", args)?;
2815        single::<bool>(reply)
2816    }
2817
2818    /// [`Self::remove`] without blocking: the call is queued, and
2819    /// the program keeps running until the result comes back; see [`crate::task`].
2820    #[cfg(feature = "async")]
2821    pub async fn remove_async(&self, path: impl AsRef<[u8]>) -> Result<bool> {
2822        let args = args(vec![Some(Value::text(path.as_ref()))]);
2823        let reply = self.invoke_async("remove", args).await?;
2824        single::<bool>(reply)
2825    }
2826
2827    /// Renames/moves an object from the first specified absolute path in the file system to the second.
2828    ///
2829    /// Lua: `filesystem.rename(from:string, to:string):boolean`
2830    /// Indirect call: waits for the next server tick.
2831    pub fn rename(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<bool> {
2832        let args = args(vec![Some(Value::text(from.as_ref())), Some(Value::text(to.as_ref()))]);
2833        let reply = self.invoke("rename", args)?;
2834        single::<bool>(reply)
2835    }
2836
2837    /// [`Self::rename`] without blocking: the call is queued, and
2838    /// the program keeps running until the result comes back; see [`crate::task`].
2839    #[cfg(feature = "async")]
2840    pub async fn rename_async(&self, from: impl AsRef<[u8]>, to: impl AsRef<[u8]>) -> Result<bool> {
2841        let args = args(vec![Some(Value::text(from.as_ref())), Some(Value::text(to.as_ref()))]);
2842        let reply = self.invoke_async("rename", args).await?;
2843        single::<bool>(reply)
2844    }
2845
2846    /// Seeks in an open file descriptor with the specified handle. Returns the new pointer position.
2847    ///
2848    /// Lua: `filesystem.seek(handle:userdata, whence:string, offset:number):number`
2849    /// Direct call (runs immediately, drawing on the per-tick budget).
2850    pub fn seek(&self, handle: Handle, whence: impl AsRef<[u8]>, offset: impl Into<Number>) -> Result<Number> {
2851        let args = args(vec![Some(Value::Handle(handle)), Some(Value::text(whence.as_ref())), Some(Value::Number(offset.into()))]);
2852        let reply = self.invoke("seek", args)?;
2853        single::<Number>(reply)
2854    }
2855
2856    /// [`Self::seek`] without blocking: the call is queued, and
2857    /// the program keeps running until the result comes back; see [`crate::task`].
2858    #[cfg(feature = "async")]
2859    pub async fn seek_async(&self, handle: Handle, whence: impl AsRef<[u8]>, offset: impl Into<Number>) -> Result<Number> {
2860        let args = args(vec![Some(Value::Handle(handle)), Some(Value::text(whence.as_ref())), Some(Value::Number(offset.into()))]);
2861        let reply = self.invoke_async("seek", args).await?;
2862        single::<Number>(reply)
2863    }
2864
2865    /// Sets the label of the drive. Returns the new value, which may be truncated.
2866    ///
2867    /// Lua: `filesystem.setLabel(value:string):string`
2868    /// Indirect call: waits for the next server tick.
2869    pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
2870        let args = args(vec![Some(Value::text(value.as_ref()))]);
2871        let reply = self.invoke("setLabel", args)?;
2872        single::<OcString>(reply)
2873    }
2874
2875    /// [`Self::set_label`] without blocking: the call is queued, and
2876    /// the program keeps running until the result comes back; see [`crate::task`].
2877    #[cfg(feature = "async")]
2878    pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<OcString> {
2879        let args = args(vec![Some(Value::text(value.as_ref()))]);
2880        let reply = self.invoke_async("setLabel", args).await?;
2881        single::<OcString>(reply)
2882    }
2883
2884    /// Returns the size of the object at the specified absolute path in the file system.
2885    ///
2886    /// Lua: `filesystem.size(path:string):number`
2887    /// Direct call (runs immediately, drawing on the per-tick budget).
2888    pub fn size(&self, path: impl AsRef<[u8]>) -> Result<Number> {
2889        let args = args(vec![Some(Value::text(path.as_ref()))]);
2890        let reply = self.invoke("size", args)?;
2891        single::<Number>(reply)
2892    }
2893
2894    /// [`Self::size`] without blocking: the call is queued, and
2895    /// the program keeps running until the result comes back; see [`crate::task`].
2896    #[cfg(feature = "async")]
2897    pub async fn size_async(&self, path: impl AsRef<[u8]>) -> Result<Number> {
2898        let args = args(vec![Some(Value::text(path.as_ref()))]);
2899        let reply = self.invoke_async("size", args).await?;
2900        single::<Number>(reply)
2901    }
2902
2903    /// The overall capacity of the file system, in bytes.
2904    ///
2905    /// Lua: `filesystem.spaceTotal():number`
2906    /// Direct call (runs immediately, drawing on the per-tick budget).
2907    pub fn space_total(&self) -> Result<Number> {
2908        let args = args(vec![]);
2909        let reply = self.invoke("spaceTotal", args)?;
2910        single::<Number>(reply)
2911    }
2912
2913    /// [`Self::space_total`] without blocking: the call is queued, and
2914    /// the program keeps running until the result comes back; see [`crate::task`].
2915    #[cfg(feature = "async")]
2916    pub async fn space_total_async(&self) -> Result<Number> {
2917        let args = args(vec![]);
2918        let reply = self.invoke_async("spaceTotal", args).await?;
2919        single::<Number>(reply)
2920    }
2921
2922    /// The currently used capacity of the file system, in bytes.
2923    ///
2924    /// Lua: `filesystem.spaceUsed():number`
2925    /// Direct call (runs immediately, drawing on the per-tick budget).
2926    pub fn space_used(&self) -> Result<Number> {
2927        let args = args(vec![]);
2928        let reply = self.invoke("spaceUsed", args)?;
2929        single::<Number>(reply)
2930    }
2931
2932    /// [`Self::space_used`] without blocking: the call is queued, and
2933    /// the program keeps running until the result comes back; see [`crate::task`].
2934    #[cfg(feature = "async")]
2935    pub async fn space_used_async(&self) -> Result<Number> {
2936        let args = args(vec![]);
2937        let reply = self.invoke_async("spaceUsed", args).await?;
2938        single::<Number>(reply)
2939    }
2940
2941    /// Writes the specified data to an open file descriptor with the specified handle.
2942    ///
2943    /// Lua: `filesystem.write(handle:userdata, value:string):boolean`
2944    /// Direct call (runs immediately, drawing on the per-tick budget).
2945    pub fn write(&self, handle: Handle, value: impl AsRef<[u8]>) -> Result<bool> {
2946        let args = args(vec![Some(Value::Handle(handle)), Some(Value::text(value.as_ref()))]);
2947        let reply = self.invoke("write", args)?;
2948        single::<bool>(reply)
2949    }
2950
2951    /// [`Self::write`] without blocking: the call is queued, and
2952    /// the program keeps running until the result comes back; see [`crate::task`].
2953    #[cfg(feature = "async")]
2954    pub async fn write_async(&self, handle: Handle, value: impl AsRef<[u8]>) -> Result<bool> {
2955        let args = args(vec![Some(Value::Handle(handle)), Some(Value::text(value.as_ref()))]);
2956        let reply = self.invoke_async("write", args).await?;
2957        single::<bool>(reply)
2958    }
2959}
2960
2961/// The `fluid_handler` component (1 methods).
2962///
2963/// Provided by OpenComputers' `DriverFluidHandler$Environment`.
2964#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2965pub struct FluidHandler(pub Address);
2966
2967impl Component for FluidHandler {
2968    const KIND: &'static str = "fluid_handler";
2969    fn from_address(address: Address) -> Self {
2970        Self(address)
2971    }
2972    fn address(&self) -> &Address {
2973        &self.0
2974    }
2975}
2976
2977impl FluidHandler {
2978    /// Get some information about the tank accessible from the specified side.
2979    ///
2980    /// Lua: `fluid_handler.getTankInfo():table`
2981    /// Indirect call: waits for the next server tick.
2982    pub fn get_tank_info(&self) -> Result<Value> {
2983        let args = args(vec![]);
2984        let reply = self.invoke("getTankInfo", args)?;
2985        single::<Value>(reply)
2986    }
2987
2988    /// [`Self::get_tank_info`] without blocking: the call is queued, and
2989    /// the program keeps running until the result comes back; see [`crate::task`].
2990    #[cfg(feature = "async")]
2991    pub async fn get_tank_info_async(&self) -> Result<Value> {
2992        let args = args(vec![]);
2993        let reply = self.invoke_async("getTankInfo", args).await?;
2994        single::<Value>(reply)
2995    }
2996}
2997
2998/// The `fluid_tank` component (1 methods).
2999///
3000/// Provided by OpenComputers' `DriverFluidTank$Environment`.
3001#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3002pub struct FluidTank(pub Address);
3003
3004impl Component for FluidTank {
3005    const KIND: &'static str = "fluid_tank";
3006    fn from_address(address: Address) -> Self {
3007        Self(address)
3008    }
3009    fn address(&self) -> &Address {
3010        &self.0
3011    }
3012}
3013
3014impl FluidTank {
3015    /// Get some information about this tank.
3016    ///
3017    /// Lua: `fluid_tank.getInfo():table`
3018    /// Indirect call: waits for the next server tick.
3019    pub fn get_info(&self) -> Result<Value> {
3020        let args = args(vec![]);
3021        let reply = self.invoke("getInfo", args)?;
3022        single::<Value>(reply)
3023    }
3024
3025    /// [`Self::get_info`] without blocking: the call is queued, and
3026    /// the program keeps running until the result comes back; see [`crate::task`].
3027    #[cfg(feature = "async")]
3028    pub async fn get_info_async(&self) -> Result<Value> {
3029        let args = args(vec![]);
3030        let reply = self.invoke_async("getInfo", args).await?;
3031        single::<Value>(reply)
3032    }
3033}
3034
3035/// The `furnace` component (5 methods).
3036///
3037/// Provided by OpenComputers' `DriverFurnace$Environment`.
3038#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3039pub struct Furnace(pub Address);
3040
3041impl Component for Furnace {
3042    const KIND: &'static str = "furnace";
3043    fn from_address(address: Address) -> Self {
3044        Self(address)
3045    }
3046    fn address(&self) -> &Address {
3047        &self.0
3048    }
3049}
3050
3051impl Furnace {
3052    /// The number of ticks that the furnace will keep burning from the last consumed fuel.
3053    ///
3054    /// Lua: `furnace.getBurnTime():number`
3055    /// Indirect call: waits for the next server tick.
3056    pub fn get_burn_time(&self) -> Result<Number> {
3057        let args = args(vec![]);
3058        let reply = self.invoke("getBurnTime", args)?;
3059        single::<Number>(reply)
3060    }
3061
3062    /// [`Self::get_burn_time`] without blocking: the call is queued, and
3063    /// the program keeps running until the result comes back; see [`crate::task`].
3064    #[cfg(feature = "async")]
3065    pub async fn get_burn_time_async(&self) -> Result<Number> {
3066        let args = args(vec![]);
3067        let reply = self.invoke_async("getBurnTime", args).await?;
3068        single::<Number>(reply)
3069    }
3070
3071    /// The number of ticks that the current item has been cooking for.
3072    ///
3073    /// Lua: `furnace.getCookTime():number`
3074    /// Indirect call: waits for the next server tick.
3075    pub fn get_cook_time(&self) -> Result<Number> {
3076        let args = args(vec![]);
3077        let reply = self.invoke("getCookTime", args)?;
3078        single::<Number>(reply)
3079    }
3080
3081    /// [`Self::get_cook_time`] without blocking: the call is queued, and
3082    /// the program keeps running until the result comes back; see [`crate::task`].
3083    #[cfg(feature = "async")]
3084    pub async fn get_cook_time_async(&self) -> Result<Number> {
3085        let args = args(vec![]);
3086        let reply = self.invoke_async("getCookTime", args).await?;
3087        single::<Number>(reply)
3088    }
3089
3090    /// The number of ticks that the currently burning fuel lasts in total.
3091    ///
3092    /// Lua: `furnace.getCurrentItemBurnTime():number`
3093    /// Indirect call: waits for the next server tick.
3094    pub fn get_current_item_burn_time(&self) -> Result<Number> {
3095        let args = args(vec![]);
3096        let reply = self.invoke("getCurrentItemBurnTime", args)?;
3097        single::<Number>(reply)
3098    }
3099
3100    /// [`Self::get_current_item_burn_time`] without blocking: the call is queued, and
3101    /// the program keeps running until the result comes back; see [`crate::task`].
3102    #[cfg(feature = "async")]
3103    pub async fn get_current_item_burn_time_async(&self) -> Result<Number> {
3104        let args = args(vec![]);
3105        let reply = self.invoke_async("getCurrentItemBurnTime", args).await?;
3106        single::<Number>(reply)
3107    }
3108
3109    /// The number of ticks that the current item needs to cook.
3110    ///
3111    /// Lua: `furnace.getTotalCookTime():number`
3112    /// Indirect call: waits for the next server tick.
3113    pub fn get_total_cook_time(&self) -> Result<Number> {
3114        let args = args(vec![]);
3115        let reply = self.invoke("getTotalCookTime", args)?;
3116        single::<Number>(reply)
3117    }
3118
3119    /// [`Self::get_total_cook_time`] without blocking: the call is queued, and
3120    /// the program keeps running until the result comes back; see [`crate::task`].
3121    #[cfg(feature = "async")]
3122    pub async fn get_total_cook_time_async(&self) -> Result<Number> {
3123        let args = args(vec![]);
3124        let reply = self.invoke_async("getTotalCookTime", args).await?;
3125        single::<Number>(reply)
3126    }
3127
3128    /// Get whether the furnace is currently active.
3129    ///
3130    /// Lua: `furnace.isBurning():boolean`
3131    /// Indirect call: waits for the next server tick.
3132    pub fn is_burning(&self) -> Result<bool> {
3133        let args = args(vec![]);
3134        let reply = self.invoke("isBurning", args)?;
3135        single::<bool>(reply)
3136    }
3137
3138    /// [`Self::is_burning`] without blocking: the call is queued, and
3139    /// the program keeps running until the result comes back; see [`crate::task`].
3140    #[cfg(feature = "async")]
3141    pub async fn is_burning_async(&self) -> Result<bool> {
3142        let args = args(vec![]);
3143        let reply = self.invoke_async("isBurning", args).await?;
3144        single::<bool>(reply)
3145    }
3146}
3147
3148/// The `generator` component (3 methods).
3149///
3150/// Provided by OpenComputers' `UpgradeGenerator`.
3151#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3152pub struct Generator(pub Address);
3153
3154impl Component for Generator {
3155    const KIND: &'static str = "generator";
3156    fn from_address(address: Address) -> Self {
3157        Self(address)
3158    }
3159    fn address(&self) -> &Address {
3160        &self.0
3161    }
3162}
3163
3164impl Generator {
3165    /// Get the size of the item stack in the generator's queue.
3166    ///
3167    /// Lua: `generator.count():number`
3168    /// Indirect call: waits for the next server tick.
3169    pub fn count(&self) -> Result<Number> {
3170        let args = args(vec![]);
3171        let reply = self.invoke("count", args)?;
3172        single::<Number>(reply)
3173    }
3174
3175    /// [`Self::count`] without blocking: the call is queued, and
3176    /// the program keeps running until the result comes back; see [`crate::task`].
3177    #[cfg(feature = "async")]
3178    pub async fn count_async(&self) -> Result<Number> {
3179        let args = args(vec![]);
3180        let reply = self.invoke_async("count", args).await?;
3181        single::<Number>(reply)
3182    }
3183
3184    /// Tries to insert fuel from the selected slot into the generator's queue.
3185    ///
3186    /// Lua: `generator.insert([count:number]):boolean`
3187    /// Indirect call: waits for the next server tick.
3188    pub fn insert(&self, count: Option<Number>) -> Result<bool> {
3189        let args = args(vec![count.map(Value::Number)]);
3190        let reply = self.invoke("insert", args)?;
3191        single::<bool>(reply)
3192    }
3193
3194    /// [`Self::insert`] without blocking: the call is queued, and
3195    /// the program keeps running until the result comes back; see [`crate::task`].
3196    #[cfg(feature = "async")]
3197    pub async fn insert_async(&self, count: Option<Number>) -> Result<bool> {
3198        let args = args(vec![count.map(Value::Number)]);
3199        let reply = self.invoke_async("insert", args).await?;
3200        single::<bool>(reply)
3201    }
3202
3203    /// Tries to remove items from the generator's queue.
3204    ///
3205    /// Lua: `generator.remove([count:number]):boolean`
3206    /// Indirect call: waits for the next server tick.
3207    pub fn remove(&self, count: Option<Number>) -> Result<bool> {
3208        let args = args(vec![count.map(Value::Number)]);
3209        let reply = self.invoke("remove", args)?;
3210        single::<bool>(reply)
3211    }
3212
3213    /// [`Self::remove`] without blocking: the call is queued, and
3214    /// the program keeps running until the result comes back; see [`crate::task`].
3215    #[cfg(feature = "async")]
3216    pub async fn remove_async(&self, count: Option<Number>) -> Result<bool> {
3217        let args = args(vec![count.map(Value::Number)]);
3218        let reply = self.invoke_async("remove", args).await?;
3219        single::<bool>(reply)
3220    }
3221}
3222
3223/// The `geolyzer` component (6 methods).
3224///
3225/// Provided by OpenComputers' `Geolyzer, GeolyzerBase`.
3226#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3227pub struct Geolyzer(pub Address);
3228
3229impl Component for Geolyzer {
3230    const KIND: &'static str = "geolyzer";
3231    fn from_address(address: Address) -> Self {
3232        Self(address)
3233    }
3234    fn address(&self) -> &Address {
3235        &self.0
3236    }
3237}
3238
3239impl Geolyzer {
3240    /// Get some information on a directly adjacent block.
3241    ///
3242    /// Lua: `geolyzer.analyze(side:number[,options:table]):table`
3243    /// Indirect call: waits for the next server tick.
3244    pub fn analyze(&self, side: impl Into<Number>, options: Option<Value>) -> Result<Value> {
3245        let args = args(vec![Some(Value::Number(side.into())), options]);
3246        let reply = self.invoke("analyze", args)?;
3247        single::<Value>(reply)
3248    }
3249
3250    /// [`Self::analyze`] without blocking: the call is queued, and
3251    /// the program keeps running until the result comes back; see [`crate::task`].
3252    #[cfg(feature = "async")]
3253    pub async fn analyze_async(&self, side: impl Into<Number>, options: Option<Value>) -> Result<Value> {
3254        let args = args(vec![Some(Value::Number(side.into())), options]);
3255        let reply = self.invoke_async("analyze", args).await?;
3256        single::<Value>(reply)
3257    }
3258
3259    /// Returns whether there is a clear line of sight to the sky directly above.
3260    ///
3261    /// Lua: `geolyzer.canSeeSky():boolean`
3262    /// Indirect call: waits for the next server tick.
3263    pub fn can_see_sky(&self) -> Result<bool> {
3264        let args = args(vec![]);
3265        let reply = self.invoke("canSeeSky", args)?;
3266        single::<bool>(reply)
3267    }
3268
3269    /// [`Self::can_see_sky`] without blocking: the call is queued, and
3270    /// the program keeps running until the result comes back; see [`crate::task`].
3271    #[cfg(feature = "async")]
3272    pub async fn can_see_sky_async(&self) -> Result<bool> {
3273        let args = args(vec![]);
3274        let reply = self.invoke_async("canSeeSky", args).await?;
3275        single::<bool>(reply)
3276    }
3277
3278    /// Checks the contents of the block on the specified sides and returns the findings.
3279    ///
3280    /// Lua: `geolyzer.detect(side:number):boolean, string`
3281    /// Indirect call: waits for the next server tick.
3282    pub fn detect(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
3283        let args = args(vec![Some(Value::Number(side.into()))]);
3284        let reply = self.invoke("detect", args)?;
3285        FromReply::from_reply(reply)
3286    }
3287
3288    /// [`Self::detect`] without blocking: the call is queued, and
3289    /// the program keeps running until the result comes back; see [`crate::task`].
3290    #[cfg(feature = "async")]
3291    pub async fn detect_async(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
3292        let args = args(vec![Some(Value::Number(side.into()))]);
3293        let reply = self.invoke_async("detect", args).await?;
3294        FromReply::from_reply(reply)
3295    }
3296
3297    /// Return whether the sun is currently visible directly above.
3298    ///
3299    /// Lua: `geolyzer.isSunVisible():boolean`
3300    /// Indirect call: waits for the next server tick.
3301    pub fn is_sun_visible(&self) -> Result<bool> {
3302        let args = args(vec![]);
3303        let reply = self.invoke("isSunVisible", args)?;
3304        single::<bool>(reply)
3305    }
3306
3307    /// [`Self::is_sun_visible`] without blocking: the call is queued, and
3308    /// the program keeps running until the result comes back; see [`crate::task`].
3309    #[cfg(feature = "async")]
3310    pub async fn is_sun_visible_async(&self) -> Result<bool> {
3311        let args = args(vec![]);
3312        let reply = self.invoke_async("isSunVisible", args).await?;
3313        single::<bool>(reply)
3314    }
3315
3316    /// Analyzes the density of the column at the specified relative coordinates.
3317    ///
3318    /// Lua: `geolyzer.scan(x:number, z:number[, y:number, w:number, d:number, h:number][, ignoreReplaceable:boolean|options:table]):table`
3319    /// Indirect call: waits for the next server tick.
3320    pub fn scan(&self, x: impl Into<Number>, z: impl Into<Number>, y: Option<Number>, w: Option<Number>, d: Option<Number>, h: Option<Number>, ignore_replaceable: Option<Value>) -> Result<Value> {
3321        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), y.map(Value::Number), w.map(Value::Number), d.map(Value::Number), h.map(Value::Number), ignore_replaceable]);
3322        let reply = self.invoke("scan", args)?;
3323        single::<Value>(reply)
3324    }
3325
3326    /// [`Self::scan`] without blocking: the call is queued, and
3327    /// the program keeps running until the result comes back; see [`crate::task`].
3328    #[cfg(feature = "async")]
3329    pub async fn scan_async(&self, x: impl Into<Number>, z: impl Into<Number>, y: Option<Number>, w: Option<Number>, d: Option<Number>, h: Option<Number>, ignore_replaceable: Option<Value>) -> Result<Value> {
3330        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), y.map(Value::Number), w.map(Value::Number), d.map(Value::Number), h.map(Value::Number), ignore_replaceable]);
3331        let reply = self.invoke_async("scan", args).await?;
3332        single::<Value>(reply)
3333    }
3334
3335    /// Store an item stack representation of the block on the specified side in a database component.
3336    ///
3337    /// Lua: `geolyzer.store(side:number, dbAddress:string, dbSlot:number):boolean`
3338    /// Indirect call: waits for the next server tick.
3339    pub fn store(&self, side: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
3340        let args = args(vec![Some(Value::Number(side.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
3341        let reply = self.invoke("store", args)?;
3342        single::<bool>(reply)
3343    }
3344
3345    /// [`Self::store`] without blocking: the call is queued, and
3346    /// the program keeps running until the result comes back; see [`crate::task`].
3347    #[cfg(feature = "async")]
3348    pub async fn store_async(&self, side: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
3349        let args = args(vec![Some(Value::Number(side.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
3350        let reply = self.invoke_async("store", args).await?;
3351        single::<bool>(reply)
3352    }
3353}
3354
3355/// The `gpu` component (30 methods).
3356///
3357/// Provided by OpenComputers' `APU, GraphicsCard, GraphicsCardBase`.
3358#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3359pub struct Gpu(pub Address);
3360
3361impl Component for Gpu {
3362    const KIND: &'static str = "gpu";
3363    fn from_address(address: Address) -> Self {
3364        Self(address)
3365    }
3366    fn address(&self) -> &Address {
3367        &self.0
3368    }
3369}
3370
3371impl Gpu {
3372    /// allocates a new buffer with dimensions width*height (defaults to max resolution) and appends it to the buffer list. Returns the index of the new buffer and returns nil with an error message on failure. A buffer can be allocated even when there is no screen bound to this gpu. Index 0 is always reserved for the screen and thus the lowest index of an allocated buffer is always 1.
3373    ///
3374    /// Lua: `gpu.allocateBuffer([width: number, height: number]): number`
3375    /// Direct call (runs immediately, drawing on the per-tick budget).
3376    pub fn allocate_buffer(&self, width: Option<Number>, height: Option<Number>) -> Result<Number> {
3377        let args = args(vec![width.map(Value::Number), height.map(Value::Number)]);
3378        let reply = self.invoke("allocateBuffer", args)?;
3379        single::<Number>(reply)
3380    }
3381
3382    /// [`Self::allocate_buffer`] without blocking: the call is queued, and
3383    /// the program keeps running until the result comes back; see [`crate::task`].
3384    #[cfg(feature = "async")]
3385    pub async fn allocate_buffer_async(&self, width: Option<Number>, height: Option<Number>) -> Result<Number> {
3386        let args = args(vec![width.map(Value::Number), height.map(Value::Number)]);
3387        let reply = self.invoke_async("allocateBuffer", args).await?;
3388        single::<Number>(reply)
3389    }
3390
3391    /// Binds the GPU to the screen with the specified address and resets screen settings if `reset` is true.
3392    ///
3393    /// Lua: `gpu.bind(address:string[, reset:boolean=true]):boolean`
3394    /// Indirect call: waits for the next server tick.
3395    /// `reset` defaults to `true`.
3396    pub fn bind(&self, address: impl AsRef<[u8]>, reset: Option<bool>) -> Result<bool> {
3397        let args = args(vec![Some(Value::text(address.as_ref())), reset.map(Value::Bool)]);
3398        let reply = self.invoke("bind", args)?;
3399        single::<bool>(reply)
3400    }
3401
3402    /// [`Self::bind`] without blocking: the call is queued, and
3403    /// the program keeps running until the result comes back; see [`crate::task`].
3404    #[cfg(feature = "async")]
3405    pub async fn bind_async(&self, address: impl AsRef<[u8]>, reset: Option<bool>) -> Result<bool> {
3406        let args = args(vec![Some(Value::text(address.as_ref())), reset.map(Value::Bool)]);
3407        let reply = self.invoke_async("bind", args).await?;
3408        single::<bool>(reply)
3409    }
3410
3411    /// bitblt from buffer to screen. All parameters are optional. Writes to `dst` page in rectangle `x, y, width, height`, defaults to the bound screen and its viewport. Reads data from `src` page at `fx, fy`, default is the active page from position 1, 1
3412    ///
3413    /// Lua: `gpu.bitblt([dst: number, col: number, row: number, width: number, height: number, src: number, fromCol: number, fromRow: number]):boolean`
3414    /// Direct call (runs immediately, drawing on the per-tick budget).
3415    pub fn bitblt(&self, dst: Option<Number>, col: Option<Number>, row: Option<Number>, width: Option<Number>, height: Option<Number>, src: Option<Number>, from_col: Option<Number>, from_row: Option<Number>) -> Result<bool> {
3416        let args = args(vec![dst.map(Value::Number), col.map(Value::Number), row.map(Value::Number), width.map(Value::Number), height.map(Value::Number), src.map(Value::Number), from_col.map(Value::Number), from_row.map(Value::Number)]);
3417        let reply = self.invoke("bitblt", args)?;
3418        single::<bool>(reply)
3419    }
3420
3421    /// [`Self::bitblt`] without blocking: the call is queued, and
3422    /// the program keeps running until the result comes back; see [`crate::task`].
3423    #[cfg(feature = "async")]
3424    pub async fn bitblt_async(&self, dst: Option<Number>, col: Option<Number>, row: Option<Number>, width: Option<Number>, height: Option<Number>, src: Option<Number>, from_col: Option<Number>, from_row: Option<Number>) -> Result<bool> {
3425        let args = args(vec![dst.map(Value::Number), col.map(Value::Number), row.map(Value::Number), width.map(Value::Number), height.map(Value::Number), src.map(Value::Number), from_col.map(Value::Number), from_row.map(Value::Number)]);
3426        let reply = self.invoke_async("bitblt", args).await?;
3427        single::<bool>(reply)
3428    }
3429
3430    /// Returns an array of indexes of the allocated buffers
3431    ///
3432    /// Lua: `gpu.buffers(): number`
3433    /// Direct call (runs immediately, drawing on the per-tick budget).
3434    pub fn buffers(&self) -> Result<Number> {
3435        let args = args(vec![]);
3436        let reply = self.invoke("buffers", args)?;
3437        single::<Number>(reply)
3438    }
3439
3440    /// [`Self::buffers`] without blocking: the call is queued, and
3441    /// the program keeps running until the result comes back; see [`crate::task`].
3442    #[cfg(feature = "async")]
3443    pub async fn buffers_async(&self) -> Result<Number> {
3444        let args = args(vec![]);
3445        let reply = self.invoke_async("buffers", args).await?;
3446        single::<Number>(reply)
3447    }
3448
3449    /// Copies a portion of the screen from the specified location with the specified size by the specified translation.
3450    ///
3451    /// Lua: `gpu.copy(x:number, y:number, width:number, height:number, tx:number, ty:number):boolean`
3452    /// Direct call (runs immediately, drawing on the per-tick budget).
3453    pub fn copy(&self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, tx: impl Into<Number>, ty: impl Into<Number>) -> Result<bool> {
3454        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(width.into())), Some(Value::Number(height.into())), Some(Value::Number(tx.into())), Some(Value::Number(ty.into()))]);
3455        let reply = self.invoke("copy", args)?;
3456        single::<bool>(reply)
3457    }
3458
3459    /// [`Self::copy`] without blocking: the call is queued, and
3460    /// the program keeps running until the result comes back; see [`crate::task`].
3461    #[cfg(feature = "async")]
3462    pub async fn copy_async(&self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, tx: impl Into<Number>, ty: impl Into<Number>) -> Result<bool> {
3463        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(width.into())), Some(Value::Number(height.into())), Some(Value::Number(tx.into())), Some(Value::Number(ty.into()))]);
3464        let reply = self.invoke_async("copy", args).await?;
3465        single::<bool>(reply)
3466    }
3467
3468    /// Fills a portion of the screen at the specified position with the specified size with the specified character.
3469    ///
3470    /// Lua: `gpu.fill(x:number, y:number, width:number, height:number, char:string):boolean`
3471    /// Direct call (runs immediately, drawing on the per-tick budget).
3472    pub fn fill(&self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, char: impl AsRef<[u8]>) -> Result<bool> {
3473        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(width.into())), Some(Value::Number(height.into())), Some(Value::text(char.as_ref()))]);
3474        let reply = self.invoke("fill", args)?;
3475        single::<bool>(reply)
3476    }
3477
3478    /// [`Self::fill`] without blocking: the call is queued, and
3479    /// the program keeps running until the result comes back; see [`crate::task`].
3480    #[cfg(feature = "async")]
3481    pub async fn fill_async(&self, x: impl Into<Number>, y: impl Into<Number>, width: impl Into<Number>, height: impl Into<Number>, char: impl AsRef<[u8]>) -> Result<bool> {
3482        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(width.into())), Some(Value::Number(height.into())), Some(Value::text(char.as_ref()))]);
3483        let reply = self.invoke_async("fill", args).await?;
3484        single::<bool>(reply)
3485    }
3486
3487    /// Closes all buffers and returns the count. If the active buffer is closed, index moves to 0
3488    ///
3489    /// Lua: `gpu.freeAllBuffers(): number`
3490    /// Direct call (runs immediately, drawing on the per-tick budget).
3491    pub fn free_all_buffers(&self) -> Result<Number> {
3492        let args = args(vec![]);
3493        let reply = self.invoke("freeAllBuffers", args)?;
3494        single::<Number>(reply)
3495    }
3496
3497    /// [`Self::free_all_buffers`] without blocking: the call is queued, and
3498    /// the program keeps running until the result comes back; see [`crate::task`].
3499    #[cfg(feature = "async")]
3500    pub async fn free_all_buffers_async(&self) -> Result<Number> {
3501        let args = args(vec![]);
3502        let reply = self.invoke_async("freeAllBuffers", args).await?;
3503        single::<Number>(reply)
3504    }
3505
3506    /// Closes buffer at `index`. Returns true if a buffer closed. If the current buffer is closed, index moves to 0
3507    ///
3508    /// Lua: `gpu.freeBuffer(index: number): boolean`
3509    /// Direct call (runs immediately, drawing on the per-tick budget).
3510    pub fn free_buffer(&self, index: impl Into<Number>) -> Result<bool> {
3511        let args = args(vec![Some(Value::Number(index.into()))]);
3512        let reply = self.invoke("freeBuffer", args)?;
3513        single::<bool>(reply)
3514    }
3515
3516    /// [`Self::free_buffer`] without blocking: the call is queued, and
3517    /// the program keeps running until the result comes back; see [`crate::task`].
3518    #[cfg(feature = "async")]
3519    pub async fn free_buffer_async(&self, index: impl Into<Number>) -> Result<bool> {
3520        let args = args(vec![Some(Value::Number(index.into()))]);
3521        let reply = self.invoke_async("freeBuffer", args).await?;
3522        single::<bool>(reply)
3523    }
3524
3525    /// returns the total free memory not allocated to buffers. This does not include the screen.
3526    ///
3527    /// Lua: `gpu.freeMemory(): number`
3528    /// Direct call (runs immediately, drawing on the per-tick budget).
3529    pub fn free_memory(&self) -> Result<Number> {
3530        let args = args(vec![]);
3531        let reply = self.invoke("freeMemory", args)?;
3532        single::<Number>(reply)
3533    }
3534
3535    /// [`Self::free_memory`] without blocking: the call is queued, and
3536    /// the program keeps running until the result comes back; see [`crate::task`].
3537    #[cfg(feature = "async")]
3538    pub async fn free_memory_async(&self) -> Result<Number> {
3539        let args = args(vec![]);
3540        let reply = self.invoke_async("freeMemory", args).await?;
3541        single::<Number>(reply)
3542    }
3543
3544    /// Get the value displayed on the screen at the specified index, as well as the foreground and background color. If the foreground or background is from the palette, returns the palette indices as fourth and fifth results, else nil, respectively.
3545    ///
3546    /// Lua: `gpu.get(x:number, y:number):string, number, number, number or nil, number or nil`
3547    /// Direct call (runs immediately, drawing on the per-tick budget).
3548    pub fn get(&self, x: impl Into<Number>, y: impl Into<Number>) -> Result<(OcString, Number, Number, Option<Number>, Option<Number>)> {
3549        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into()))]);
3550        let reply = self.invoke("get", args)?;
3551        FromReply::from_reply(reply)
3552    }
3553
3554    /// [`Self::get`] without blocking: the call is queued, and
3555    /// the program keeps running until the result comes back; see [`crate::task`].
3556    #[cfg(feature = "async")]
3557    pub async fn get_async(&self, x: impl Into<Number>, y: impl Into<Number>) -> Result<(OcString, Number, Number, Option<Number>, Option<Number>)> {
3558        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into()))]);
3559        let reply = self.invoke_async("get", args).await?;
3560        FromReply::from_reply(reply)
3561    }
3562
3563    /// returns the index of the currently selected buffer. 0 is reserved for the screen. Can return 0 even when there is no screen
3564    ///
3565    /// Lua: `gpu.getActiveBuffer(): number`
3566    /// Direct call (runs immediately, drawing on the per-tick budget).
3567    pub fn get_active_buffer(&self) -> Result<Number> {
3568        let args = args(vec![]);
3569        let reply = self.invoke("getActiveBuffer", args)?;
3570        single::<Number>(reply)
3571    }
3572
3573    /// [`Self::get_active_buffer`] without blocking: the call is queued, and
3574    /// the program keeps running until the result comes back; see [`crate::task`].
3575    #[cfg(feature = "async")]
3576    pub async fn get_active_buffer_async(&self) -> Result<Number> {
3577        let args = args(vec![]);
3578        let reply = self.invoke_async("getActiveBuffer", args).await?;
3579        single::<Number>(reply)
3580    }
3581
3582    /// Get the current background color and whether it's from the palette or not.
3583    ///
3584    /// Lua: `gpu.getBackground():number, boolean`
3585    /// Direct call (runs immediately, drawing on the per-tick budget).
3586    pub fn get_background(&self) -> Result<(Number, bool)> {
3587        let args = args(vec![]);
3588        let reply = self.invoke("getBackground", args)?;
3589        FromReply::from_reply(reply)
3590    }
3591
3592    /// [`Self::get_background`] without blocking: the call is queued, and
3593    /// the program keeps running until the result comes back; see [`crate::task`].
3594    #[cfg(feature = "async")]
3595    pub async fn get_background_async(&self) -> Result<(Number, bool)> {
3596        let args = args(vec![]);
3597        let reply = self.invoke_async("getBackground", args).await?;
3598        FromReply::from_reply(reply)
3599    }
3600
3601    /// returns the buffer size at index. Returns the screen resolution for index 0. returns nil for invalid indexes
3602    ///
3603    /// Lua: `gpu.getBufferSize(index: number): number, number`
3604    /// Direct call (runs immediately, drawing on the per-tick budget).
3605    pub fn get_buffer_size(&self, index: impl Into<Number>) -> Result<(Number, Number)> {
3606        let args = args(vec![Some(Value::Number(index.into()))]);
3607        let reply = self.invoke("getBufferSize", args)?;
3608        FromReply::from_reply(reply)
3609    }
3610
3611    /// [`Self::get_buffer_size`] without blocking: the call is queued, and
3612    /// the program keeps running until the result comes back; see [`crate::task`].
3613    #[cfg(feature = "async")]
3614    pub async fn get_buffer_size_async(&self, index: impl Into<Number>) -> Result<(Number, Number)> {
3615        let args = args(vec![Some(Value::Number(index.into()))]);
3616        let reply = self.invoke_async("getBufferSize", args).await?;
3617        FromReply::from_reply(reply)
3618    }
3619
3620    /// Returns the currently set color depth in bits.
3621    ///
3622    /// Lua: `gpu.getDepth():number`
3623    /// Direct call (runs immediately, drawing on the per-tick budget).
3624    pub fn get_depth(&self) -> Result<Number> {
3625        let args = args(vec![]);
3626        let reply = self.invoke("getDepth", args)?;
3627        single::<Number>(reply)
3628    }
3629
3630    /// [`Self::get_depth`] without blocking: the call is queued, and
3631    /// the program keeps running until the result comes back; see [`crate::task`].
3632    #[cfg(feature = "async")]
3633    pub async fn get_depth_async(&self) -> Result<Number> {
3634        let args = args(vec![]);
3635        let reply = self.invoke_async("getDepth", args).await?;
3636        single::<Number>(reply)
3637    }
3638
3639    /// Get the current foreground color and whether it's from the palette or not.
3640    ///
3641    /// Lua: `gpu.getForeground():number, boolean`
3642    /// Direct call (runs immediately, drawing on the per-tick budget).
3643    pub fn get_foreground(&self) -> Result<(Number, bool)> {
3644        let args = args(vec![]);
3645        let reply = self.invoke("getForeground", args)?;
3646        FromReply::from_reply(reply)
3647    }
3648
3649    /// [`Self::get_foreground`] without blocking: the call is queued, and
3650    /// the program keeps running until the result comes back; see [`crate::task`].
3651    #[cfg(feature = "async")]
3652    pub async fn get_foreground_async(&self) -> Result<(Number, bool)> {
3653        let args = args(vec![]);
3654        let reply = self.invoke_async("getForeground", args).await?;
3655        FromReply::from_reply(reply)
3656    }
3657
3658    /// Get the palette color at the specified palette index.
3659    ///
3660    /// Lua: `gpu.getPaletteColor(index:number):number`
3661    /// Direct call (runs immediately, drawing on the per-tick budget).
3662    pub fn get_palette_color(&self, index: impl Into<Number>) -> Result<Number> {
3663        let args = args(vec![Some(Value::Number(index.into()))]);
3664        let reply = self.invoke("getPaletteColor", args)?;
3665        single::<Number>(reply)
3666    }
3667
3668    /// [`Self::get_palette_color`] without blocking: the call is queued, and
3669    /// the program keeps running until the result comes back; see [`crate::task`].
3670    #[cfg(feature = "async")]
3671    pub async fn get_palette_color_async(&self, index: impl Into<Number>) -> Result<Number> {
3672        let args = args(vec![Some(Value::Number(index.into()))]);
3673        let reply = self.invoke_async("getPaletteColor", args).await?;
3674        single::<Number>(reply)
3675    }
3676
3677    /// Get the current screen resolution.
3678    ///
3679    /// Lua: `gpu.getResolution():number, number`
3680    /// Direct call (runs immediately, drawing on the per-tick budget).
3681    pub fn get_resolution(&self) -> Result<(Number, Number)> {
3682        let args = args(vec![]);
3683        let reply = self.invoke("getResolution", args)?;
3684        FromReply::from_reply(reply)
3685    }
3686
3687    /// [`Self::get_resolution`] without blocking: the call is queued, and
3688    /// the program keeps running until the result comes back; see [`crate::task`].
3689    #[cfg(feature = "async")]
3690    pub async fn get_resolution_async(&self) -> Result<(Number, Number)> {
3691        let args = args(vec![]);
3692        let reply = self.invoke_async("getResolution", args).await?;
3693        FromReply::from_reply(reply)
3694    }
3695
3696    /// Get the address of the screen the GPU is currently bound to.
3697    ///
3698    /// Lua: `gpu.getScreen():string`
3699    /// Direct call (runs immediately, drawing on the per-tick budget).
3700    pub fn get_screen(&self) -> Result<OcString> {
3701        let args = args(vec![]);
3702        let reply = self.invoke("getScreen", args)?;
3703        single::<OcString>(reply)
3704    }
3705
3706    /// [`Self::get_screen`] without blocking: the call is queued, and
3707    /// the program keeps running until the result comes back; see [`crate::task`].
3708    #[cfg(feature = "async")]
3709    pub async fn get_screen_async(&self) -> Result<OcString> {
3710        let args = args(vec![]);
3711        let reply = self.invoke_async("getScreen", args).await?;
3712        single::<OcString>(reply)
3713    }
3714
3715    /// Get the current viewport resolution.
3716    ///
3717    /// Lua: `gpu.getViewport():number, number`
3718    /// Direct call (runs immediately, drawing on the per-tick budget).
3719    pub fn get_viewport(&self) -> Result<(Number, Number)> {
3720        let args = args(vec![]);
3721        let reply = self.invoke("getViewport", args)?;
3722        FromReply::from_reply(reply)
3723    }
3724
3725    /// [`Self::get_viewport`] without blocking: the call is queued, and
3726    /// the program keeps running until the result comes back; see [`crate::task`].
3727    #[cfg(feature = "async")]
3728    pub async fn get_viewport_async(&self) -> Result<(Number, Number)> {
3729        let args = args(vec![]);
3730        let reply = self.invoke_async("getViewport", args).await?;
3731        FromReply::from_reply(reply)
3732    }
3733
3734    /// Gets the maximum supported color depth in bits.
3735    ///
3736    /// Lua: `gpu.maxDepth():number`
3737    /// Direct call (runs immediately, drawing on the per-tick budget).
3738    pub fn max_depth(&self) -> Result<Number> {
3739        let args = args(vec![]);
3740        let reply = self.invoke("maxDepth", args)?;
3741        single::<Number>(reply)
3742    }
3743
3744    /// [`Self::max_depth`] without blocking: the call is queued, and
3745    /// the program keeps running until the result comes back; see [`crate::task`].
3746    #[cfg(feature = "async")]
3747    pub async fn max_depth_async(&self) -> Result<Number> {
3748        let args = args(vec![]);
3749        let reply = self.invoke_async("maxDepth", args).await?;
3750        single::<Number>(reply)
3751    }
3752
3753    /// Get the maximum screen resolution.
3754    ///
3755    /// Lua: `gpu.maxResolution():number, number`
3756    /// Direct call (runs immediately, drawing on the per-tick budget).
3757    pub fn max_resolution(&self) -> Result<(Number, Number)> {
3758        let args = args(vec![]);
3759        let reply = self.invoke("maxResolution", args)?;
3760        FromReply::from_reply(reply)
3761    }
3762
3763    /// [`Self::max_resolution`] without blocking: the call is queued, and
3764    /// the program keeps running until the result comes back; see [`crate::task`].
3765    #[cfg(feature = "async")]
3766    pub async fn max_resolution_async(&self) -> Result<(Number, Number)> {
3767        let args = args(vec![]);
3768        let reply = self.invoke_async("maxResolution", args).await?;
3769        FromReply::from_reply(reply)
3770    }
3771
3772    /// Plots a string value to the screen at the specified position. Optionally writes the string vertically.
3773    ///
3774    /// Lua: `gpu.set(x:number, y:number, value:string[, vertical:boolean]):boolean`
3775    /// Direct call (runs immediately, drawing on the per-tick budget).
3776    pub fn set(&self, x: impl Into<Number>, y: impl Into<Number>, value: impl AsRef<[u8]>, vertical: Option<bool>) -> Result<bool> {
3777        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::text(value.as_ref())), vertical.map(Value::Bool)]);
3778        let reply = self.invoke("set", args)?;
3779        single::<bool>(reply)
3780    }
3781
3782    /// [`Self::set`] without blocking: the call is queued, and
3783    /// the program keeps running until the result comes back; see [`crate::task`].
3784    #[cfg(feature = "async")]
3785    pub async fn set_async(&self, x: impl Into<Number>, y: impl Into<Number>, value: impl AsRef<[u8]>, vertical: Option<bool>) -> Result<bool> {
3786        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::text(value.as_ref())), vertical.map(Value::Bool)]);
3787        let reply = self.invoke_async("set", args).await?;
3788        single::<bool>(reply)
3789    }
3790
3791    /// Sets the active buffer to `index`. 1 is the first vram buffer and 0 is reserved for the screen. returns nil for invalid index (0 is always valid)
3792    ///
3793    /// Lua: `gpu.setActiveBuffer(index: number): number`
3794    /// Direct call (runs immediately, drawing on the per-tick budget).
3795    pub fn set_active_buffer(&self, index: impl Into<Number>) -> Result<Number> {
3796        let args = args(vec![Some(Value::Number(index.into()))]);
3797        let reply = self.invoke("setActiveBuffer", args)?;
3798        single::<Number>(reply)
3799    }
3800
3801    /// [`Self::set_active_buffer`] without blocking: the call is queued, and
3802    /// the program keeps running until the result comes back; see [`crate::task`].
3803    #[cfg(feature = "async")]
3804    pub async fn set_active_buffer_async(&self, index: impl Into<Number>) -> Result<Number> {
3805        let args = args(vec![Some(Value::Number(index.into()))]);
3806        let reply = self.invoke_async("setActiveBuffer", args).await?;
3807        single::<Number>(reply)
3808    }
3809
3810    /// Sets the background color to the specified value. Optionally takes an explicit palette index. Returns the old value and if it was from the palette its palette index.
3811    ///
3812    /// Lua: `gpu.setBackground(value:number[, palette:boolean]):number, number or nil`
3813    /// Direct call (runs immediately, drawing on the per-tick budget).
3814    pub fn set_background(&self, value: impl Into<Number>, palette: Option<bool>) -> Result<(Number, Option<Number>)> {
3815        let args = args(vec![Some(Value::Number(value.into())), palette.map(Value::Bool)]);
3816        let reply = self.invoke("setBackground", args)?;
3817        FromReply::from_reply(reply)
3818    }
3819
3820    /// [`Self::set_background`] without blocking: the call is queued, and
3821    /// the program keeps running until the result comes back; see [`crate::task`].
3822    #[cfg(feature = "async")]
3823    pub async fn set_background_async(&self, value: impl Into<Number>, palette: Option<bool>) -> Result<(Number, Option<Number>)> {
3824        let args = args(vec![Some(Value::Number(value.into())), palette.map(Value::Bool)]);
3825        let reply = self.invoke_async("setBackground", args).await?;
3826        FromReply::from_reply(reply)
3827    }
3828
3829    /// Set the color depth. Returns the previous value.
3830    ///
3831    /// Lua: `gpu.setDepth(depth:number):number`
3832    /// Indirect call: waits for the next server tick.
3833    pub fn set_depth(&self, depth: impl Into<Number>) -> Result<Number> {
3834        let args = args(vec![Some(Value::Number(depth.into()))]);
3835        let reply = self.invoke("setDepth", args)?;
3836        single::<Number>(reply)
3837    }
3838
3839    /// [`Self::set_depth`] without blocking: the call is queued, and
3840    /// the program keeps running until the result comes back; see [`crate::task`].
3841    #[cfg(feature = "async")]
3842    pub async fn set_depth_async(&self, depth: impl Into<Number>) -> Result<Number> {
3843        let args = args(vec![Some(Value::Number(depth.into()))]);
3844        let reply = self.invoke_async("setDepth", args).await?;
3845        single::<Number>(reply)
3846    }
3847
3848    /// Sets the foreground color to the specified value. Optionally takes an explicit palette index. Returns the old value and if it was from the palette its palette index.
3849    ///
3850    /// Lua: `gpu.setForeground(value:number[, palette:boolean]):number, number or nil`
3851    /// Direct call (runs immediately, drawing on the per-tick budget).
3852    pub fn set_foreground(&self, value: impl Into<Number>, palette: Option<bool>) -> Result<(Number, Option<Number>)> {
3853        let args = args(vec![Some(Value::Number(value.into())), palette.map(Value::Bool)]);
3854        let reply = self.invoke("setForeground", args)?;
3855        FromReply::from_reply(reply)
3856    }
3857
3858    /// [`Self::set_foreground`] without blocking: the call is queued, and
3859    /// the program keeps running until the result comes back; see [`crate::task`].
3860    #[cfg(feature = "async")]
3861    pub async fn set_foreground_async(&self, value: impl Into<Number>, palette: Option<bool>) -> Result<(Number, Option<Number>)> {
3862        let args = args(vec![Some(Value::Number(value.into())), palette.map(Value::Bool)]);
3863        let reply = self.invoke_async("setForeground", args).await?;
3864        FromReply::from_reply(reply)
3865    }
3866
3867    /// Set the palette color at the specified palette index. Returns the previous value.
3868    ///
3869    /// Lua: `gpu.setPaletteColor(index:number, color:number):number`
3870    /// Direct call (runs immediately, drawing on the per-tick budget).
3871    pub fn set_palette_color(&self, index: impl Into<Number>, color: impl Into<Number>) -> Result<Number> {
3872        let args = args(vec![Some(Value::Number(index.into())), Some(Value::Number(color.into()))]);
3873        let reply = self.invoke("setPaletteColor", args)?;
3874        single::<Number>(reply)
3875    }
3876
3877    /// [`Self::set_palette_color`] without blocking: the call is queued, and
3878    /// the program keeps running until the result comes back; see [`crate::task`].
3879    #[cfg(feature = "async")]
3880    pub async fn set_palette_color_async(&self, index: impl Into<Number>, color: impl Into<Number>) -> Result<Number> {
3881        let args = args(vec![Some(Value::Number(index.into())), Some(Value::Number(color.into()))]);
3882        let reply = self.invoke_async("setPaletteColor", args).await?;
3883        single::<Number>(reply)
3884    }
3885
3886    /// Set the screen resolution. Returns true if the resolution changed.
3887    ///
3888    /// Lua: `gpu.setResolution(width:number, height:number):boolean`
3889    /// Indirect call: waits for the next server tick.
3890    pub fn set_resolution(&self, width: impl Into<Number>, height: impl Into<Number>) -> Result<bool> {
3891        let args = args(vec![Some(Value::Number(width.into())), Some(Value::Number(height.into()))]);
3892        let reply = self.invoke("setResolution", args)?;
3893        single::<bool>(reply)
3894    }
3895
3896    /// [`Self::set_resolution`] without blocking: the call is queued, and
3897    /// the program keeps running until the result comes back; see [`crate::task`].
3898    #[cfg(feature = "async")]
3899    pub async fn set_resolution_async(&self, width: impl Into<Number>, height: impl Into<Number>) -> Result<bool> {
3900        let args = args(vec![Some(Value::Number(width.into())), Some(Value::Number(height.into()))]);
3901        let reply = self.invoke_async("setResolution", args).await?;
3902        single::<bool>(reply)
3903    }
3904
3905    /// Set the viewport resolution. Cannot exceed the screen resolution. Returns true if the resolution changed.
3906    ///
3907    /// Lua: `gpu.setViewport(width:number, height:number):boolean`
3908    /// Indirect call: waits for the next server tick.
3909    pub fn set_viewport(&self, width: impl Into<Number>, height: impl Into<Number>) -> Result<bool> {
3910        let args = args(vec![Some(Value::Number(width.into())), Some(Value::Number(height.into()))]);
3911        let reply = self.invoke("setViewport", args)?;
3912        single::<bool>(reply)
3913    }
3914
3915    /// [`Self::set_viewport`] without blocking: the call is queued, and
3916    /// the program keeps running until the result comes back; see [`crate::task`].
3917    #[cfg(feature = "async")]
3918    pub async fn set_viewport_async(&self, width: impl Into<Number>, height: impl Into<Number>) -> Result<bool> {
3919        let args = args(vec![Some(Value::Number(width.into())), Some(Value::Number(height.into()))]);
3920        let reply = self.invoke_async("setViewport", args).await?;
3921        single::<bool>(reply)
3922    }
3923
3924    /// returns the total memory size of the gpu vram. This does not include the screen.
3925    ///
3926    /// Lua: `gpu.totalMemory(): number`
3927    /// Direct call (runs immediately, drawing on the per-tick budget).
3928    pub fn total_memory(&self) -> Result<Number> {
3929        let args = args(vec![]);
3930        let reply = self.invoke("totalMemory", args)?;
3931        single::<Number>(reply)
3932    }
3933
3934    /// [`Self::total_memory`] without blocking: the call is queued, and
3935    /// the program keeps running until the result comes back; see [`crate::task`].
3936    #[cfg(feature = "async")]
3937    pub async fn total_memory_async(&self) -> Result<Number> {
3938        let args = args(vec![]);
3939        let reply = self.invoke_async("totalMemory", args).await?;
3940        single::<Number>(reply)
3941    }
3942}
3943
3944/// The `hologram` component (16 methods).
3945///
3946/// Provided by OpenComputers' `Hologram`.
3947#[derive(Clone, Debug, PartialEq, Eq, Hash)]
3948pub struct Hologram(pub Address);
3949
3950impl Component for Hologram {
3951    const KIND: &'static str = "hologram";
3952    fn from_address(address: Address) -> Self {
3953        Self(address)
3954    }
3955    fn address(&self) -> &Address {
3956        &self.0
3957    }
3958}
3959
3960impl Hologram {
3961    /// Clears the hologram.
3962    ///
3963    /// Lua: `hologram.clear()`
3964    /// Indirect call: waits for the next server tick.
3965    pub fn clear(&self) -> Result<()> {
3966        let args = args(vec![]);
3967        let reply = self.invoke("clear", args)?;
3968        FromReply::from_reply(reply)
3969    }
3970
3971    /// [`Self::clear`] without blocking: the call is queued, and
3972    /// the program keeps running until the result comes back; see [`crate::task`].
3973    #[cfg(feature = "async")]
3974    pub async fn clear_async(&self) -> Result<()> {
3975        let args = args(vec![]);
3976        let reply = self.invoke_async("clear", args).await?;
3977        FromReply::from_reply(reply)
3978    }
3979
3980    /// Copies an area of columns by the specified translation.
3981    ///
3982    /// Lua: `hologram.copy(x:number, z:number, sx:number, sz:number, tx:number, tz:number)`
3983    /// Indirect call: waits for the next server tick.
3984    pub fn copy(&self, x: impl Into<Number>, z: impl Into<Number>, sx: impl Into<Number>, sz: impl Into<Number>, tx: impl Into<Number>, tz: impl Into<Number>) -> Result<()> {
3985        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), Some(Value::Number(sx.into())), Some(Value::Number(sz.into())), Some(Value::Number(tx.into())), Some(Value::Number(tz.into()))]);
3986        let reply = self.invoke("copy", args)?;
3987        FromReply::from_reply(reply)
3988    }
3989
3990    /// [`Self::copy`] without blocking: the call is queued, and
3991    /// the program keeps running until the result comes back; see [`crate::task`].
3992    #[cfg(feature = "async")]
3993    pub async fn copy_async(&self, x: impl Into<Number>, z: impl Into<Number>, sx: impl Into<Number>, sz: impl Into<Number>, tx: impl Into<Number>, tz: impl Into<Number>) -> Result<()> {
3994        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), Some(Value::Number(sx.into())), Some(Value::Number(sz.into())), Some(Value::Number(tx.into())), Some(Value::Number(tz.into()))]);
3995        let reply = self.invoke_async("copy", args).await?;
3996        FromReply::from_reply(reply)
3997    }
3998
3999    /// Fills an interval of a column with the specified value.
4000    ///
4001    /// Lua: `hologram.fill(x:number, z:number[, minY:number], maxY:number, value:number or boolean)`
4002    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 128).
4003    pub fn fill(&self, x: impl Into<Number>, z: impl Into<Number>, min_y: Option<Number>, max_y: Option<Number>, value: Option<Value>) -> Result<()> {
4004        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), min_y.map(Value::Number), max_y.map(Value::Number), value]);
4005        let reply = self.invoke("fill", args)?;
4006        FromReply::from_reply(reply)
4007    }
4008
4009    /// [`Self::fill`] without blocking: the call is queued, and
4010    /// the program keeps running until the result comes back; see [`crate::task`].
4011    #[cfg(feature = "async")]
4012    pub async fn fill_async(&self, x: impl Into<Number>, z: impl Into<Number>, min_y: Option<Number>, max_y: Option<Number>, value: Option<Value>) -> Result<()> {
4013        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(z.into())), min_y.map(Value::Number), max_y.map(Value::Number), value]);
4014        let reply = self.invoke_async("fill", args).await?;
4015        FromReply::from_reply(reply)
4016    }
4017
4018    /// Returns the value for the specified voxel.
4019    ///
4020    /// Lua: `hologram.get(x:number, y:number, z:number):number`
4021    /// Direct call (runs immediately, drawing on the per-tick budget).
4022    pub fn get(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<Number> {
4023        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4024        let reply = self.invoke("get", args)?;
4025        single::<Number>(reply)
4026    }
4027
4028    /// [`Self::get`] without blocking: the call is queued, and
4029    /// the program keeps running until the result comes back; see [`crate::task`].
4030    #[cfg(feature = "async")]
4031    pub async fn get_async(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<Number> {
4032        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4033        let reply = self.invoke_async("get", args).await?;
4034        single::<Number>(reply)
4035    }
4036
4037    /// Get the dimension of the x,y,z axes.
4038    ///
4039    /// Lua: `hologram.getDimensions():number, number, number`
4040    /// Direct call (runs immediately, drawing on the per-tick budget).
4041    pub fn get_dimensions(&self) -> Result<(Number, Number, Number)> {
4042        let args = args(vec![]);
4043        let reply = self.invoke("getDimensions", args)?;
4044        FromReply::from_reply(reply)
4045    }
4046
4047    /// [`Self::get_dimensions`] without blocking: the call is queued, and
4048    /// the program keeps running until the result comes back; see [`crate::task`].
4049    #[cfg(feature = "async")]
4050    pub async fn get_dimensions_async(&self) -> Result<(Number, Number, Number)> {
4051        let args = args(vec![]);
4052        let reply = self.invoke_async("getDimensions", args).await?;
4053        FromReply::from_reply(reply)
4054    }
4055
4056    /// Get the color defined for the specified value.
4057    ///
4058    /// Lua: `hologram.getPaletteColor(index:number):number`
4059    /// Indirect call: waits for the next server tick.
4060    pub fn get_palette_color(&self, index: impl Into<Number>) -> Result<Number> {
4061        let args = args(vec![Some(Value::Number(index.into()))]);
4062        let reply = self.invoke("getPaletteColor", args)?;
4063        single::<Number>(reply)
4064    }
4065
4066    /// [`Self::get_palette_color`] without blocking: the call is queued, and
4067    /// the program keeps running until the result comes back; see [`crate::task`].
4068    #[cfg(feature = "async")]
4069    pub async fn get_palette_color_async(&self, index: impl Into<Number>) -> Result<Number> {
4070        let args = args(vec![Some(Value::Number(index.into()))]);
4071        let reply = self.invoke_async("getPaletteColor", args).await?;
4072        single::<Number>(reply)
4073    }
4074
4075    /// Returns the render scale of the hologram.
4076    ///
4077    /// Lua: `hologram.getScale():number`
4078    /// Direct call (runs immediately, drawing on the per-tick budget).
4079    pub fn get_scale(&self) -> Result<Number> {
4080        let args = args(vec![]);
4081        let reply = self.invoke("getScale", args)?;
4082        single::<Number>(reply)
4083    }
4084
4085    /// [`Self::get_scale`] without blocking: the call is queued, and
4086    /// the program keeps running until the result comes back; see [`crate::task`].
4087    #[cfg(feature = "async")]
4088    pub async fn get_scale_async(&self) -> Result<Number> {
4089        let args = args(vec![]);
4090        let reply = self.invoke_async("getScale", args).await?;
4091        single::<Number>(reply)
4092    }
4093
4094    /// Returns the relative render projection offsets of the hologram.
4095    ///
4096    /// Lua: `hologram.getTranslation():number, number, number`
4097    /// Direct call (runs immediately, drawing on the per-tick budget).
4098    pub fn get_translation(&self) -> Result<(Number, Number, Number)> {
4099        let args = args(vec![]);
4100        let reply = self.invoke("getTranslation", args)?;
4101        FromReply::from_reply(reply)
4102    }
4103
4104    /// [`Self::get_translation`] without blocking: the call is queued, and
4105    /// the program keeps running until the result comes back; see [`crate::task`].
4106    #[cfg(feature = "async")]
4107    pub async fn get_translation_async(&self) -> Result<(Number, Number, Number)> {
4108        let args = args(vec![]);
4109        let reply = self.invoke_async("getTranslation", args).await?;
4110        FromReply::from_reply(reply)
4111    }
4112
4113    /// The color depth supported by the hologram.
4114    ///
4115    /// Lua: `hologram.maxDepth():number`
4116    /// Direct call (runs immediately, drawing on the per-tick budget).
4117    pub fn max_depth(&self) -> Result<Number> {
4118        let args = args(vec![]);
4119        let reply = self.invoke("maxDepth", args)?;
4120        single::<Number>(reply)
4121    }
4122
4123    /// [`Self::max_depth`] without blocking: the call is queued, and
4124    /// the program keeps running until the result comes back; see [`crate::task`].
4125    #[cfg(feature = "async")]
4126    pub async fn max_depth_async(&self) -> Result<Number> {
4127        let args = args(vec![]);
4128        let reply = self.invoke_async("maxDepth", args).await?;
4129        single::<Number>(reply)
4130    }
4131
4132    /// Set the value for the specified voxel.
4133    ///
4134    /// Lua: `hologram.set(x:number, y:number, z:number, value:number or boolean)`
4135    /// Direct call (runs immediately, drawing on the per-tick budget; OC's limit 256).
4136    pub fn set(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>, value: impl Into<Value>) -> Result<()> {
4137        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into())), Some(value.into())]);
4138        let reply = self.invoke("set", args)?;
4139        FromReply::from_reply(reply)
4140    }
4141
4142    /// [`Self::set`] without blocking: the call is queued, and
4143    /// the program keeps running until the result comes back; see [`crate::task`].
4144    #[cfg(feature = "async")]
4145    pub async fn set_async(&self, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>, value: impl Into<Value>) -> Result<()> {
4146        let args = args(vec![Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into())), Some(value.into())]);
4147        let reply = self.invoke_async("set", args).await?;
4148        FromReply::from_reply(reply)
4149    }
4150
4151    /// Set the color defined for the specified value.
4152    ///
4153    /// Lua: `hologram.setPaletteColor(index:number, value:number):number`
4154    /// Indirect call: waits for the next server tick.
4155    pub fn set_palette_color(&self, index: impl Into<Number>, value: impl Into<Number>) -> Result<Number> {
4156        let args = args(vec![Some(Value::Number(index.into())), Some(Value::Number(value.into()))]);
4157        let reply = self.invoke("setPaletteColor", args)?;
4158        single::<Number>(reply)
4159    }
4160
4161    /// [`Self::set_palette_color`] without blocking: the call is queued, and
4162    /// the program keeps running until the result comes back; see [`crate::task`].
4163    #[cfg(feature = "async")]
4164    pub async fn set_palette_color_async(&self, index: impl Into<Number>, value: impl Into<Number>) -> Result<Number> {
4165        let args = args(vec![Some(Value::Number(index.into())), Some(Value::Number(value.into()))]);
4166        let reply = self.invoke_async("setPaletteColor", args).await?;
4167        single::<Number>(reply)
4168    }
4169
4170    /// Set the raw buffer to the specified byte array, where each byte represents a voxel color. Nesting is x,z,y.
4171    ///
4172    /// Lua: `hologram.setRaw(data:string)`
4173    /// Indirect call: waits for the next server tick.
4174    pub fn set_raw(&self, data: impl AsRef<[u8]>) -> Result<()> {
4175        let args = args(vec![Some(Value::text(data.as_ref()))]);
4176        let reply = self.invoke("setRaw", args)?;
4177        FromReply::from_reply(reply)
4178    }
4179
4180    /// [`Self::set_raw`] without blocking: the call is queued, and
4181    /// the program keeps running until the result comes back; see [`crate::task`].
4182    #[cfg(feature = "async")]
4183    pub async fn set_raw_async(&self, data: impl AsRef<[u8]>) -> Result<()> {
4184        let args = args(vec![Some(Value::text(data.as_ref()))]);
4185        let reply = self.invoke_async("setRaw", args).await?;
4186        FromReply::from_reply(reply)
4187    }
4188
4189    /// Set the base rotation of the displayed hologram.
4190    ///
4191    /// Lua: `hologram.setRotation(angle:number, x:number, y:number, z:number):boolean`
4192    /// Indirect call: waits for the next server tick.
4193    pub fn set_rotation(&self, angle: impl Into<Number>, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
4194        let args = args(vec![Some(Value::Number(angle.into())), Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4195        let reply = self.invoke("setRotation", args)?;
4196        single::<bool>(reply)
4197    }
4198
4199    /// [`Self::set_rotation`] without blocking: the call is queued, and
4200    /// the program keeps running until the result comes back; see [`crate::task`].
4201    #[cfg(feature = "async")]
4202    pub async fn set_rotation_async(&self, angle: impl Into<Number>, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
4203        let args = args(vec![Some(Value::Number(angle.into())), Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4204        let reply = self.invoke_async("setRotation", args).await?;
4205        single::<bool>(reply)
4206    }
4207
4208    /// Set the rotation speed of the displayed hologram.
4209    ///
4210    /// Lua: `hologram.setRotationSpeed(speed:number, x:number, y:number, z:number):boolean`
4211    /// Indirect call: waits for the next server tick.
4212    pub fn set_rotation_speed(&self, speed: impl Into<Number>, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
4213        let args = args(vec![Some(Value::Number(speed.into())), Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4214        let reply = self.invoke("setRotationSpeed", args)?;
4215        single::<bool>(reply)
4216    }
4217
4218    /// [`Self::set_rotation_speed`] without blocking: the call is queued, and
4219    /// the program keeps running until the result comes back; see [`crate::task`].
4220    #[cfg(feature = "async")]
4221    pub async fn set_rotation_speed_async(&self, speed: impl Into<Number>, x: impl Into<Number>, y: impl Into<Number>, z: impl Into<Number>) -> Result<bool> {
4222        let args = args(vec![Some(Value::Number(speed.into())), Some(Value::Number(x.into())), Some(Value::Number(y.into())), Some(Value::Number(z.into()))]);
4223        let reply = self.invoke_async("setRotationSpeed", args).await?;
4224        single::<bool>(reply)
4225    }
4226
4227    /// Set the render scale. A larger scale consumes more energy.
4228    ///
4229    /// Lua: `hologram.setScale(value:number)`
4230    /// Indirect call: waits for the next server tick.
4231    pub fn set_scale(&self, value: impl Into<Number>) -> Result<()> {
4232        let args = args(vec![Some(Value::Number(value.into()))]);
4233        let reply = self.invoke("setScale", args)?;
4234        FromReply::from_reply(reply)
4235    }
4236
4237    /// [`Self::set_scale`] without blocking: the call is queued, and
4238    /// the program keeps running until the result comes back; see [`crate::task`].
4239    #[cfg(feature = "async")]
4240    pub async fn set_scale_async(&self, value: impl Into<Number>) -> Result<()> {
4241        let args = args(vec![Some(Value::Number(value.into()))]);
4242        let reply = self.invoke_async("setScale", args).await?;
4243        FromReply::from_reply(reply)
4244    }
4245
4246    /// Sets the relative render projection offsets of the hologram.
4247    ///
4248    /// Lua: `hologram.setTranslation(tx:number, ty:number, tz:number)`
4249    /// Indirect call: waits for the next server tick.
4250    pub fn set_translation(&self, tx: impl Into<Number>, ty: impl Into<Number>, tz: impl Into<Number>) -> Result<()> {
4251        let args = args(vec![Some(Value::Number(tx.into())), Some(Value::Number(ty.into())), Some(Value::Number(tz.into()))]);
4252        let reply = self.invoke("setTranslation", args)?;
4253        FromReply::from_reply(reply)
4254    }
4255
4256    /// [`Self::set_translation`] without blocking: the call is queued, and
4257    /// the program keeps running until the result comes back; see [`crate::task`].
4258    #[cfg(feature = "async")]
4259    pub async fn set_translation_async(&self, tx: impl Into<Number>, ty: impl Into<Number>, tz: impl Into<Number>) -> Result<()> {
4260        let args = args(vec![Some(Value::Number(tx.into())), Some(Value::Number(ty.into())), Some(Value::Number(tz.into()))]);
4261        let reply = self.invoke_async("setTranslation", args).await?;
4262        FromReply::from_reply(reply)
4263    }
4264}
4265
4266/// The `internet` component (4 methods).
4267///
4268/// Provided by OpenComputers' `InternetCard`.
4269#[derive(Clone, Debug, PartialEq, Eq, Hash)]
4270pub struct Internet(pub Address);
4271
4272impl Component for Internet {
4273    const KIND: &'static str = "internet";
4274    fn from_address(address: Address) -> Self {
4275        Self(address)
4276    }
4277    fn address(&self) -> &Address {
4278        &self.0
4279    }
4280}
4281
4282impl Internet {
4283    /// Opens a new TCP connection. Returns the handle of the connection.
4284    ///
4285    /// Lua: `internet.connect(address:string[, port:number]):userdata`
4286    /// Indirect call: waits for the next server tick.
4287    pub fn connect(&self, address: impl AsRef<[u8]>, port: Option<Number>) -> Result<Handle> {
4288        let args = args(vec![Some(Value::text(address.as_ref())), port.map(Value::Number)]);
4289        let reply = self.invoke("connect", args)?;
4290        single::<Handle>(reply)
4291    }
4292
4293    /// [`Self::connect`] without blocking: the call is queued, and
4294    /// the program keeps running until the result comes back; see [`crate::task`].
4295    #[cfg(feature = "async")]
4296    pub async fn connect_async(&self, address: impl AsRef<[u8]>, port: Option<Number>) -> Result<Handle> {
4297        let args = args(vec![Some(Value::text(address.as_ref())), port.map(Value::Number)]);
4298        let reply = self.invoke_async("connect", args).await?;
4299        single::<Handle>(reply)
4300    }
4301
4302    /// Returns whether HTTP requests can be made (config setting).
4303    ///
4304    /// Lua: `internet.isHttpEnabled():boolean`
4305    /// Direct call (runs immediately, drawing on the per-tick budget).
4306    pub fn is_http_enabled(&self) -> Result<bool> {
4307        let args = args(vec![]);
4308        let reply = self.invoke("isHttpEnabled", args)?;
4309        single::<bool>(reply)
4310    }
4311
4312    /// [`Self::is_http_enabled`] without blocking: the call is queued, and
4313    /// the program keeps running until the result comes back; see [`crate::task`].
4314    #[cfg(feature = "async")]
4315    pub async fn is_http_enabled_async(&self) -> Result<bool> {
4316        let args = args(vec![]);
4317        let reply = self.invoke_async("isHttpEnabled", args).await?;
4318        single::<bool>(reply)
4319    }
4320
4321    /// Returns whether TCP connections can be made (config setting).
4322    ///
4323    /// Lua: `internet.isTcpEnabled():boolean`
4324    /// Direct call (runs immediately, drawing on the per-tick budget).
4325    pub fn is_tcp_enabled(&self) -> Result<bool> {
4326        let args = args(vec![]);
4327        let reply = self.invoke("isTcpEnabled", args)?;
4328        single::<bool>(reply)
4329    }
4330
4331    /// [`Self::is_tcp_enabled`] without blocking: the call is queued, and
4332    /// the program keeps running until the result comes back; see [`crate::task`].
4333    #[cfg(feature = "async")]
4334    pub async fn is_tcp_enabled_async(&self) -> Result<bool> {
4335        let args = args(vec![]);
4336        let reply = self.invoke_async("isTcpEnabled", args).await?;
4337        single::<bool>(reply)
4338    }
4339
4340    /// Starts an HTTP request. If this returns true, further results will be pushed using `http_response` signals.
4341    ///
4342    /// Lua: `internet.request(url:string[, postData:string[, headers:table[, method:string]]]):userdata`
4343    /// Indirect call: waits for the next server tick.
4344    pub fn request(&self, url: impl AsRef<[u8]>, post_data: Option<&str>, headers: Option<Value>, method: Option<&str>) -> Result<Handle> {
4345        let args = args(vec![Some(Value::text(url.as_ref())), post_data.map(Value::from), headers, method.map(Value::from)]);
4346        let reply = self.invoke("request", args)?;
4347        single::<Handle>(reply)
4348    }
4349
4350    /// [`Self::request`] without blocking: the call is queued, and
4351    /// the program keeps running until the result comes back; see [`crate::task`].
4352    #[cfg(feature = "async")]
4353    pub async fn request_async(&self, url: impl AsRef<[u8]>, post_data: Option<&str>, headers: Option<Value>, method: Option<&str>) -> Result<Handle> {
4354        let args = args(vec![Some(Value::text(url.as_ref())), post_data.map(Value::from), headers, method.map(Value::from)]);
4355        let reply = self.invoke_async("request", args).await?;
4356        single::<Handle>(reply)
4357    }
4358}
4359
4360/// The `inventory` component (8 methods).
4361///
4362/// Provided by OpenComputers' `DriverInventory$Environment`.
4363#[derive(Clone, Debug, PartialEq, Eq, Hash)]
4364pub struct Inventory(pub Address);
4365
4366impl Component for Inventory {
4367    const KIND: &'static str = "inventory";
4368    fn from_address(address: Address) -> Self {
4369        Self(address)
4370    }
4371    fn address(&self) -> &Address {
4372        &self.0
4373    }
4374}
4375
4376impl Inventory {
4377    /// Compare the two item stacks in the specified slots for equality.
4378    ///
4379    /// Lua: `inventory.compareStacks(slotA:number, slotB:number):boolean`
4380    /// Indirect call: waits for the next server tick.
4381    pub fn compare_stacks(&self, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
4382        let args = args(vec![Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
4383        let reply = self.invoke("compareStacks", args)?;
4384        single::<bool>(reply)
4385    }
4386
4387    /// [`Self::compare_stacks`] without blocking: the call is queued, and
4388    /// the program keeps running until the result comes back; see [`crate::task`].
4389    #[cfg(feature = "async")]
4390    pub async fn compare_stacks_async(&self, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
4391        let args = args(vec![Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
4392        let reply = self.invoke_async("compareStacks", args).await?;
4393        single::<bool>(reply)
4394    }
4395
4396    /// Get a list of descriptions for all item stacks in this inventory.
4397    ///
4398    /// Lua: `inventory.getAllStacks():table`
4399    /// Indirect call: waits for the next server tick.
4400    pub fn get_all_stacks(&self) -> Result<Value> {
4401        let args = args(vec![]);
4402        let reply = self.invoke("getAllStacks", args)?;
4403        single::<Value>(reply)
4404    }
4405
4406    /// [`Self::get_all_stacks`] without blocking: the call is queued, and
4407    /// the program keeps running until the result comes back; see [`crate::task`].
4408    #[cfg(feature = "async")]
4409    pub async fn get_all_stacks_async(&self) -> Result<Value> {
4410        let args = args(vec![]);
4411        let reply = self.invoke_async("getAllStacks", args).await?;
4412        single::<Value>(reply)
4413    }
4414
4415    /// Get the name of this inventory.
4416    ///
4417    /// Lua: `inventory.getInventoryName():string`
4418    /// Indirect call: waits for the next server tick.
4419    pub fn get_inventory_name(&self) -> Result<OcString> {
4420        let args = args(vec![]);
4421        let reply = self.invoke("getInventoryName", args)?;
4422        single::<OcString>(reply)
4423    }
4424
4425    /// [`Self::get_inventory_name`] without blocking: the call is queued, and
4426    /// the program keeps running until the result comes back; see [`crate::task`].
4427    #[cfg(feature = "async")]
4428    pub async fn get_inventory_name_async(&self) -> Result<OcString> {
4429        let args = args(vec![]);
4430        let reply = self.invoke_async("getInventoryName", args).await?;
4431        single::<OcString>(reply)
4432    }
4433
4434    /// Get the number of slots in this inventory.
4435    ///
4436    /// Lua: `inventory.getInventorySize():number`
4437    /// Indirect call: waits for the next server tick.
4438    pub fn get_inventory_size(&self) -> Result<Number> {
4439        let args = args(vec![]);
4440        let reply = self.invoke("getInventorySize", args)?;
4441        single::<Number>(reply)
4442    }
4443
4444    /// [`Self::get_inventory_size`] without blocking: the call is queued, and
4445    /// the program keeps running until the result comes back; see [`crate::task`].
4446    #[cfg(feature = "async")]
4447    pub async fn get_inventory_size_async(&self) -> Result<Number> {
4448        let args = args(vec![]);
4449        let reply = self.invoke_async("getInventorySize", args).await?;
4450        single::<Number>(reply)
4451    }
4452
4453    /// Get the maximum stack size of the item stack in the specified slot.
4454    ///
4455    /// Lua: `inventory.getSlotMaxStackSize(slot:number):number`
4456    /// Indirect call: waits for the next server tick.
4457    pub fn get_slot_max_stack_size(&self, slot: impl Into<Number>) -> Result<Number> {
4458        let args = args(vec![Some(Value::Number(slot.into()))]);
4459        let reply = self.invoke("getSlotMaxStackSize", args)?;
4460        single::<Number>(reply)
4461    }
4462
4463    /// [`Self::get_slot_max_stack_size`] without blocking: the call is queued, and
4464    /// the program keeps running until the result comes back; see [`crate::task`].
4465    #[cfg(feature = "async")]
4466    pub async fn get_slot_max_stack_size_async(&self, slot: impl Into<Number>) -> Result<Number> {
4467        let args = args(vec![Some(Value::Number(slot.into()))]);
4468        let reply = self.invoke_async("getSlotMaxStackSize", args).await?;
4469        single::<Number>(reply)
4470    }
4471
4472    /// Get the stack size of the item stack in the specified slot.
4473    ///
4474    /// Lua: `inventory.getSlotStackSize(slot:number):number`
4475    /// Indirect call: waits for the next server tick.
4476    pub fn get_slot_stack_size(&self, slot: impl Into<Number>) -> Result<Number> {
4477        let args = args(vec![Some(Value::Number(slot.into()))]);
4478        let reply = self.invoke("getSlotStackSize", args)?;
4479        single::<Number>(reply)
4480    }
4481
4482    /// [`Self::get_slot_stack_size`] without blocking: the call is queued, and
4483    /// the program keeps running until the result comes back; see [`crate::task`].
4484    #[cfg(feature = "async")]
4485    pub async fn get_slot_stack_size_async(&self, slot: impl Into<Number>) -> Result<Number> {
4486        let args = args(vec![Some(Value::Number(slot.into()))]);
4487        let reply = self.invoke_async("getSlotStackSize", args).await?;
4488        single::<Number>(reply)
4489    }
4490
4491    /// Get a description of the item stack in the specified slot.
4492    ///
4493    /// Lua: `inventory.getStackInSlot(slot:number):table`
4494    /// Indirect call: waits for the next server tick.
4495    pub fn get_stack_in_slot(&self, slot: impl Into<Number>) -> Result<Value> {
4496        let args = args(vec![Some(Value::Number(slot.into()))]);
4497        let reply = self.invoke("getStackInSlot", args)?;
4498        single::<Value>(reply)
4499    }
4500
4501    /// [`Self::get_stack_in_slot`] without blocking: the call is queued, and
4502    /// the program keeps running until the result comes back; see [`crate::task`].
4503    #[cfg(feature = "async")]
4504    pub async fn get_stack_in_slot_async(&self, slot: impl Into<Number>) -> Result<Value> {
4505        let args = args(vec![Some(Value::Number(slot.into()))]);
4506        let reply = self.invoke_async("getStackInSlot", args).await?;
4507        single::<Value>(reply)
4508    }
4509
4510    /// Move up to the specified number of items from the first specified slot to the second.
4511    ///
4512    /// Lua: `inventory.transferStack(slotA:number, slotB:number[, count:number=math.huge]):boolean`
4513    /// Indirect call: waits for the next server tick.
4514    /// `count` defaults to `math.huge`.
4515    pub fn transfer_stack(&self, slot_a: impl Into<Number>, slot_b: impl Into<Number>, count: Option<Number>) -> Result<bool> {
4516        let args = args(vec![Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), count.map(Value::Number)]);
4517        let reply = self.invoke("transferStack", args)?;
4518        single::<bool>(reply)
4519    }
4520
4521    /// [`Self::transfer_stack`] without blocking: the call is queued, and
4522    /// the program keeps running until the result comes back; see [`crate::task`].
4523    #[cfg(feature = "async")]
4524    pub async fn transfer_stack_async(&self, slot_a: impl Into<Number>, slot_b: impl Into<Number>, count: Option<Number>) -> Result<bool> {
4525        let args = args(vec![Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), count.map(Value::Number)]);
4526        let reply = self.invoke_async("transferStack", args).await?;
4527        single::<bool>(reply)
4528    }
4529}
4530
4531/// The `inventory_controller` component (24 methods).
4532///
4533/// Provided by OpenComputers' `UpgradeInventoryController$Adapter, UpgradeInventoryController$Drone, UpgradeInventoryController$Robot`.
4534#[derive(Clone, Debug, PartialEq, Eq, Hash)]
4535pub struct InventoryController(pub Address);
4536
4537impl Component for InventoryController {
4538    const KIND: &'static str = "inventory_controller";
4539    fn from_address(address: Address) -> Self {
4540        Self(address)
4541    }
4542    fn address(&self) -> &Address {
4543        &self.0
4544    }
4545}
4546
4547impl InventoryController {
4548    /// Get whether the items in the two specified slots of the inventory on the specified side of the device are equivalent (have shared item tags).
4549    ///
4550    /// Lua: `inventory_controller.areStacksEquivalent(side:number, slotA:number, slotB:number):boolean`
4551    /// Indirect call: waits for the next server tick.
4552    pub fn are_stacks_equivalent(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
4553        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
4554        let reply = self.invoke("areStacksEquivalent", args)?;
4555        single::<bool>(reply)
4556    }
4557
4558    /// [`Self::are_stacks_equivalent`] without blocking: the call is queued, and
4559    /// the program keeps running until the result comes back; see [`crate::task`].
4560    #[cfg(feature = "async")]
4561    pub async fn are_stacks_equivalent_async(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
4562        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
4563        let reply = self.invoke_async("areStacksEquivalent", args).await?;
4564        single::<bool>(reply)
4565    }
4566
4567    /// Compare an item in the specified slot in the inventory on the specified side with one in the database with the specified address.
4568    ///
4569    /// Lua: `inventory_controller.compareStackToDatabase(side:number, slot:number, dbAddress:string, dbSlot:number[, checkNBT:boolean=false]):boolean`
4570    /// Indirect call: waits for the next server tick.
4571    /// `check_nbt` defaults to `false`.
4572    pub fn compare_stack_to_database(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4573        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
4574        let reply = self.invoke("compareStackToDatabase", args)?;
4575        single::<bool>(reply)
4576    }
4577
4578    /// [`Self::compare_stack_to_database`] without blocking: the call is queued, and
4579    /// the program keeps running until the result comes back; see [`crate::task`].
4580    #[cfg(feature = "async")]
4581    pub async fn compare_stack_to_database_async(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4582        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
4583        let reply = self.invoke_async("compareStackToDatabase", args).await?;
4584        single::<bool>(reply)
4585    }
4586
4587    /// Get whether the items in the two specified slots of the inventory on the specified side of the device are of the same type.
4588    ///
4589    /// Lua: `inventory_controller.compareStacks(side:number, slotA:number, slotB:number[, checkNBT:boolean=false]):boolean`
4590    /// Indirect call: waits for the next server tick.
4591    /// `check_nbt` defaults to `false`.
4592    pub fn compare_stacks(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4593        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), check_nbt.map(Value::Bool)]);
4594        let reply = self.invoke("compareStacks", args)?;
4595        single::<bool>(reply)
4596    }
4597
4598    /// [`Self::compare_stacks`] without blocking: the call is queued, and
4599    /// the program keeps running until the result comes back; see [`crate::task`].
4600    #[cfg(feature = "async")]
4601    pub async fn compare_stacks_async(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4602        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), check_nbt.map(Value::Bool)]);
4603        let reply = self.invoke_async("compareStacks", args).await?;
4604        single::<bool>(reply)
4605    }
4606
4607    /// Compare an item in the specified slot with one in the database with the specified address.
4608    ///
4609    /// Lua: `inventory_controller.compareToDatabase(slot:number, dbAddress:string, dbSlot:number[, checkNBT:boolean=false]):boolean`
4610    /// Indirect call: waits for the next server tick.
4611    /// `check_nbt` defaults to `false`.
4612    pub fn compare_to_database(&self, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4613        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
4614        let reply = self.invoke("compareToDatabase", args)?;
4615        single::<bool>(reply)
4616    }
4617
4618    /// [`Self::compare_to_database`] without blocking: the call is queued, and
4619    /// the program keeps running until the result comes back; see [`crate::task`].
4620    #[cfg(feature = "async")]
4621    pub async fn compare_to_database_async(&self, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
4622        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
4623        let reply = self.invoke_async("compareToDatabase", args).await?;
4624        single::<bool>(reply)
4625    }
4626
4627    /// Drops an item from the selected slot into the specified slot in the item inventory.
4628    ///
4629    /// Lua: `inventory_controller.dropIntoItemInventory(inventorySlot:number, slot:number[, count:number=64]):number`
4630    /// Indirect call: waits for the next server tick.
4631    /// `count` defaults to `64`.
4632    pub fn drop_into_item_inventory(&self, inventory_slot: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>) -> Result<Number> {
4633        let args = args(vec![Some(Value::Number(inventory_slot.into())), Some(Value::Number(slot.into())), count.map(Value::Number)]);
4634        let reply = self.invoke("dropIntoItemInventory", args)?;
4635        single::<Number>(reply)
4636    }
4637
4638    /// [`Self::drop_into_item_inventory`] without blocking: the call is queued, and
4639    /// the program keeps running until the result comes back; see [`crate::task`].
4640    #[cfg(feature = "async")]
4641    pub async fn drop_into_item_inventory_async(&self, inventory_slot: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>) -> Result<Number> {
4642        let args = args(vec![Some(Value::Number(inventory_slot.into())), Some(Value::Number(slot.into())), count.map(Value::Number)]);
4643        let reply = self.invoke_async("dropIntoItemInventory", args).await?;
4644        single::<Number>(reply)
4645    }
4646
4647    /// Drops the selected item stack into the specified slot of an inventory.
4648    ///
4649    /// Lua: `inventory_controller.dropIntoSlot(facing:number, slot:number[, count:number[, fromSide:number]]):boolean`
4650    /// Indirect call: waits for the next server tick.
4651    pub fn drop_into_slot(&self, facing: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>, from_side: Option<Number>) -> Result<bool> {
4652        let args = args(vec![Some(Value::Number(facing.into())), Some(Value::Number(slot.into())), count.map(Value::Number), from_side.map(Value::Number)]);
4653        let reply = self.invoke("dropIntoSlot", args)?;
4654        single::<bool>(reply)
4655    }
4656
4657    /// [`Self::drop_into_slot`] without blocking: the call is queued, and
4658    /// the program keeps running until the result comes back; see [`crate::task`].
4659    #[cfg(feature = "async")]
4660    pub async fn drop_into_slot_async(&self, facing: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>, from_side: Option<Number>) -> Result<bool> {
4661        let args = args(vec![Some(Value::Number(facing.into())), Some(Value::Number(slot.into())), count.map(Value::Number), from_side.map(Value::Number)]);
4662        let reply = self.invoke_async("dropIntoSlot", args).await?;
4663        single::<bool>(reply)
4664    }
4665
4666    /// Swaps the equipped tool with the content of the currently selected inventory slot.
4667    ///
4668    /// Lua: `inventory_controller.equip():boolean`
4669    /// Indirect call: waits for the next server tick.
4670    pub fn equip(&self) -> Result<bool> {
4671        let args = args(vec![]);
4672        let reply = self.invoke("equip", args)?;
4673        single::<bool>(reply)
4674    }
4675
4676    /// [`Self::equip`] without blocking: the call is queued, and
4677    /// the program keeps running until the result comes back; see [`crate::task`].
4678    #[cfg(feature = "async")]
4679    pub async fn equip_async(&self) -> Result<bool> {
4680        let args = args(vec![]);
4681        let reply = self.invoke_async("equip", args).await?;
4682        single::<bool>(reply)
4683    }
4684
4685    /// Get a description of all stacks in the inventory on the specified side of the device.
4686    ///
4687    /// Lua: `inventory_controller.getAllStacks(side:number):userdata`
4688    /// Indirect call: waits for the next server tick.
4689    pub fn get_all_stacks(&self, side: impl Into<Number>) -> Result<Handle> {
4690        let args = args(vec![Some(Value::Number(side.into()))]);
4691        let reply = self.invoke("getAllStacks", args)?;
4692        single::<Handle>(reply)
4693    }
4694
4695    /// [`Self::get_all_stacks`] without blocking: the call is queued, and
4696    /// the program keeps running until the result comes back; see [`crate::task`].
4697    #[cfg(feature = "async")]
4698    pub async fn get_all_stacks_async(&self, side: impl Into<Number>) -> Result<Handle> {
4699        let args = args(vec![Some(Value::Number(side.into()))]);
4700        let reply = self.invoke_async("getAllStacks", args).await?;
4701        single::<Handle>(reply)
4702    }
4703
4704    /// Get the name of the inventory on the specified side of the device.
4705    ///
4706    /// Lua: `inventory_controller.getInventoryName(side:number):string`
4707    /// Indirect call: waits for the next server tick.
4708    pub fn get_inventory_name(&self, side: impl Into<Number>) -> Result<OcString> {
4709        let args = args(vec![Some(Value::Number(side.into()))]);
4710        let reply = self.invoke("getInventoryName", args)?;
4711        single::<OcString>(reply)
4712    }
4713
4714    /// [`Self::get_inventory_name`] without blocking: the call is queued, and
4715    /// the program keeps running until the result comes back; see [`crate::task`].
4716    #[cfg(feature = "async")]
4717    pub async fn get_inventory_name_async(&self, side: impl Into<Number>) -> Result<OcString> {
4718        let args = args(vec![Some(Value::Number(side.into()))]);
4719        let reply = self.invoke_async("getInventoryName", args).await?;
4720        single::<OcString>(reply)
4721    }
4722
4723    /// Get the number of slots in the inventory on the specified side of the device.
4724    ///
4725    /// Lua: `inventory_controller.getInventorySize(side:number):number`
4726    /// Indirect call: waits for the next server tick.
4727    pub fn get_inventory_size(&self, side: impl Into<Number>) -> Result<Number> {
4728        let args = args(vec![Some(Value::Number(side.into()))]);
4729        let reply = self.invoke("getInventorySize", args)?;
4730        single::<Number>(reply)
4731    }
4732
4733    /// [`Self::get_inventory_size`] without blocking: the call is queued, and
4734    /// the program keeps running until the result comes back; see [`crate::task`].
4735    #[cfg(feature = "async")]
4736    pub async fn get_inventory_size_async(&self, side: impl Into<Number>) -> Result<Number> {
4737        let args = args(vec![Some(Value::Number(side.into()))]);
4738        let reply = self.invoke_async("getInventorySize", args).await?;
4739        single::<Number>(reply)
4740    }
4741
4742    /// The size of an item inventory in the specified slot.
4743    ///
4744    /// Lua: `inventory_controller.getItemInventorySize(slot:number):number`
4745    /// Indirect call: waits for the next server tick.
4746    pub fn get_item_inventory_size(&self, slot: impl Into<Number>) -> Result<Number> {
4747        let args = args(vec![Some(Value::Number(slot.into()))]);
4748        let reply = self.invoke("getItemInventorySize", args)?;
4749        single::<Number>(reply)
4750    }
4751
4752    /// [`Self::get_item_inventory_size`] without blocking: the call is queued, and
4753    /// the program keeps running until the result comes back; see [`crate::task`].
4754    #[cfg(feature = "async")]
4755    pub async fn get_item_inventory_size_async(&self, slot: impl Into<Number>) -> Result<Number> {
4756        let args = args(vec![Some(Value::Number(slot.into()))]);
4757        let reply = self.invoke_async("getItemInventorySize", args).await?;
4758        single::<Number>(reply)
4759    }
4760
4761    /// Get the maximum number of items in the specified slot of the inventory on the specified side of the device.
4762    ///
4763    /// Lua: `inventory_controller.getSlotMaxStackSize(side:number, slot:number):number`
4764    /// Indirect call: waits for the next server tick.
4765    pub fn get_slot_max_stack_size(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
4766        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4767        let reply = self.invoke("getSlotMaxStackSize", args)?;
4768        single::<Number>(reply)
4769    }
4770
4771    /// [`Self::get_slot_max_stack_size`] without blocking: the call is queued, and
4772    /// the program keeps running until the result comes back; see [`crate::task`].
4773    #[cfg(feature = "async")]
4774    pub async fn get_slot_max_stack_size_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
4775        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4776        let reply = self.invoke_async("getSlotMaxStackSize", args).await?;
4777        single::<Number>(reply)
4778    }
4779
4780    /// Get number of items in the specified slot of the inventory on the specified side of the device.
4781    ///
4782    /// Lua: `inventory_controller.getSlotStackSize(side:number, slot:number):number`
4783    /// Indirect call: waits for the next server tick.
4784    pub fn get_slot_stack_size(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
4785        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4786        let reply = self.invoke("getSlotStackSize", args)?;
4787        single::<Number>(reply)
4788    }
4789
4790    /// [`Self::get_slot_stack_size`] without blocking: the call is queued, and
4791    /// the program keeps running until the result comes back; see [`crate::task`].
4792    #[cfg(feature = "async")]
4793    pub async fn get_slot_stack_size_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
4794        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4795        let reply = self.invoke_async("getSlotStackSize", args).await?;
4796        single::<Number>(reply)
4797    }
4798
4799    /// Get a description of the stack in the specified slot or the selected slot.
4800    ///
4801    /// Lua: `inventory_controller.getStackInInternalSlot([slot:number]):table`
4802    /// Indirect call: waits for the next server tick.
4803    pub fn get_stack_in_internal_slot(&self, slot: Option<Number>) -> Result<Value> {
4804        let args = args(vec![slot.map(Value::Number)]);
4805        let reply = self.invoke("getStackInInternalSlot", args)?;
4806        single::<Value>(reply)
4807    }
4808
4809    /// [`Self::get_stack_in_internal_slot`] without blocking: the call is queued, and
4810    /// the program keeps running until the result comes back; see [`crate::task`].
4811    #[cfg(feature = "async")]
4812    pub async fn get_stack_in_internal_slot_async(&self, slot: Option<Number>) -> Result<Value> {
4813        let args = args(vec![slot.map(Value::Number)]);
4814        let reply = self.invoke_async("getStackInInternalSlot", args).await?;
4815        single::<Value>(reply)
4816    }
4817
4818    /// Get a description of the stack in the inventory on the specified side of the device.
4819    ///
4820    /// Lua: `inventory_controller.getStackInSlot(side:number, slot:number):table`
4821    /// Indirect call: waits for the next server tick.
4822    pub fn get_stack_in_slot(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
4823        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4824        let reply = self.invoke("getStackInSlot", args)?;
4825        single::<Value>(reply)
4826    }
4827
4828    /// [`Self::get_stack_in_slot`] without blocking: the call is queued, and
4829    /// the program keeps running until the result comes back; see [`crate::task`].
4830    #[cfg(feature = "async")]
4831    pub async fn get_stack_in_slot_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
4832        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
4833        let reply = self.invoke_async("getStackInSlot", args).await?;
4834        single::<Value>(reply)
4835    }
4836
4837    /// get upgrade container tier at the given slot.
4838    ///
4839    /// Lua: `inventory_controller.getUpgradeContainerTier(slot:number):number`
4840    /// Indirect call: waits for the next server tick.
4841    pub fn get_upgrade_container_tier(&self, slot: impl Into<Number>) -> Result<Number> {
4842        let args = args(vec![Some(Value::Number(slot.into()))]);
4843        let reply = self.invoke("getUpgradeContainerTier", args)?;
4844        single::<Number>(reply)
4845    }
4846
4847    /// [`Self::get_upgrade_container_tier`] without blocking: the call is queued, and
4848    /// the program keeps running until the result comes back; see [`crate::task`].
4849    #[cfg(feature = "async")]
4850    pub async fn get_upgrade_container_tier_async(&self, slot: impl Into<Number>) -> Result<Number> {
4851        let args = args(vec![Some(Value::Number(slot.into()))]);
4852        let reply = self.invoke_async("getUpgradeContainerTier", args).await?;
4853        single::<Number>(reply)
4854    }
4855
4856    /// get upgrade container type at the given slot.
4857    ///
4858    /// Lua: `inventory_controller.getUpgradeContainerType(slot:number):string`
4859    /// Indirect call: waits for the next server tick.
4860    pub fn get_upgrade_container_type(&self, slot: impl Into<Number>) -> Result<OcString> {
4861        let args = args(vec![Some(Value::Number(slot.into()))]);
4862        let reply = self.invoke("getUpgradeContainerType", args)?;
4863        single::<OcString>(reply)
4864    }
4865
4866    /// [`Self::get_upgrade_container_type`] without blocking: the call is queued, and
4867    /// the program keeps running until the result comes back; see [`crate::task`].
4868    #[cfg(feature = "async")]
4869    pub async fn get_upgrade_container_type_async(&self, slot: impl Into<Number>) -> Result<OcString> {
4870        let args = args(vec![Some(Value::Number(slot.into()))]);
4871        let reply = self.invoke_async("getUpgradeContainerType", args).await?;
4872        single::<OcString>(reply)
4873    }
4874
4875    /// Swaps the installed upgrade in the slot (1 by default) with the content of the currently selected inventory slot.
4876    ///
4877    /// Lua: `inventory_controller.installUpgrade([slot:number]):boolean`
4878    /// Indirect call: waits for the next server tick.
4879    pub fn install_upgrade(&self, slot: Option<Number>) -> Result<bool> {
4880        let args = args(vec![slot.map(Value::Number)]);
4881        let reply = self.invoke("installUpgrade", args)?;
4882        single::<bool>(reply)
4883    }
4884
4885    /// [`Self::install_upgrade`] without blocking: the call is queued, and
4886    /// the program keeps running until the result comes back; see [`crate::task`].
4887    #[cfg(feature = "async")]
4888    pub async fn install_upgrade_async(&self, slot: Option<Number>) -> Result<bool> {
4889        let args = args(vec![slot.map(Value::Number)]);
4890        let reply = self.invoke_async("installUpgrade", args).await?;
4891        single::<bool>(reply)
4892    }
4893
4894    /// Get whether the stack in the selected slot is equivalent to the item in the specified slot (have shared OreDictionary IDs).
4895    ///
4896    /// Lua: `inventory_controller.isEquivalentTo(otherSlot:number):boolean`
4897    /// Indirect call: waits for the next server tick.
4898    pub fn is_equivalent_to(&self, other_slot: impl Into<Number>) -> Result<bool> {
4899        let args = args(vec![Some(Value::Number(other_slot.into()))]);
4900        let reply = self.invoke("isEquivalentTo", args)?;
4901        single::<bool>(reply)
4902    }
4903
4904    /// [`Self::is_equivalent_to`] without blocking: the call is queued, and
4905    /// the program keeps running until the result comes back; see [`crate::task`].
4906    #[cfg(feature = "async")]
4907    pub async fn is_equivalent_to_async(&self, other_slot: impl Into<Number>) -> Result<bool> {
4908        let args = args(vec![Some(Value::Number(other_slot.into()))]);
4909        let reply = self.invoke_async("isEquivalentTo", args).await?;
4910        single::<bool>(reply)
4911    }
4912
4913    /// Change the display name of the stack.
4914    ///
4915    /// Lua: `inventory_controller.setStackDisplayName(side:number, slot:number, label:string):boolean`
4916    /// Indirect call: waits for the next server tick.
4917    pub fn set_stack_display_name(&self, side: impl Into<Number>, slot: impl Into<Number>, label: impl AsRef<[u8]>) -> Result<bool> {
4918        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(label.as_ref()))]);
4919        let reply = self.invoke("setStackDisplayName", args)?;
4920        single::<bool>(reply)
4921    }
4922
4923    /// [`Self::set_stack_display_name`] without blocking: the call is queued, and
4924    /// the program keeps running until the result comes back; see [`crate::task`].
4925    #[cfg(feature = "async")]
4926    pub async fn set_stack_display_name_async(&self, side: impl Into<Number>, slot: impl Into<Number>, label: impl AsRef<[u8]>) -> Result<bool> {
4927        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(label.as_ref()))]);
4928        let reply = self.invoke_async("setStackDisplayName", args).await?;
4929        single::<bool>(reply)
4930    }
4931
4932    /// Store an item stack description in the specified slot of the database with the specified address.
4933    ///
4934    /// Lua: `inventory_controller.store(side:number, slot:number, dbAddress:string, dbSlot:number):boolean`
4935    /// Indirect call: waits for the next server tick.
4936    pub fn store(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
4937        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
4938        let reply = self.invoke("store", args)?;
4939        single::<bool>(reply)
4940    }
4941
4942    /// [`Self::store`] without blocking: the call is queued, and
4943    /// the program keeps running until the result comes back; see [`crate::task`].
4944    #[cfg(feature = "async")]
4945    pub async fn store_async(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
4946        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
4947        let reply = self.invoke_async("store", args).await?;
4948        single::<bool>(reply)
4949    }
4950
4951    /// Store an item stack description in the specified slot of the database with the specified address.
4952    ///
4953    /// Lua: `inventory_controller.storeInternal(slot:number, dbAddress:string, dbSlot:number):boolean`
4954    /// Indirect call: waits for the next server tick.
4955    pub fn store_internal(&self, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
4956        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
4957        let reply = self.invoke("storeInternal", args)?;
4958        single::<bool>(reply)
4959    }
4960
4961    /// [`Self::store_internal`] without blocking: the call is queued, and
4962    /// the program keeps running until the result comes back; see [`crate::task`].
4963    #[cfg(feature = "async")]
4964    pub async fn store_internal_async(&self, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
4965        let args = args(vec![Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
4966        let reply = self.invoke_async("storeInternal", args).await?;
4967        single::<bool>(reply)
4968    }
4969
4970    /// Sucks an item out of the specified slot in the item inventory.
4971    ///
4972    /// Lua: `inventory_controller.suckFromItemInventory(inventorySlot:number, slot:number[, count:number=64]):number`
4973    /// Indirect call: waits for the next server tick.
4974    /// `count` defaults to `64`.
4975    pub fn suck_from_item_inventory(&self, inventory_slot: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>) -> Result<Number> {
4976        let args = args(vec![Some(Value::Number(inventory_slot.into())), Some(Value::Number(slot.into())), count.map(Value::Number)]);
4977        let reply = self.invoke("suckFromItemInventory", args)?;
4978        single::<Number>(reply)
4979    }
4980
4981    /// [`Self::suck_from_item_inventory`] without blocking: the call is queued, and
4982    /// the program keeps running until the result comes back; see [`crate::task`].
4983    #[cfg(feature = "async")]
4984    pub async fn suck_from_item_inventory_async(&self, inventory_slot: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>) -> Result<Number> {
4985        let args = args(vec![Some(Value::Number(inventory_slot.into())), Some(Value::Number(slot.into())), count.map(Value::Number)]);
4986        let reply = self.invoke_async("suckFromItemInventory", args).await?;
4987        single::<Number>(reply)
4988    }
4989
4990    /// Sucks items from the specified slot of an inventory.
4991    ///
4992    /// Lua: `inventory_controller.suckFromSlot(facing:number, slot:number[, count:number[, fromSide:number]]):boolean`
4993    /// Indirect call: waits for the next server tick.
4994    pub fn suck_from_slot(&self, facing: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>, from_side: Option<Number>) -> Result<bool> {
4995        let args = args(vec![Some(Value::Number(facing.into())), Some(Value::Number(slot.into())), count.map(Value::Number), from_side.map(Value::Number)]);
4996        let reply = self.invoke("suckFromSlot", args)?;
4997        single::<bool>(reply)
4998    }
4999
5000    /// [`Self::suck_from_slot`] without blocking: the call is queued, and
5001    /// the program keeps running until the result comes back; see [`crate::task`].
5002    #[cfg(feature = "async")]
5003    pub async fn suck_from_slot_async(&self, facing: impl Into<Number>, slot: impl Into<Number>, count: Option<Number>, from_side: Option<Number>) -> Result<bool> {
5004        let args = args(vec![Some(Value::Number(facing.into())), Some(Value::Number(slot.into())), count.map(Value::Number), from_side.map(Value::Number)]);
5005        let reply = self.invoke_async("suckFromSlot", args).await?;
5006        single::<bool>(reply)
5007    }
5008}
5009
5010/// The `jukebox` component (3 methods).
5011///
5012/// Provided by OpenComputers' `DriverRecordPlayer$Environment`.
5013#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5014pub struct Jukebox(pub Address);
5015
5016impl Component for Jukebox {
5017    const KIND: &'static str = "jukebox";
5018    fn from_address(address: Address) -> Self {
5019        Self(address)
5020    }
5021    fn address(&self) -> &Address {
5022        &self.0
5023    }
5024}
5025
5026impl Jukebox {
5027    /// Get the title of the record currently in the jukebox.
5028    ///
5029    /// Lua: `jukebox.getRecord():string`
5030    /// Indirect call: waits for the next server tick.
5031    pub fn get_record(&self) -> Result<OcString> {
5032        let args = args(vec![]);
5033        let reply = self.invoke("getRecord", args)?;
5034        single::<OcString>(reply)
5035    }
5036
5037    /// [`Self::get_record`] without blocking: the call is queued, and
5038    /// the program keeps running until the result comes back; see [`crate::task`].
5039    #[cfg(feature = "async")]
5040    pub async fn get_record_async(&self) -> Result<OcString> {
5041        let args = args(vec![]);
5042        let reply = self.invoke_async("getRecord", args).await?;
5043        single::<OcString>(reply)
5044    }
5045
5046    /// Start playing the record currently in the jukebox.
5047    ///
5048    /// Lua: `jukebox.play()`
5049    /// Indirect call: waits for the next server tick.
5050    pub fn play(&self) -> Result<()> {
5051        let args = args(vec![]);
5052        let reply = self.invoke("play", args)?;
5053        FromReply::from_reply(reply)
5054    }
5055
5056    /// [`Self::play`] without blocking: the call is queued, and
5057    /// the program keeps running until the result comes back; see [`crate::task`].
5058    #[cfg(feature = "async")]
5059    pub async fn play_async(&self) -> Result<()> {
5060        let args = args(vec![]);
5061        let reply = self.invoke_async("play", args).await?;
5062        FromReply::from_reply(reply)
5063    }
5064
5065    /// Stop playing the record currently in the jukebox.
5066    ///
5067    /// Lua: `jukebox.stop()`
5068    /// Indirect call: waits for the next server tick.
5069    pub fn stop(&self) -> Result<()> {
5070        let args = args(vec![]);
5071        let reply = self.invoke("stop", args)?;
5072        FromReply::from_reply(reply)
5073    }
5074
5075    /// [`Self::stop`] without blocking: the call is queued, and
5076    /// the program keeps running until the result comes back; see [`crate::task`].
5077    #[cfg(feature = "async")]
5078    pub async fn stop_async(&self) -> Result<()> {
5079        let args = args(vec![]);
5080        let reply = self.invoke_async("stop", args).await?;
5081        FromReply::from_reply(reply)
5082    }
5083}
5084
5085/// The `keyboard` component (0 methods).
5086///
5087/// Provided by OpenComputers' `Keyboard`.
5088#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5089pub struct Keyboard(pub Address);
5090
5091impl Component for Keyboard {
5092    const KIND: &'static str = "keyboard";
5093    fn from_address(address: Address) -> Self {
5094        Self(address)
5095    }
5096    fn address(&self) -> &Address {
5097        &self.0
5098    }
5099}
5100
5101/// The `leash` component (2 methods).
5102///
5103/// Provided by OpenComputers' `UpgradeLeash`.
5104#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5105pub struct Leash(pub Address);
5106
5107impl Component for Leash {
5108    const KIND: &'static str = "leash";
5109    fn from_address(address: Address) -> Self {
5110        Self(address)
5111    }
5112    fn address(&self) -> &Address {
5113        &self.0
5114    }
5115}
5116
5117impl Leash {
5118    /// Tries to put an entity on the specified side of the device onto a leash.
5119    ///
5120    /// Lua: `leash.leash(side:number):boolean`
5121    /// Indirect call: waits for the next server tick.
5122    pub fn leash(&self, side: impl Into<Number>) -> Result<bool> {
5123        let args = args(vec![Some(Value::Number(side.into()))]);
5124        let reply = self.invoke("leash", args)?;
5125        single::<bool>(reply)
5126    }
5127
5128    /// [`Self::leash`] without blocking: the call is queued, and
5129    /// the program keeps running until the result comes back; see [`crate::task`].
5130    #[cfg(feature = "async")]
5131    pub async fn leash_async(&self, side: impl Into<Number>) -> Result<bool> {
5132        let args = args(vec![Some(Value::Number(side.into()))]);
5133        let reply = self.invoke_async("leash", args).await?;
5134        single::<bool>(reply)
5135    }
5136
5137    /// Unleashes all currently leashed entities.
5138    ///
5139    /// Lua: `leash.unleash()`
5140    /// Indirect call: waits for the next server tick.
5141    pub fn unleash(&self) -> Result<()> {
5142        let args = args(vec![]);
5143        let reply = self.invoke("unleash", args)?;
5144        FromReply::from_reply(reply)
5145    }
5146
5147    /// [`Self::unleash`] without blocking: the call is queued, and
5148    /// the program keeps running until the result comes back; see [`crate::task`].
5149    #[cfg(feature = "async")]
5150    pub async fn unleash_async(&self) -> Result<()> {
5151        let args = args(vec![]);
5152        let reply = self.invoke_async("unleash", args).await?;
5153        FromReply::from_reply(reply)
5154    }
5155}
5156
5157/// The `microcontroller` component (6 methods).
5158///
5159/// Provided by OpenComputers' `Microcontroller`.
5160#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5161pub struct Microcontroller(pub Address);
5162
5163impl Component for Microcontroller {
5164    const KIND: &'static str = "microcontroller";
5165    fn from_address(address: Address) -> Self {
5166        Self(address)
5167    }
5168    fn address(&self) -> &Address {
5169        &self.0
5170    }
5171}
5172
5173impl Microcontroller {
5174    /// Returns whether the microcontroller is running.
5175    ///
5176    /// Lua: `microcontroller.isRunning():boolean`
5177    /// Direct call (runs immediately, drawing on the per-tick budget).
5178    pub fn is_running(&self) -> Result<bool> {
5179        let args = args(vec![]);
5180        let reply = self.invoke("isRunning", args)?;
5181        single::<bool>(reply)
5182    }
5183
5184    /// [`Self::is_running`] without blocking: the call is queued, and
5185    /// the program keeps running until the result comes back; see [`crate::task`].
5186    #[cfg(feature = "async")]
5187    pub async fn is_running_async(&self) -> Result<bool> {
5188        let args = args(vec![]);
5189        let reply = self.invoke_async("isRunning", args).await?;
5190        single::<bool>(reply)
5191    }
5192
5193    /// Get whether network messages are sent via the specified side.
5194    ///
5195    /// Lua: `microcontroller.isSideOpen(side:number):boolean`
5196    /// Direct call (runs immediately, drawing on the per-tick budget).
5197    pub fn is_side_open(&self, side: impl Into<Number>) -> Result<bool> {
5198        let args = args(vec![Some(Value::Number(side.into()))]);
5199        let reply = self.invoke("isSideOpen", args)?;
5200        single::<bool>(reply)
5201    }
5202
5203    /// [`Self::is_side_open`] without blocking: the call is queued, and
5204    /// the program keeps running until the result comes back; see [`crate::task`].
5205    #[cfg(feature = "async")]
5206    pub async fn is_side_open_async(&self, side: impl Into<Number>) -> Result<bool> {
5207        let args = args(vec![Some(Value::Number(side.into()))]);
5208        let reply = self.invoke_async("isSideOpen", args).await?;
5209        single::<bool>(reply)
5210    }
5211
5212    /// Returns the reason the microcontroller crashed, if applicable.
5213    ///
5214    /// Lua: `microcontroller.lastError():string`
5215    /// Direct call (runs immediately, drawing on the per-tick budget).
5216    pub fn last_error(&self) -> Result<OcString> {
5217        let args = args(vec![]);
5218        let reply = self.invoke("lastError", args)?;
5219        single::<OcString>(reply)
5220    }
5221
5222    /// [`Self::last_error`] without blocking: the call is queued, and
5223    /// the program keeps running until the result comes back; see [`crate::task`].
5224    #[cfg(feature = "async")]
5225    pub async fn last_error_async(&self) -> Result<OcString> {
5226        let args = args(vec![]);
5227        let reply = self.invoke_async("lastError", args).await?;
5228        single::<OcString>(reply)
5229    }
5230
5231    /// Set whether network messages are sent via the specified side.
5232    ///
5233    /// Lua: `microcontroller.setSideOpen(side:number, open:boolean):boolean`
5234    /// Indirect call: waits for the next server tick.
5235    pub fn set_side_open(&self, side: impl Into<Number>, open: bool) -> Result<bool> {
5236        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Bool(open))]);
5237        let reply = self.invoke("setSideOpen", args)?;
5238        single::<bool>(reply)
5239    }
5240
5241    /// [`Self::set_side_open`] without blocking: the call is queued, and
5242    /// the program keeps running until the result comes back; see [`crate::task`].
5243    #[cfg(feature = "async")]
5244    pub async fn set_side_open_async(&self, side: impl Into<Number>, open: bool) -> Result<bool> {
5245        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Bool(open))]);
5246        let reply = self.invoke_async("setSideOpen", args).await?;
5247        single::<bool>(reply)
5248    }
5249
5250    /// Starts the microcontroller. Returns true if the state changed.
5251    ///
5252    /// Lua: `microcontroller.start():boolean`
5253    /// Indirect call: waits for the next server tick.
5254    pub fn start(&self) -> Result<bool> {
5255        let args = args(vec![]);
5256        let reply = self.invoke("start", args)?;
5257        single::<bool>(reply)
5258    }
5259
5260    /// [`Self::start`] without blocking: the call is queued, and
5261    /// the program keeps running until the result comes back; see [`crate::task`].
5262    #[cfg(feature = "async")]
5263    pub async fn start_async(&self) -> Result<bool> {
5264        let args = args(vec![]);
5265        let reply = self.invoke_async("start", args).await?;
5266        single::<bool>(reply)
5267    }
5268
5269    /// Stops the microcontroller. Returns true if the state changed.
5270    ///
5271    /// Lua: `microcontroller.stop():boolean`
5272    /// Indirect call: waits for the next server tick.
5273    pub fn stop(&self) -> Result<bool> {
5274        let args = args(vec![]);
5275        let reply = self.invoke("stop", args)?;
5276        single::<bool>(reply)
5277    }
5278
5279    /// [`Self::stop`] without blocking: the call is queued, and
5280    /// the program keeps running until the result comes back; see [`crate::task`].
5281    #[cfg(feature = "async")]
5282    pub async fn stop_async(&self) -> Result<bool> {
5283        let args = args(vec![]);
5284        let reply = self.invoke_async("stop", args).await?;
5285        single::<bool>(reply)
5286    }
5287}
5288
5289/// The `mob_spawner` component (1 methods).
5290///
5291/// Provided by OpenComputers' `DriverMobSpawner$Environment`.
5292#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5293pub struct MobSpawner(pub Address);
5294
5295impl Component for MobSpawner {
5296    const KIND: &'static str = "mob_spawner";
5297    fn from_address(address: Address) -> Self {
5298        Self(address)
5299    }
5300    fn address(&self) -> &Address {
5301        &self.0
5302    }
5303}
5304
5305impl MobSpawner {
5306    /// Get the name of the entity that is being spawned by this spawner.
5307    ///
5308    /// Lua: `mob_spawner.getSpawningMobName():string`
5309    /// Indirect call: waits for the next server tick.
5310    pub fn get_spawning_mob_name(&self) -> Result<OcString> {
5311        let args = args(vec![]);
5312        let reply = self.invoke("getSpawningMobName", args)?;
5313        single::<OcString>(reply)
5314    }
5315
5316    /// [`Self::get_spawning_mob_name`] without blocking: the call is queued, and
5317    /// the program keeps running until the result comes back; see [`crate::task`].
5318    #[cfg(feature = "async")]
5319    pub async fn get_spawning_mob_name_async(&self) -> Result<OcString> {
5320        let args = args(vec![]);
5321        let reply = self.invoke_async("getSpawningMobName", args).await?;
5322        single::<OcString>(reply)
5323    }
5324}
5325
5326/// The `modem` component (12 methods).
5327///
5328/// Provided by OpenComputers' `NetworkCard, WirelessNetworkCard, WirelessNetworkCard$Tier1, WirelessNetworkCard$Tier2`.
5329#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5330pub struct Modem(pub Address);
5331
5332impl Component for Modem {
5333    const KIND: &'static str = "modem";
5334    fn from_address(address: Address) -> Self {
5335        Self(address)
5336    }
5337    fn address(&self) -> &Address {
5338        &self.0
5339    }
5340}
5341
5342impl Modem {
5343    /// Broadcasts the specified data on the specified port.
5344    ///
5345    /// Lua: `modem.broadcast(port:number, data...)`
5346    /// Indirect call: waits for the next server tick.
5347    pub fn broadcast(&self, port: impl Into<Number>, data: &[Value]) -> Result<()> {
5348        let mut args: Vec<Value> = vec![Some(Value::Number(port.into()))].into_iter().map(Option::unwrap_or_default).collect();
5349        args.extend_from_slice(data);
5350        let reply = self.invoke("broadcast", args)?;
5351        FromReply::from_reply(reply)
5352    }
5353
5354    /// [`Self::broadcast`] without blocking: the call is queued, and
5355    /// the program keeps running until the result comes back; see [`crate::task`].
5356    #[cfg(feature = "async")]
5357    pub async fn broadcast_async(&self, port: impl Into<Number>, data: &[Value]) -> Result<()> {
5358        let mut args: Vec<Value> = vec![Some(Value::Number(port.into()))].into_iter().map(Option::unwrap_or_default).collect();
5359        args.extend_from_slice(data);
5360        let reply = self.invoke_async("broadcast", args).await?;
5361        FromReply::from_reply(reply)
5362    }
5363
5364    /// Closes the specified port (default: all ports). Returns true if ports were closed.
5365    ///
5366    /// Lua: `modem.close([port:number]):boolean`
5367    /// Indirect call: waits for the next server tick.
5368    pub fn close(&self, port: Option<Number>) -> Result<bool> {
5369        let args = args(vec![port.map(Value::Number)]);
5370        let reply = self.invoke("close", args)?;
5371        single::<bool>(reply)
5372    }
5373
5374    /// [`Self::close`] without blocking: the call is queued, and
5375    /// the program keeps running until the result comes back; see [`crate::task`].
5376    #[cfg(feature = "async")]
5377    pub async fn close_async(&self, port: Option<Number>) -> Result<bool> {
5378        let args = args(vec![port.map(Value::Number)]);
5379        let reply = self.invoke_async("close", args).await?;
5380        single::<bool>(reply)
5381    }
5382
5383    /// Get the signal strength (range) used when sending messages.
5384    ///
5385    /// Lua: `modem.getStrength():number`
5386    /// Direct call (runs immediately, drawing on the per-tick budget).
5387    pub fn get_strength(&self) -> Result<Number> {
5388        let args = args(vec![]);
5389        let reply = self.invoke("getStrength", args)?;
5390        single::<Number>(reply)
5391    }
5392
5393    /// [`Self::get_strength`] without blocking: the call is queued, and
5394    /// the program keeps running until the result comes back; see [`crate::task`].
5395    #[cfg(feature = "async")]
5396    pub async fn get_strength_async(&self) -> Result<Number> {
5397        let args = args(vec![]);
5398        let reply = self.invoke_async("getStrength", args).await?;
5399        single::<Number>(reply)
5400    }
5401
5402    /// Get the current wake-up message.
5403    ///
5404    /// Lua: `modem.getWakeMessage():string, boolean`
5405    /// Direct call (runs immediately, drawing on the per-tick budget).
5406    pub fn get_wake_message(&self) -> Result<(OcString, bool)> {
5407        let args = args(vec![]);
5408        let reply = self.invoke("getWakeMessage", args)?;
5409        FromReply::from_reply(reply)
5410    }
5411
5412    /// [`Self::get_wake_message`] without blocking: the call is queued, and
5413    /// the program keeps running until the result comes back; see [`crate::task`].
5414    #[cfg(feature = "async")]
5415    pub async fn get_wake_message_async(&self) -> Result<(OcString, bool)> {
5416        let args = args(vec![]);
5417        let reply = self.invoke_async("getWakeMessage", args).await?;
5418        FromReply::from_reply(reply)
5419    }
5420
5421    /// Whether the specified port is open.
5422    ///
5423    /// Lua: `modem.isOpen(port:number):boolean`
5424    /// Direct call (runs immediately, drawing on the per-tick budget).
5425    pub fn is_open(&self, port: impl Into<Number>) -> Result<bool> {
5426        let args = args(vec![Some(Value::Number(port.into()))]);
5427        let reply = self.invoke("isOpen", args)?;
5428        single::<bool>(reply)
5429    }
5430
5431    /// [`Self::is_open`] without blocking: the call is queued, and
5432    /// the program keeps running until the result comes back; see [`crate::task`].
5433    #[cfg(feature = "async")]
5434    pub async fn is_open_async(&self, port: impl Into<Number>) -> Result<bool> {
5435        let args = args(vec![Some(Value::Number(port.into()))]);
5436        let reply = self.invoke_async("isOpen", args).await?;
5437        single::<bool>(reply)
5438    }
5439
5440    /// Whether this card has wired networking capability.
5441    ///
5442    /// Lua: `modem.isWired():boolean`
5443    /// Direct call (runs immediately, drawing on the per-tick budget).
5444    pub fn is_wired(&self) -> Result<bool> {
5445        let args = args(vec![]);
5446        let reply = self.invoke("isWired", args)?;
5447        single::<bool>(reply)
5448    }
5449
5450    /// [`Self::is_wired`] without blocking: the call is queued, and
5451    /// the program keeps running until the result comes back; see [`crate::task`].
5452    #[cfg(feature = "async")]
5453    pub async fn is_wired_async(&self) -> Result<bool> {
5454        let args = args(vec![]);
5455        let reply = self.invoke_async("isWired", args).await?;
5456        single::<bool>(reply)
5457    }
5458
5459    /// Whether this card has wireless networking capability.
5460    ///
5461    /// Lua: `modem.isWireless():boolean`
5462    /// Direct call (runs immediately, drawing on the per-tick budget).
5463    pub fn is_wireless(&self) -> Result<bool> {
5464        let args = args(vec![]);
5465        let reply = self.invoke("isWireless", args)?;
5466        single::<bool>(reply)
5467    }
5468
5469    /// [`Self::is_wireless`] without blocking: the call is queued, and
5470    /// the program keeps running until the result comes back; see [`crate::task`].
5471    #[cfg(feature = "async")]
5472    pub async fn is_wireless_async(&self) -> Result<bool> {
5473        let args = args(vec![]);
5474        let reply = self.invoke_async("isWireless", args).await?;
5475        single::<bool>(reply)
5476    }
5477
5478    /// Gets the maximum packet size (config setting).
5479    ///
5480    /// Lua: `modem.maxPacketSize():number`
5481    /// Direct call (runs immediately, drawing on the per-tick budget).
5482    pub fn max_packet_size(&self) -> Result<Number> {
5483        let args = args(vec![]);
5484        let reply = self.invoke("maxPacketSize", args)?;
5485        single::<Number>(reply)
5486    }
5487
5488    /// [`Self::max_packet_size`] without blocking: the call is queued, and
5489    /// the program keeps running until the result comes back; see [`crate::task`].
5490    #[cfg(feature = "async")]
5491    pub async fn max_packet_size_async(&self) -> Result<Number> {
5492        let args = args(vec![]);
5493        let reply = self.invoke_async("maxPacketSize", args).await?;
5494        single::<Number>(reply)
5495    }
5496
5497    /// Opens the specified port. Returns true if the port was opened.
5498    ///
5499    /// Lua: `modem.open(port:number):boolean`
5500    /// Indirect call: waits for the next server tick.
5501    pub fn open(&self, port: impl Into<Number>) -> Result<bool> {
5502        let args = args(vec![Some(Value::Number(port.into()))]);
5503        let reply = self.invoke("open", args)?;
5504        single::<bool>(reply)
5505    }
5506
5507    /// [`Self::open`] without blocking: the call is queued, and
5508    /// the program keeps running until the result comes back; see [`crate::task`].
5509    #[cfg(feature = "async")]
5510    pub async fn open_async(&self, port: impl Into<Number>) -> Result<bool> {
5511        let args = args(vec![Some(Value::Number(port.into()))]);
5512        let reply = self.invoke_async("open", args).await?;
5513        single::<bool>(reply)
5514    }
5515
5516    /// Sends the specified data.
5517    ///
5518    /// Lua: `modem.send(address:string, port:number, data...)`
5519    /// Indirect call: waits for the next server tick.
5520    pub fn send(&self, address: impl AsRef<[u8]>, port: impl Into<Number>, data: &[Value]) -> Result<()> {
5521        let mut args: Vec<Value> = vec![Some(Value::text(address.as_ref())), Some(Value::Number(port.into()))].into_iter().map(Option::unwrap_or_default).collect();
5522        args.extend_from_slice(data);
5523        let reply = self.invoke("send", args)?;
5524        FromReply::from_reply(reply)
5525    }
5526
5527    /// [`Self::send`] without blocking: the call is queued, and
5528    /// the program keeps running until the result comes back; see [`crate::task`].
5529    #[cfg(feature = "async")]
5530    pub async fn send_async(&self, address: impl AsRef<[u8]>, port: impl Into<Number>, data: &[Value]) -> Result<()> {
5531        let mut args: Vec<Value> = vec![Some(Value::text(address.as_ref())), Some(Value::Number(port.into()))].into_iter().map(Option::unwrap_or_default).collect();
5532        args.extend_from_slice(data);
5533        let reply = self.invoke_async("send", args).await?;
5534        FromReply::from_reply(reply)
5535    }
5536
5537    /// Set the signal strength (range) used when sending messages.
5538    ///
5539    /// Lua: `modem.setStrength(strength:number):number`
5540    /// Indirect call: waits for the next server tick.
5541    pub fn set_strength(&self, strength: impl Into<Number>) -> Result<Number> {
5542        let args = args(vec![Some(Value::Number(strength.into()))]);
5543        let reply = self.invoke("setStrength", args)?;
5544        single::<Number>(reply)
5545    }
5546
5547    /// [`Self::set_strength`] without blocking: the call is queued, and
5548    /// the program keeps running until the result comes back; see [`crate::task`].
5549    #[cfg(feature = "async")]
5550    pub async fn set_strength_async(&self, strength: impl Into<Number>) -> Result<Number> {
5551        let args = args(vec![Some(Value::Number(strength.into()))]);
5552        let reply = self.invoke_async("setStrength", args).await?;
5553        single::<Number>(reply)
5554    }
5555
5556    /// Set the wake-up message and whether to ignore additional data/parameters.
5557    ///
5558    /// Lua: `modem.setWakeMessage(message:string[, fuzzy:boolean]):string`
5559    /// Indirect call: waits for the next server tick.
5560    pub fn set_wake_message(&self, message: impl AsRef<[u8]>, fuzzy: Option<bool>) -> Result<OcString> {
5561        let args = args(vec![Some(Value::text(message.as_ref())), fuzzy.map(Value::Bool)]);
5562        let reply = self.invoke("setWakeMessage", args)?;
5563        single::<OcString>(reply)
5564    }
5565
5566    /// [`Self::set_wake_message`] without blocking: the call is queued, and
5567    /// the program keeps running until the result comes back; see [`crate::task`].
5568    #[cfg(feature = "async")]
5569    pub async fn set_wake_message_async(&self, message: impl AsRef<[u8]>, fuzzy: Option<bool>) -> Result<OcString> {
5570        let args = args(vec![Some(Value::text(message.as_ref())), fuzzy.map(Value::Bool)]);
5571        let reply = self.invoke_async("setWakeMessage", args).await?;
5572        single::<OcString>(reply)
5573    }
5574}
5575
5576/// The `motion_sensor` component (2 methods).
5577///
5578/// Provided by OpenComputers' `MotionSensor`.
5579#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5580pub struct MotionSensor(pub Address);
5581
5582impl Component for MotionSensor {
5583    const KIND: &'static str = "motion_sensor";
5584    fn from_address(address: Address) -> Self {
5585        Self(address)
5586    }
5587    fn address(&self) -> &Address {
5588        &self.0
5589    }
5590}
5591
5592impl MotionSensor {
5593    /// Gets the current sensor sensitivity.
5594    ///
5595    /// Lua: `motion_sensor.getSensitivity():number`
5596    /// Direct call (runs immediately, drawing on the per-tick budget).
5597    pub fn get_sensitivity(&self) -> Result<Number> {
5598        let args = args(vec![]);
5599        let reply = self.invoke("getSensitivity", args)?;
5600        single::<Number>(reply)
5601    }
5602
5603    /// [`Self::get_sensitivity`] without blocking: the call is queued, and
5604    /// the program keeps running until the result comes back; see [`crate::task`].
5605    #[cfg(feature = "async")]
5606    pub async fn get_sensitivity_async(&self) -> Result<Number> {
5607        let args = args(vec![]);
5608        let reply = self.invoke_async("getSensitivity", args).await?;
5609        single::<Number>(reply)
5610    }
5611
5612    /// Sets the sensor's sensitivity. Returns the old value.
5613    ///
5614    /// Lua: `motion_sensor.setSensitivity(value:number):number`
5615    /// Direct call (runs immediately, drawing on the per-tick budget).
5616    pub fn set_sensitivity(&self, value: impl Into<Number>) -> Result<Number> {
5617        let args = args(vec![Some(Value::Number(value.into()))]);
5618        let reply = self.invoke("setSensitivity", args)?;
5619        single::<Number>(reply)
5620    }
5621
5622    /// [`Self::set_sensitivity`] without blocking: the call is queued, and
5623    /// the program keeps running until the result comes back; see [`crate::task`].
5624    #[cfg(feature = "async")]
5625    pub async fn set_sensitivity_async(&self, value: impl Into<Number>) -> Result<Number> {
5626        let args = args(vec![Some(Value::Number(value.into()))]);
5627        let reply = self.invoke_async("setSensitivity", args).await?;
5628        single::<Number>(reply)
5629    }
5630}
5631
5632/// The `navigation` component (4 methods).
5633///
5634/// Provided by OpenComputers' `UpgradeNavigation, UpgradeNavigationBase`.
5635#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5636pub struct Navigation(pub Address);
5637
5638impl Component for Navigation {
5639    const KIND: &'static str = "navigation";
5640    fn from_address(address: Address) -> Self {
5641        Self(address)
5642    }
5643    fn address(&self) -> &Address {
5644        &self.0
5645    }
5646}
5647
5648impl Navigation {
5649    /// Find waypoints in the specified range.
5650    ///
5651    /// Lua: `navigation.findWaypoints(range:number):table`
5652    /// Indirect call: waits for the next server tick.
5653    pub fn find_waypoints(&self, range: impl Into<Number>) -> Result<Value> {
5654        let args = args(vec![Some(Value::Number(range.into()))]);
5655        let reply = self.invoke("findWaypoints", args)?;
5656        single::<Value>(reply)
5657    }
5658
5659    /// [`Self::find_waypoints`] without blocking: the call is queued, and
5660    /// the program keeps running until the result comes back; see [`crate::task`].
5661    #[cfg(feature = "async")]
5662    pub async fn find_waypoints_async(&self, range: impl Into<Number>) -> Result<Value> {
5663        let args = args(vec![Some(Value::Number(range.into()))]);
5664        let reply = self.invoke_async("findWaypoints", args).await?;
5665        single::<Value>(reply)
5666    }
5667
5668    /// Get the current orientation of the robot.
5669    ///
5670    /// Lua: `navigation.getFacing():number`
5671    /// Indirect call: waits for the next server tick.
5672    pub fn get_facing(&self) -> Result<Number> {
5673        let args = args(vec![]);
5674        let reply = self.invoke("getFacing", args)?;
5675        single::<Number>(reply)
5676    }
5677
5678    /// [`Self::get_facing`] without blocking: the call is queued, and
5679    /// the program keeps running until the result comes back; see [`crate::task`].
5680    #[cfg(feature = "async")]
5681    pub async fn get_facing_async(&self) -> Result<Number> {
5682        let args = args(vec![]);
5683        let reply = self.invoke_async("getFacing", args).await?;
5684        single::<Number>(reply)
5685    }
5686
5687    /// Get the current relative position of the robot.
5688    ///
5689    /// Lua: `navigation.getPosition():number, number, number`
5690    /// Indirect call: waits for the next server tick.
5691    pub fn get_position(&self) -> Result<(Number, Number, Number)> {
5692        let args = args(vec![]);
5693        let reply = self.invoke("getPosition", args)?;
5694        FromReply::from_reply(reply)
5695    }
5696
5697    /// [`Self::get_position`] without blocking: the call is queued, and
5698    /// the program keeps running until the result comes back; see [`crate::task`].
5699    #[cfg(feature = "async")]
5700    pub async fn get_position_async(&self) -> Result<(Number, Number, Number)> {
5701        let args = args(vec![]);
5702        let reply = self.invoke_async("getPosition", args).await?;
5703        FromReply::from_reply(reply)
5704    }
5705
5706    /// Get the operational range of the navigation upgrade.
5707    ///
5708    /// Lua: `navigation.getRange():number`
5709    /// Indirect call: waits for the next server tick.
5710    pub fn get_range(&self) -> Result<Number> {
5711        let args = args(vec![]);
5712        let reply = self.invoke("getRange", args)?;
5713        single::<Number>(reply)
5714    }
5715
5716    /// [`Self::get_range`] without blocking: the call is queued, and
5717    /// the program keeps running until the result comes back; see [`crate::task`].
5718    #[cfg(feature = "async")]
5719    pub async fn get_range_async(&self) -> Result<Number> {
5720        let args = args(vec![]);
5721        let reply = self.invoke_async("getRange", args).await?;
5722        single::<Number>(reply)
5723    }
5724}
5725
5726/// The `net_splitter` component (4 methods).
5727///
5728/// Provided by OpenComputers' `NetSplitter`.
5729#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5730pub struct NetSplitter(pub Address);
5731
5732impl Component for NetSplitter {
5733    const KIND: &'static str = "net_splitter";
5734    fn from_address(address: Address) -> Self {
5735        Self(address)
5736    }
5737    fn address(&self) -> &Address {
5738        &self.0
5739    }
5740}
5741
5742impl NetSplitter {
5743    /// Close the side, returns true if it changed to close.
5744    ///
5745    /// Lua: `net_splitter.close(side: number):boolean`
5746    /// Indirect call: waits for the next server tick.
5747    pub fn close(&self, side: impl Into<Number>) -> Result<bool> {
5748        let args = args(vec![Some(Value::Number(side.into()))]);
5749        let reply = self.invoke("close", args)?;
5750        single::<bool>(reply)
5751    }
5752
5753    /// [`Self::close`] without blocking: the call is queued, and
5754    /// the program keeps running until the result comes back; see [`crate::task`].
5755    #[cfg(feature = "async")]
5756    pub async fn close_async(&self, side: impl Into<Number>) -> Result<bool> {
5757        let args = args(vec![Some(Value::Number(side.into()))]);
5758        let reply = self.invoke_async("close", args).await?;
5759        single::<bool>(reply)
5760    }
5761
5762    /// Returns current open/close state of all sides in an array, indexed by direction.
5763    ///
5764    /// Lua: `net_splitter.getSides():table`
5765    /// Direct call (runs immediately, drawing on the per-tick budget).
5766    pub fn get_sides(&self) -> Result<Value> {
5767        let args = args(vec![]);
5768        let reply = self.invoke("getSides", args)?;
5769        single::<Value>(reply)
5770    }
5771
5772    /// [`Self::get_sides`] without blocking: the call is queued, and
5773    /// the program keeps running until the result comes back; see [`crate::task`].
5774    #[cfg(feature = "async")]
5775    pub async fn get_sides_async(&self) -> Result<Value> {
5776        let args = args(vec![]);
5777        let reply = self.invoke_async("getSides", args).await?;
5778        single::<Value>(reply)
5779    }
5780
5781    /// Open the side, returns true if it changed to open.
5782    ///
5783    /// Lua: `net_splitter.open(side: number):boolean`
5784    /// Indirect call: waits for the next server tick.
5785    pub fn open(&self, side: impl Into<Number>) -> Result<bool> {
5786        let args = args(vec![Some(Value::Number(side.into()))]);
5787        let reply = self.invoke("open", args)?;
5788        single::<bool>(reply)
5789    }
5790
5791    /// [`Self::open`] without blocking: the call is queued, and
5792    /// the program keeps running until the result comes back; see [`crate::task`].
5793    #[cfg(feature = "async")]
5794    pub async fn open_async(&self, side: impl Into<Number>) -> Result<bool> {
5795        let args = args(vec![Some(Value::Number(side.into()))]);
5796        let reply = self.invoke_async("open", args).await?;
5797        single::<bool>(reply)
5798    }
5799
5800    /// set open state (true/false) of all sides in an array; index by direction. Returns previous states
5801    ///
5802    /// Lua: `net_splitter.setSides(settings:table):table`
5803    /// Indirect call: waits for the next server tick.
5804    pub fn set_sides(&self, settings: impl Into<Value>) -> Result<Value> {
5805        let args = args(vec![Some(settings.into())]);
5806        let reply = self.invoke("setSides", args)?;
5807        single::<Value>(reply)
5808    }
5809
5810    /// [`Self::set_sides`] without blocking: the call is queued, and
5811    /// the program keeps running until the result comes back; see [`crate::task`].
5812    #[cfg(feature = "async")]
5813    pub async fn set_sides_async(&self, settings: impl Into<Value>) -> Result<Value> {
5814        let args = args(vec![Some(settings.into())]);
5815        let reply = self.invoke_async("setSides", args).await?;
5816        single::<Value>(reply)
5817    }
5818}
5819
5820/// The `note_block` component (3 methods).
5821///
5822/// Provided by OpenComputers' `DriverNoteBlock$Environment`.
5823#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5824pub struct NoteBlock(pub Address);
5825
5826impl Component for NoteBlock {
5827    const KIND: &'static str = "note_block";
5828    fn from_address(address: Address) -> Self {
5829        Self(address)
5830    }
5831    fn address(&self) -> &Address {
5832        &self.0
5833    }
5834}
5835
5836impl NoteBlock {
5837    /// Get the currently set pitch on this note block.
5838    ///
5839    /// Lua: `note_block.getPitch():number`
5840    /// Direct call (runs immediately, drawing on the per-tick budget).
5841    pub fn get_pitch(&self) -> Result<Number> {
5842        let args = args(vec![]);
5843        let reply = self.invoke("getPitch", args)?;
5844        single::<Number>(reply)
5845    }
5846
5847    /// [`Self::get_pitch`] without blocking: the call is queued, and
5848    /// the program keeps running until the result comes back; see [`crate::task`].
5849    #[cfg(feature = "async")]
5850    pub async fn get_pitch_async(&self) -> Result<Number> {
5851        let args = args(vec![]);
5852        let reply = self.invoke_async("getPitch", args).await?;
5853        single::<Number>(reply)
5854    }
5855
5856    /// Set the pitch for this note block. Must be in the interval \[1, 25\].
5857    ///
5858    /// Lua: `note_block.setPitch(value:number)`
5859    /// Indirect call: waits for the next server tick.
5860    pub fn set_pitch(&self, value: impl Into<Number>) -> Result<()> {
5861        let args = args(vec![Some(Value::Number(value.into()))]);
5862        let reply = self.invoke("setPitch", args)?;
5863        FromReply::from_reply(reply)
5864    }
5865
5866    /// [`Self::set_pitch`] without blocking: the call is queued, and
5867    /// the program keeps running until the result comes back; see [`crate::task`].
5868    #[cfg(feature = "async")]
5869    pub async fn set_pitch_async(&self, value: impl Into<Number>) -> Result<()> {
5870        let args = args(vec![Some(Value::Number(value.into()))]);
5871        let reply = self.invoke_async("setPitch", args).await?;
5872        FromReply::from_reply(reply)
5873    }
5874
5875    /// Triggers the note block if possible. Allows setting the pitch to save a tick.
5876    ///
5877    /// Lua: `note_block.trigger([pitch:number]):boolean`
5878    /// Indirect call: waits for the next server tick.
5879    pub fn trigger(&self, pitch: Option<Number>) -> Result<bool> {
5880        let args = args(vec![pitch.map(Value::Number)]);
5881        let reply = self.invoke("trigger", args)?;
5882        single::<bool>(reply)
5883    }
5884
5885    /// [`Self::trigger`] without blocking: the call is queued, and
5886    /// the program keeps running until the result comes back; see [`crate::task`].
5887    #[cfg(feature = "async")]
5888    pub async fn trigger_async(&self, pitch: Option<Number>) -> Result<bool> {
5889        let args = args(vec![pitch.map(Value::Number)]);
5890        let reply = self.invoke_async("trigger", args).await?;
5891        single::<bool>(reply)
5892    }
5893}
5894
5895/// The `piston` component (3 methods).
5896///
5897/// Provided by OpenComputers' `UpgradePiston, UpgradePiston$Drone, UpgradePiston$Rotatable, UpgradePiston$Tablet, UpgradeStickyPiston, UpgradeStickyPiston$Drone, UpgradeStickyPiston$Rotatable, UpgradeStickyPiston$Tablet`.
5898#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5899pub struct Piston(pub Address);
5900
5901impl Component for Piston {
5902    const KIND: &'static str = "piston";
5903    fn from_address(address: Address) -> Self {
5904        Self(address)
5905    }
5906    fn address(&self) -> &Address {
5907        &self.0
5908    }
5909}
5910
5911impl Piston {
5912    /// Returns true if the piston is sticky, i.e. it can also pull.
5913    ///
5914    /// Lua: `piston.isSticky():boolean`
5915    /// Indirect call: waits for the next server tick.
5916    pub fn is_sticky(&self) -> Result<bool> {
5917        let args = args(vec![]);
5918        let reply = self.invoke("isSticky", args)?;
5919        single::<bool>(reply)
5920    }
5921
5922    /// [`Self::is_sticky`] without blocking: the call is queued, and
5923    /// the program keeps running until the result comes back; see [`crate::task`].
5924    #[cfg(feature = "async")]
5925    pub async fn is_sticky_async(&self) -> Result<bool> {
5926        let args = args(vec![]);
5927        let reply = self.invoke_async("isSticky", args).await?;
5928        single::<bool>(reply)
5929    }
5930
5931    /// Tries to reach out to the side given (default front) and pull a block similar to a vanilla sticky piston.
5932    ///
5933    /// Lua: `piston.pull([side:number]):boolean`
5934    /// Indirect call: waits for the next server tick.
5935    pub fn pull(&self, side: Option<Number>) -> Result<bool> {
5936        let args = args(vec![side.map(Value::Number)]);
5937        let reply = self.invoke("pull", args)?;
5938        single::<bool>(reply)
5939    }
5940
5941    /// [`Self::pull`] without blocking: the call is queued, and
5942    /// the program keeps running until the result comes back; see [`crate::task`].
5943    #[cfg(feature = "async")]
5944    pub async fn pull_async(&self, side: Option<Number>) -> Result<bool> {
5945        let args = args(vec![side.map(Value::Number)]);
5946        let reply = self.invoke_async("pull", args).await?;
5947        single::<bool>(reply)
5948    }
5949
5950    /// Tries to push the block on the specified side of the container of the upgrade. Defaults to front.
5951    ///
5952    /// Lua: `piston.push([side:number]):boolean`
5953    /// Indirect call: waits for the next server tick.
5954    pub fn push(&self, side: Option<Number>) -> Result<bool> {
5955        let args = args(vec![side.map(Value::Number)]);
5956        let reply = self.invoke("push", args)?;
5957        single::<bool>(reply)
5958    }
5959
5960    /// [`Self::push`] without blocking: the call is queued, and
5961    /// the program keeps running until the result comes back; see [`crate::task`].
5962    #[cfg(feature = "async")]
5963    pub async fn push_async(&self, side: Option<Number>) -> Result<bool> {
5964        let args = args(vec![side.map(Value::Number)]);
5965        let reply = self.invoke_async("push", args).await?;
5966        single::<bool>(reply)
5967    }
5968}
5969
5970/// The `printer3d` component (18 methods).
5971///
5972/// Provided by OpenComputers' `Printer`.
5973#[derive(Clone, Debug, PartialEq, Eq, Hash)]
5974pub struct Printer3d(pub Address);
5975
5976impl Component for Printer3d {
5977    const KIND: &'static str = "printer3d";
5978    fn from_address(address: Address) -> Self {
5979        Self(address)
5980    }
5981    fn address(&self) -> &Address {
5982        &self.0
5983    }
5984}
5985
5986impl Printer3d {
5987    /// Adds a shape to the printers configuration, optionally specifying whether it is for the off or on state.
5988    ///
5989    /// Lua: `printer3d.addShape(minX:number, minY:number, minZ:number, maxX:number, maxY:number, maxZ:number, texture:string[, state:boolean=false][,tint:number])`
5990    /// Indirect call: waits for the next server tick.
5991    /// `state` defaults to `false`.
5992    pub fn add_shape(&self, min_x: impl Into<Number>, min_y: impl Into<Number>, min_z: impl Into<Number>, max_x: impl Into<Number>, max_y: impl Into<Number>, max_z: impl Into<Number>, texture: impl AsRef<[u8]>, state: Option<bool>, tint: Option<Number>) -> Result<()> {
5993        let args = args(vec![Some(Value::Number(min_x.into())), Some(Value::Number(min_y.into())), Some(Value::Number(min_z.into())), Some(Value::Number(max_x.into())), Some(Value::Number(max_y.into())), Some(Value::Number(max_z.into())), Some(Value::text(texture.as_ref())), state.map(Value::Bool), tint.map(Value::Number)]);
5994        let reply = self.invoke("addShape", args)?;
5995        FromReply::from_reply(reply)
5996    }
5997
5998    /// [`Self::add_shape`] without blocking: the call is queued, and
5999    /// the program keeps running until the result comes back; see [`crate::task`].
6000    #[cfg(feature = "async")]
6001    pub async fn add_shape_async(&self, min_x: impl Into<Number>, min_y: impl Into<Number>, min_z: impl Into<Number>, max_x: impl Into<Number>, max_y: impl Into<Number>, max_z: impl Into<Number>, texture: impl AsRef<[u8]>, state: Option<bool>, tint: Option<Number>) -> Result<()> {
6002        let args = args(vec![Some(Value::Number(min_x.into())), Some(Value::Number(min_y.into())), Some(Value::Number(min_z.into())), Some(Value::Number(max_x.into())), Some(Value::Number(max_y.into())), Some(Value::Number(max_z.into())), Some(Value::text(texture.as_ref())), state.map(Value::Bool), tint.map(Value::Number)]);
6003        let reply = self.invoke_async("addShape", args).await?;
6004        FromReply::from_reply(reply)
6005    }
6006
6007    /// Commit and begin printing the current configuration.
6008    ///
6009    /// Lua: `printer3d.commit([count:number]):boolean`
6010    /// Indirect call: waits for the next server tick.
6011    pub fn commit(&self, count: Option<Number>) -> Result<bool> {
6012        let args = args(vec![count.map(Value::Number)]);
6013        let reply = self.invoke("commit", args)?;
6014        single::<bool>(reply)
6015    }
6016
6017    /// [`Self::commit`] without blocking: the call is queued, and
6018    /// the program keeps running until the result comes back; see [`crate::task`].
6019    #[cfg(feature = "async")]
6020    pub async fn commit_async(&self, count: Option<Number>) -> Result<bool> {
6021        let args = args(vec![count.map(Value::Number)]);
6022        let reply = self.invoke_async("commit", args).await?;
6023        single::<bool>(reply)
6024    }
6025
6026    /// Get the current label for the block being printed.
6027    ///
6028    /// Lua: `printer3d.getLabel():string`
6029    /// Indirect call: waits for the next server tick.
6030    pub fn get_label(&self) -> Result<OcString> {
6031        let args = args(vec![]);
6032        let reply = self.invoke("getLabel", args)?;
6033        single::<OcString>(reply)
6034    }
6035
6036    /// [`Self::get_label`] without blocking: the call is queued, and
6037    /// the program keeps running until the result comes back; see [`crate::task`].
6038    #[cfg(feature = "async")]
6039    pub async fn get_label_async(&self) -> Result<OcString> {
6040        let args = args(vec![]);
6041        let reply = self.invoke_async("getLabel", args).await?;
6042        single::<OcString>(reply)
6043    }
6044
6045    /// Get which light level the printed block should have.
6046    ///
6047    /// Lua: `printer3d.getLightLevel():number`
6048    /// Indirect call: waits for the next server tick.
6049    pub fn get_light_level(&self) -> Result<Number> {
6050        let args = args(vec![]);
6051        let reply = self.invoke("getLightLevel", args)?;
6052        single::<Number>(reply)
6053    }
6054
6055    /// [`Self::get_light_level`] without blocking: the call is queued, and
6056    /// the program keeps running until the result comes back; see [`crate::task`].
6057    #[cfg(feature = "async")]
6058    pub async fn get_light_level_async(&self) -> Result<Number> {
6059        let args = args(vec![]);
6060        let reply = self.invoke_async("getLightLevel", args).await?;
6061        single::<Number>(reply)
6062    }
6063
6064    /// Get the maximum allowed number of shapes.
6065    ///
6066    /// Lua: `printer3d.getMaxShapeCount():number`
6067    /// Indirect call: waits for the next server tick.
6068    pub fn get_max_shape_count(&self) -> Result<Number> {
6069        let args = args(vec![]);
6070        let reply = self.invoke("getMaxShapeCount", args)?;
6071        single::<Number>(reply)
6072    }
6073
6074    /// [`Self::get_max_shape_count`] without blocking: the call is queued, and
6075    /// the program keeps running until the result comes back; see [`crate::task`].
6076    #[cfg(feature = "async")]
6077    pub async fn get_max_shape_count_async(&self) -> Result<Number> {
6078        let args = args(vec![]);
6079        let reply = self.invoke_async("getMaxShapeCount", args).await?;
6080        single::<Number>(reply)
6081    }
6082
6083    /// Get the number of shapes in the current configuration.
6084    ///
6085    /// Lua: `printer3d.getShapeCount():number`
6086    /// Indirect call: waits for the next server tick.
6087    pub fn get_shape_count(&self) -> Result<Number> {
6088        let args = args(vec![]);
6089        let reply = self.invoke("getShapeCount", args)?;
6090        single::<Number>(reply)
6091    }
6092
6093    /// [`Self::get_shape_count`] without blocking: the call is queued, and
6094    /// the program keeps running until the result comes back; see [`crate::task`].
6095    #[cfg(feature = "async")]
6096    pub async fn get_shape_count_async(&self) -> Result<Number> {
6097        let args = args(vec![]);
6098        let reply = self.invoke_async("getShapeCount", args).await?;
6099        single::<Number>(reply)
6100    }
6101
6102    /// Get the current tooltip for the block being printed.
6103    ///
6104    /// Lua: `printer3d.getTooltip():string`
6105    /// Indirect call: waits for the next server tick.
6106    pub fn get_tooltip(&self) -> Result<OcString> {
6107        let args = args(vec![]);
6108        let reply = self.invoke("getTooltip", args)?;
6109        single::<OcString>(reply)
6110    }
6111
6112    /// [`Self::get_tooltip`] without blocking: the call is queued, and
6113    /// the program keeps running until the result comes back; see [`crate::task`].
6114    #[cfg(feature = "async")]
6115    pub async fn get_tooltip_async(&self) -> Result<OcString> {
6116        let args = args(vec![]);
6117        let reply = self.invoke_async("getTooltip", args).await?;
6118        single::<OcString>(reply)
6119    }
6120
6121    /// Get whether the printed block should automatically return to its off state.
6122    ///
6123    /// Lua: `printer3d.isButtonMode():boolean`
6124    /// Indirect call: waits for the next server tick.
6125    pub fn is_button_mode(&self) -> Result<bool> {
6126        let args = args(vec![]);
6127        let reply = self.invoke("isButtonMode", args)?;
6128        single::<bool>(reply)
6129    }
6130
6131    /// [`Self::is_button_mode`] without blocking: the call is queued, and
6132    /// the program keeps running until the result comes back; see [`crate::task`].
6133    #[cfg(feature = "async")]
6134    pub async fn is_button_mode_async(&self) -> Result<bool> {
6135        let args = args(vec![]);
6136        let reply = self.invoke_async("isButtonMode", args).await?;
6137        single::<bool>(reply)
6138    }
6139
6140    /// Get whether the printed block should be collidable or not.
6141    ///
6142    /// Lua: `printer3d.isCollidable():boolean, boolean`
6143    /// Indirect call: waits for the next server tick.
6144    pub fn is_collidable(&self) -> Result<(bool, bool)> {
6145        let args = args(vec![]);
6146        let reply = self.invoke("isCollidable", args)?;
6147        FromReply::from_reply(reply)
6148    }
6149
6150    /// [`Self::is_collidable`] without blocking: the call is queued, and
6151    /// the program keeps running until the result comes back; see [`crate::task`].
6152    #[cfg(feature = "async")]
6153    pub async fn is_collidable_async(&self) -> Result<(bool, bool)> {
6154        let args = args(vec![]);
6155        let reply = self.invoke_async("isCollidable", args).await?;
6156        FromReply::from_reply(reply)
6157    }
6158
6159    /// Get whether the printed block should emit redstone when in its active state.
6160    ///
6161    /// Lua: `printer3d.isRedstoneEmitter():boolean, number`
6162    /// Indirect call: waits for the next server tick.
6163    pub fn is_redstone_emitter(&self) -> Result<(bool, Number)> {
6164        let args = args(vec![]);
6165        let reply = self.invoke("isRedstoneEmitter", args)?;
6166        FromReply::from_reply(reply)
6167    }
6168
6169    /// [`Self::is_redstone_emitter`] without blocking: the call is queued, and
6170    /// the program keeps running until the result comes back; see [`crate::task`].
6171    #[cfg(feature = "async")]
6172    pub async fn is_redstone_emitter_async(&self) -> Result<(bool, Number)> {
6173        let args = args(vec![]);
6174        let reply = self.invoke_async("isRedstoneEmitter", args).await?;
6175        FromReply::from_reply(reply)
6176    }
6177
6178    /// Resets the configuration of the printer and stop printing (current job will finish).
6179    ///
6180    /// Lua: `printer3d.reset()`
6181    /// Indirect call: waits for the next server tick.
6182    pub fn reset(&self) -> Result<()> {
6183        let args = args(vec![]);
6184        let reply = self.invoke("reset", args)?;
6185        FromReply::from_reply(reply)
6186    }
6187
6188    /// [`Self::reset`] without blocking: the call is queued, and
6189    /// the program keeps running until the result comes back; see [`crate::task`].
6190    #[cfg(feature = "async")]
6191    pub async fn reset_async(&self) -> Result<()> {
6192        let args = args(vec![]);
6193        let reply = self.invoke_async("reset", args).await?;
6194        FromReply::from_reply(reply)
6195    }
6196
6197    /// Set whether the printed block should automatically return to its off state.
6198    ///
6199    /// Lua: `printer3d.setButtonMode(value:boolean)`
6200    /// Indirect call: waits for the next server tick.
6201    pub fn set_button_mode(&self, value: bool) -> Result<()> {
6202        let args = args(vec![Some(Value::Bool(value))]);
6203        let reply = self.invoke("setButtonMode", args)?;
6204        FromReply::from_reply(reply)
6205    }
6206
6207    /// [`Self::set_button_mode`] without blocking: the call is queued, and
6208    /// the program keeps running until the result comes back; see [`crate::task`].
6209    #[cfg(feature = "async")]
6210    pub async fn set_button_mode_async(&self, value: bool) -> Result<()> {
6211        let args = args(vec![Some(Value::Bool(value))]);
6212        let reply = self.invoke_async("setButtonMode", args).await?;
6213        FromReply::from_reply(reply)
6214    }
6215
6216    /// Set whether the printed block should be collidable or not.
6217    ///
6218    /// Lua: `printer3d.setCollidable(collideOff:boolean, collideOn:boolean)`
6219    /// Indirect call: waits for the next server tick.
6220    pub fn set_collidable(&self, collide_off: bool, collide_on: bool) -> Result<()> {
6221        let args = args(vec![Some(Value::Bool(collide_off)), Some(Value::Bool(collide_on))]);
6222        let reply = self.invoke("setCollidable", args)?;
6223        FromReply::from_reply(reply)
6224    }
6225
6226    /// [`Self::set_collidable`] without blocking: the call is queued, and
6227    /// the program keeps running until the result comes back; see [`crate::task`].
6228    #[cfg(feature = "async")]
6229    pub async fn set_collidable_async(&self, collide_off: bool, collide_on: bool) -> Result<()> {
6230        let args = args(vec![Some(Value::Bool(collide_off)), Some(Value::Bool(collide_on))]);
6231        let reply = self.invoke_async("setCollidable", args).await?;
6232        FromReply::from_reply(reply)
6233    }
6234
6235    /// Set a label for the block being printed.
6236    ///
6237    /// Lua: `printer3d.setLabel(value:string)`
6238    /// Indirect call: waits for the next server tick.
6239    pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<()> {
6240        let args = args(vec![Some(Value::text(value.as_ref()))]);
6241        let reply = self.invoke("setLabel", args)?;
6242        FromReply::from_reply(reply)
6243    }
6244
6245    /// [`Self::set_label`] without blocking: the call is queued, and
6246    /// the program keeps running until the result comes back; see [`crate::task`].
6247    #[cfg(feature = "async")]
6248    pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<()> {
6249        let args = args(vec![Some(Value::text(value.as_ref()))]);
6250        let reply = self.invoke_async("setLabel", args).await?;
6251        FromReply::from_reply(reply)
6252    }
6253
6254    /// Set what light level the printed block should have.
6255    ///
6256    /// Lua: `printer3d.setLightLevel(value:number)`
6257    /// Indirect call: waits for the next server tick.
6258    pub fn set_light_level(&self, value: impl Into<Number>) -> Result<()> {
6259        let args = args(vec![Some(Value::Number(value.into()))]);
6260        let reply = self.invoke("setLightLevel", args)?;
6261        FromReply::from_reply(reply)
6262    }
6263
6264    /// [`Self::set_light_level`] without blocking: the call is queued, and
6265    /// the program keeps running until the result comes back; see [`crate::task`].
6266    #[cfg(feature = "async")]
6267    pub async fn set_light_level_async(&self, value: impl Into<Number>) -> Result<()> {
6268        let args = args(vec![Some(Value::Number(value.into()))]);
6269        let reply = self.invoke_async("setLightLevel", args).await?;
6270        FromReply::from_reply(reply)
6271    }
6272
6273    /// Set whether the printed block should emit redstone when in its active state.
6274    ///
6275    /// Lua: `printer3d.setRedstoneEmitter(value:boolean or number)`
6276    /// Indirect call: waits for the next server tick.
6277    pub fn set_redstone_emitter(&self, value: impl Into<Value>) -> Result<()> {
6278        let args = args(vec![Some(value.into())]);
6279        let reply = self.invoke("setRedstoneEmitter", args)?;
6280        FromReply::from_reply(reply)
6281    }
6282
6283    /// [`Self::set_redstone_emitter`] without blocking: the call is queued, and
6284    /// the program keeps running until the result comes back; see [`crate::task`].
6285    #[cfg(feature = "async")]
6286    pub async fn set_redstone_emitter_async(&self, value: impl Into<Value>) -> Result<()> {
6287        let args = args(vec![Some(value.into())]);
6288        let reply = self.invoke_async("setRedstoneEmitter", args).await?;
6289        FromReply::from_reply(reply)
6290    }
6291
6292    /// Set a tooltip for the block being printed.
6293    ///
6294    /// Lua: `printer3d.setTooltip(value:string)`
6295    /// Indirect call: waits for the next server tick.
6296    pub fn set_tooltip(&self, value: impl AsRef<[u8]>) -> Result<()> {
6297        let args = args(vec![Some(Value::text(value.as_ref()))]);
6298        let reply = self.invoke("setTooltip", args)?;
6299        FromReply::from_reply(reply)
6300    }
6301
6302    /// [`Self::set_tooltip`] without blocking: the call is queued, and
6303    /// the program keeps running until the result comes back; see [`crate::task`].
6304    #[cfg(feature = "async")]
6305    pub async fn set_tooltip_async(&self, value: impl AsRef<[u8]>) -> Result<()> {
6306        let args = args(vec![Some(Value::text(value.as_ref()))]);
6307        let reply = self.invoke_async("setTooltip", args).await?;
6308        FromReply::from_reply(reply)
6309    }
6310
6311    /// The current state of the printer, `busy' or `idle', followed by the progress or model validity, respectively.
6312    ///
6313    /// Lua: `printer3d.status(): string, number or boolean`
6314    /// Indirect call: waits for the next server tick.
6315    pub fn status(&self) -> Result<(OcString, Value)> {
6316        let args = args(vec![]);
6317        let reply = self.invoke("status", args)?;
6318        FromReply::from_reply(reply)
6319    }
6320
6321    /// [`Self::status`] without blocking: the call is queued, and
6322    /// the program keeps running until the result comes back; see [`crate::task`].
6323    #[cfg(feature = "async")]
6324    pub async fn status_async(&self) -> Result<(OcString, Value)> {
6325        let args = args(vec![]);
6326        let reply = self.invoke_async("status", args).await?;
6327        FromReply::from_reply(reply)
6328    }
6329}
6330
6331/// The `redstone` component (16 methods).
6332///
6333/// Provided by OpenComputers' `Redstone$Bundled, Redstone$BundledWireless, Redstone$Vanilla, Redstone$VanillaWireless, Redstone$Wireless, RedstoneSignaller, RedstoneVanilla`.
6334#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6335pub struct Redstone(pub Address);
6336
6337impl Component for Redstone {
6338    const KIND: &'static str = "redstone";
6339    fn from_address(address: Address) -> Self {
6340        Self(address)
6341    }
6342    fn address(&self) -> &Address {
6343        &self.0
6344    }
6345}
6346
6347impl Redstone {
6348    /// Fewer params returns set of inputs
6349    ///
6350    /// Lua: `redstone.getBundledInput([side:number[, color:number]]):number or table`
6351    /// Direct call (runs immediately, drawing on the per-tick budget).
6352    pub fn get_bundled_input(&self, side: Option<Number>, color: Option<Number>) -> Result<Value> {
6353        let args = args(vec![side.map(Value::Number), color.map(Value::Number)]);
6354        let reply = self.invoke("getBundledInput", args)?;
6355        single::<Value>(reply)
6356    }
6357
6358    /// [`Self::get_bundled_input`] without blocking: the call is queued, and
6359    /// the program keeps running until the result comes back; see [`crate::task`].
6360    #[cfg(feature = "async")]
6361    pub async fn get_bundled_input_async(&self, side: Option<Number>, color: Option<Number>) -> Result<Value> {
6362        let args = args(vec![side.map(Value::Number), color.map(Value::Number)]);
6363        let reply = self.invoke_async("getBundledInput", args).await?;
6364        single::<Value>(reply)
6365    }
6366
6367    /// Fewer params returns set of outputs
6368    ///
6369    /// Lua: `redstone.getBundledOutput([side:number[, color:number]]):number or table`
6370    /// Direct call (runs immediately, drawing on the per-tick budget).
6371    pub fn get_bundled_output(&self, side: Option<Number>, color: Option<Number>) -> Result<Value> {
6372        let args = args(vec![side.map(Value::Number), color.map(Value::Number)]);
6373        let reply = self.invoke("getBundledOutput", args)?;
6374        single::<Value>(reply)
6375    }
6376
6377    /// [`Self::get_bundled_output`] without blocking: the call is queued, and
6378    /// the program keeps running until the result comes back; see [`crate::task`].
6379    #[cfg(feature = "async")]
6380    pub async fn get_bundled_output_async(&self, side: Option<Number>, color: Option<Number>) -> Result<Value> {
6381        let args = args(vec![side.map(Value::Number), color.map(Value::Number)]);
6382        let reply = self.invoke_async("getBundledOutput", args).await?;
6383        single::<Value>(reply)
6384    }
6385
6386    /// Get the comparator input on the specified side.
6387    ///
6388    /// Lua: `redstone.getComparatorInput(side:number):number`
6389    /// Direct call (runs immediately, drawing on the per-tick budget).
6390    pub fn get_comparator_input(&self, side: impl Into<Number>) -> Result<Number> {
6391        let args = args(vec![Some(Value::Number(side.into()))]);
6392        let reply = self.invoke("getComparatorInput", args)?;
6393        single::<Number>(reply)
6394    }
6395
6396    /// [`Self::get_comparator_input`] without blocking: the call is queued, and
6397    /// the program keeps running until the result comes back; see [`crate::task`].
6398    #[cfg(feature = "async")]
6399    pub async fn get_comparator_input_async(&self, side: impl Into<Number>) -> Result<Number> {
6400        let args = args(vec![Some(Value::Number(side.into()))]);
6401        let reply = self.invoke_async("getComparatorInput", args).await?;
6402        single::<Number>(reply)
6403    }
6404
6405    /// Get the redstone input (all sides, or optionally on the specified side)
6406    ///
6407    /// Lua: `redstone.getInput([side:number]):number or table`
6408    /// Direct call (runs immediately, drawing on the per-tick budget).
6409    pub fn get_input(&self, side: Option<Number>) -> Result<Value> {
6410        let args = args(vec![side.map(Value::Number)]);
6411        let reply = self.invoke("getInput", args)?;
6412        single::<Value>(reply)
6413    }
6414
6415    /// [`Self::get_input`] without blocking: the call is queued, and
6416    /// the program keeps running until the result comes back; see [`crate::task`].
6417    #[cfg(feature = "async")]
6418    pub async fn get_input_async(&self, side: Option<Number>) -> Result<Value> {
6419        let args = args(vec![side.map(Value::Number)]);
6420        let reply = self.invoke_async("getInput", args).await?;
6421        single::<Value>(reply)
6422    }
6423
6424    /// Get the redstone output (all sides, or optionally on the specified side)
6425    ///
6426    /// Lua: `redstone.getOutput([side:number]):number or table`
6427    /// Direct call (runs immediately, drawing on the per-tick budget).
6428    pub fn get_output(&self, side: Option<Number>) -> Result<Value> {
6429        let args = args(vec![side.map(Value::Number)]);
6430        let reply = self.invoke("getOutput", args)?;
6431        single::<Value>(reply)
6432    }
6433
6434    /// [`Self::get_output`] without blocking: the call is queued, and
6435    /// the program keeps running until the result comes back; see [`crate::task`].
6436    #[cfg(feature = "async")]
6437    pub async fn get_output_async(&self, side: Option<Number>) -> Result<Value> {
6438        let args = args(vec![side.map(Value::Number)]);
6439        let reply = self.invoke_async("getOutput", args).await?;
6440        single::<Value>(reply)
6441    }
6442
6443    /// Get the current wake-up threshold.
6444    ///
6445    /// Lua: `redstone.getWakeThreshold():number`
6446    /// Direct call (runs immediately, drawing on the per-tick budget).
6447    pub fn get_wake_threshold(&self) -> Result<Number> {
6448        let args = args(vec![]);
6449        let reply = self.invoke("getWakeThreshold", args)?;
6450        single::<Number>(reply)
6451    }
6452
6453    /// [`Self::get_wake_threshold`] without blocking: the call is queued, and
6454    /// the program keeps running until the result comes back; see [`crate::task`].
6455    #[cfg(feature = "async")]
6456    pub async fn get_wake_threshold_async(&self) -> Result<Number> {
6457        let args = args(vec![]);
6458        let reply = self.invoke_async("getWakeThreshold", args).await?;
6459        single::<Number>(reply)
6460    }
6461
6462    /// Get the currently set wireless redstone frequency.
6463    ///
6464    /// Lua: `redstone.getWirelessFrequency():number`
6465    /// Direct call (runs immediately, drawing on the per-tick budget).
6466    pub fn get_wireless_frequency(&self) -> Result<Number> {
6467        let args = args(vec![]);
6468        let reply = self.invoke("getWirelessFrequency", args)?;
6469        single::<Number>(reply)
6470    }
6471
6472    /// [`Self::get_wireless_frequency`] without blocking: the call is queued, and
6473    /// the program keeps running until the result comes back; see [`crate::task`].
6474    #[cfg(feature = "async")]
6475    pub async fn get_wireless_frequency_async(&self) -> Result<Number> {
6476        let args = args(vec![]);
6477        let reply = self.invoke_async("getWirelessFrequency", args).await?;
6478        single::<Number>(reply)
6479    }
6480
6481    /// Get the wireless redstone input.
6482    ///
6483    /// Lua: `redstone.getWirelessInput():number`
6484    /// Indirect call: waits for the next server tick.
6485    pub fn get_wireless_input(&self) -> Result<Number> {
6486        let args = args(vec![]);
6487        let reply = self.invoke("getWirelessInput", args)?;
6488        single::<Number>(reply)
6489    }
6490
6491    /// [`Self::get_wireless_input`] without blocking: the call is queued, and
6492    /// the program keeps running until the result comes back; see [`crate::task`].
6493    #[cfg(feature = "async")]
6494    pub async fn get_wireless_input_async(&self) -> Result<Number> {
6495        let args = args(vec![]);
6496        let reply = self.invoke_async("getWirelessInput", args).await?;
6497        single::<Number>(reply)
6498    }
6499
6500    /// Get the wireless redstone output.
6501    ///
6502    /// Lua: `redstone.getWirelessOutput():boolean`
6503    /// Direct call (runs immediately, drawing on the per-tick budget).
6504    pub fn get_wireless_output(&self) -> Result<bool> {
6505        let args = args(vec![]);
6506        let reply = self.invoke("getWirelessOutput", args)?;
6507        single::<bool>(reply)
6508    }
6509
6510    /// [`Self::get_wireless_output`] without blocking: the call is queued, and
6511    /// the program keeps running until the result comes back; see [`crate::task`].
6512    #[cfg(feature = "async")]
6513    pub async fn get_wireless_output_async(&self) -> Result<bool> {
6514        let args = args(vec![]);
6515        let reply = self.invoke_async("getWirelessOutput", args).await?;
6516        single::<bool>(reply)
6517    }
6518
6519    /// Get the list of enabled wireless providers.
6520    ///
6521    /// Lua: `redstone.getWirelessProviders():table`
6522    /// Direct call (runs immediately, drawing on the per-tick budget).
6523    pub fn get_wireless_providers(&self) -> Result<Value> {
6524        let args = args(vec![]);
6525        let reply = self.invoke("getWirelessProviders", args)?;
6526        single::<Value>(reply)
6527    }
6528
6529    /// [`Self::get_wireless_providers`] without blocking: the call is queued, and
6530    /// the program keeps running until the result comes back; see [`crate::task`].
6531    #[cfg(feature = "async")]
6532    pub async fn get_wireless_providers_async(&self) -> Result<Value> {
6533        let args = args(vec![]);
6534        let reply = self.invoke_async("getWirelessProviders", args).await?;
6535        single::<Value>(reply)
6536    }
6537
6538    /// Fewer params to assign set of outputs. Returns previous values
6539    ///
6540    /// Lua: `redstone.setBundledOutput([side:number[, color:number,]] value:number or table):number or table`
6541    /// Indirect call: waits for the next server tick.
6542    pub fn set_bundled_output(&self, side: Option<Number>, color: Option<Number>, value: Option<Value>) -> Result<Value> {
6543        let args = args(vec![side.map(Value::Number), color.map(Value::Number), value]);
6544        let reply = self.invoke("setBundledOutput", args)?;
6545        single::<Value>(reply)
6546    }
6547
6548    /// [`Self::set_bundled_output`] without blocking: the call is queued, and
6549    /// the program keeps running until the result comes back; see [`crate::task`].
6550    #[cfg(feature = "async")]
6551    pub async fn set_bundled_output_async(&self, side: Option<Number>, color: Option<Number>, value: Option<Value>) -> Result<Value> {
6552        let args = args(vec![side.map(Value::Number), color.map(Value::Number), value]);
6553        let reply = self.invoke_async("setBundledOutput", args).await?;
6554        single::<Value>(reply)
6555    }
6556
6557    /// Set the redstone output (all sides, or optionally on the specified side). Returns previous values
6558    ///
6559    /// Lua: `redstone.setOutput([side:number, ]value:number or table):number or table`
6560    /// Indirect call: waits for the next server tick.
6561    pub fn set_output(&self, side: Option<Number>, value: Option<Value>) -> Result<Value> {
6562        let args = args(vec![side.map(Value::Number), value]);
6563        let reply = self.invoke("setOutput", args)?;
6564        single::<Value>(reply)
6565    }
6566
6567    /// [`Self::set_output`] without blocking: the call is queued, and
6568    /// the program keeps running until the result comes back; see [`crate::task`].
6569    #[cfg(feature = "async")]
6570    pub async fn set_output_async(&self, side: Option<Number>, value: Option<Value>) -> Result<Value> {
6571        let args = args(vec![side.map(Value::Number), value]);
6572        let reply = self.invoke_async("setOutput", args).await?;
6573        single::<Value>(reply)
6574    }
6575
6576    /// Set the wake-up threshold.
6577    ///
6578    /// Lua: `redstone.setWakeThreshold(threshold:number):number`
6579    /// Indirect call: waits for the next server tick.
6580    pub fn set_wake_threshold(&self, threshold: impl Into<Number>) -> Result<Number> {
6581        let args = args(vec![Some(Value::Number(threshold.into()))]);
6582        let reply = self.invoke("setWakeThreshold", args)?;
6583        single::<Number>(reply)
6584    }
6585
6586    /// [`Self::set_wake_threshold`] without blocking: the call is queued, and
6587    /// the program keeps running until the result comes back; see [`crate::task`].
6588    #[cfg(feature = "async")]
6589    pub async fn set_wake_threshold_async(&self, threshold: impl Into<Number>) -> Result<Number> {
6590        let args = args(vec![Some(Value::Number(threshold.into()))]);
6591        let reply = self.invoke_async("setWakeThreshold", args).await?;
6592        single::<Number>(reply)
6593    }
6594
6595    /// Set the wireless redstone frequency to use.
6596    ///
6597    /// Lua: `redstone.setWirelessFrequency(frequency:number):number`
6598    /// Indirect call: waits for the next server tick.
6599    pub fn set_wireless_frequency(&self, frequency: impl Into<Number>) -> Result<Number> {
6600        let args = args(vec![Some(Value::Number(frequency.into()))]);
6601        let reply = self.invoke("setWirelessFrequency", args)?;
6602        single::<Number>(reply)
6603    }
6604
6605    /// [`Self::set_wireless_frequency`] without blocking: the call is queued, and
6606    /// the program keeps running until the result comes back; see [`crate::task`].
6607    #[cfg(feature = "async")]
6608    pub async fn set_wireless_frequency_async(&self, frequency: impl Into<Number>) -> Result<Number> {
6609        let args = args(vec![Some(Value::Number(frequency.into()))]);
6610        let reply = self.invoke_async("setWirelessFrequency", args).await?;
6611        single::<Number>(reply)
6612    }
6613
6614    /// Set the wireless redstone output.
6615    ///
6616    /// Lua: `redstone.setWirelessOutput(value:boolean):boolean`
6617    /// Indirect call: waits for the next server tick.
6618    pub fn set_wireless_output(&self, value: bool) -> Result<bool> {
6619        let args = args(vec![Some(Value::Bool(value))]);
6620        let reply = self.invoke("setWirelessOutput", args)?;
6621        single::<bool>(reply)
6622    }
6623
6624    /// [`Self::set_wireless_output`] without blocking: the call is queued, and
6625    /// the program keeps running until the result comes back; see [`crate::task`].
6626    #[cfg(feature = "async")]
6627    pub async fn set_wireless_output_async(&self, value: bool) -> Result<bool> {
6628        let args = args(vec![Some(Value::Bool(value))]);
6629        let reply = self.invoke_async("setWirelessOutput", args).await?;
6630        single::<bool>(reply)
6631    }
6632
6633    /// Set the enabled wireless providers.
6634    ///
6635    /// Lua: `redstone.setWirelessProviders(providers:table):table`
6636    /// Indirect call: waits for the next server tick.
6637    pub fn set_wireless_providers(&self, providers: impl Into<Value>) -> Result<Value> {
6638        let args = args(vec![Some(providers.into())]);
6639        let reply = self.invoke("setWirelessProviders", args)?;
6640        single::<Value>(reply)
6641    }
6642
6643    /// [`Self::set_wireless_providers`] without blocking: the call is queued, and
6644    /// the program keeps running until the result comes back; see [`crate::task`].
6645    #[cfg(feature = "async")]
6646    pub async fn set_wireless_providers_async(&self, providers: impl Into<Value>) -> Result<Value> {
6647        let args = args(vec![Some(providers.into())]);
6648        let reply = self.invoke_async("setWirelessProviders", args).await?;
6649        single::<Value>(reply)
6650    }
6651}
6652
6653/// The `relay` component (4 methods).
6654///
6655/// Provided by OpenComputers' `Relay`.
6656#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6657pub struct Relay(pub Address);
6658
6659impl Component for Relay {
6660    const KIND: &'static str = "relay";
6661    fn from_address(address: Address) -> Self {
6662        Self(address)
6663    }
6664    fn address(&self) -> &Address {
6665        &self.0
6666    }
6667}
6668
6669impl Relay {
6670    /// Get the signal strength (range) used when relaying messages.
6671    ///
6672    /// Lua: `relay.getStrength():number`
6673    /// Direct call (runs immediately, drawing on the per-tick budget).
6674    pub fn get_strength(&self) -> Result<Number> {
6675        let args = args(vec![]);
6676        let reply = self.invoke("getStrength", args)?;
6677        single::<Number>(reply)
6678    }
6679
6680    /// [`Self::get_strength`] without blocking: the call is queued, and
6681    /// the program keeps running until the result comes back; see [`crate::task`].
6682    #[cfg(feature = "async")]
6683    pub async fn get_strength_async(&self) -> Result<Number> {
6684        let args = args(vec![]);
6685        let reply = self.invoke_async("getStrength", args).await?;
6686        single::<Number>(reply)
6687    }
6688
6689    /// Get whether the access point currently acts as a repeater (resend received wireless packets wirelessly).
6690    ///
6691    /// Lua: `relay.isRepeater():boolean`
6692    /// Direct call (runs immediately, drawing on the per-tick budget).
6693    pub fn is_repeater(&self) -> Result<bool> {
6694        let args = args(vec![]);
6695        let reply = self.invoke("isRepeater", args)?;
6696        single::<bool>(reply)
6697    }
6698
6699    /// [`Self::is_repeater`] without blocking: the call is queued, and
6700    /// the program keeps running until the result comes back; see [`crate::task`].
6701    #[cfg(feature = "async")]
6702    pub async fn is_repeater_async(&self) -> Result<bool> {
6703        let args = args(vec![]);
6704        let reply = self.invoke_async("isRepeater", args).await?;
6705        single::<bool>(reply)
6706    }
6707
6708    /// Set whether the access point should act as a repeater.
6709    ///
6710    /// Lua: `relay.setRepeater(enabled:boolean):boolean`
6711    /// Indirect call: waits for the next server tick.
6712    pub fn set_repeater(&self, enabled: bool) -> Result<bool> {
6713        let args = args(vec![Some(Value::Bool(enabled))]);
6714        let reply = self.invoke("setRepeater", args)?;
6715        single::<bool>(reply)
6716    }
6717
6718    /// [`Self::set_repeater`] without blocking: the call is queued, and
6719    /// the program keeps running until the result comes back; see [`crate::task`].
6720    #[cfg(feature = "async")]
6721    pub async fn set_repeater_async(&self, enabled: bool) -> Result<bool> {
6722        let args = args(vec![Some(Value::Bool(enabled))]);
6723        let reply = self.invoke_async("setRepeater", args).await?;
6724        single::<bool>(reply)
6725    }
6726
6727    /// Set the signal strength (range) used when relaying messages.
6728    ///
6729    /// Lua: `relay.setStrength(strength:number):number`
6730    /// Indirect call: waits for the next server tick.
6731    pub fn set_strength(&self, strength: impl Into<Number>) -> Result<Number> {
6732        let args = args(vec![Some(Value::Number(strength.into()))]);
6733        let reply = self.invoke("setStrength", args)?;
6734        single::<Number>(reply)
6735    }
6736
6737    /// [`Self::set_strength`] without blocking: the call is queued, and
6738    /// the program keeps running until the result comes back; see [`crate::task`].
6739    #[cfg(feature = "async")]
6740    pub async fn set_strength_async(&self, strength: impl Into<Number>) -> Result<Number> {
6741        let args = args(vec![Some(Value::Number(strength.into()))]);
6742        let reply = self.invoke_async("setStrength", args).await?;
6743        single::<Number>(reply)
6744    }
6745}
6746
6747/// The `robot` component (33 methods).
6748///
6749/// Provided by OpenComputers' `Robot, RobotBase, RobotProxy`.
6750#[derive(Clone, Debug, PartialEq, Eq, Hash)]
6751pub struct Robot(pub Address);
6752
6753impl Component for Robot {
6754    const KIND: &'static str = "robot";
6755    fn from_address(address: Address) -> Self {
6756        Self(address)
6757    }
6758    fn address(&self) -> &Address {
6759        &self.0
6760    }
6761}
6762
6763impl Robot {
6764    /// Compare the block on the specified side with the one in the selected slot. Returns true if equal.
6765    ///
6766    /// Lua: `robot.compare(side:number[, fuzzy:boolean=false]):boolean`
6767    /// Indirect call: waits for the next server tick.
6768    /// `fuzzy` defaults to `false`.
6769    pub fn compare(&self, side: impl Into<Number>, fuzzy: Option<bool>) -> Result<bool> {
6770        let args = args(vec![Some(Value::Number(side.into())), fuzzy.map(Value::Bool)]);
6771        let reply = self.invoke("compare", args)?;
6772        single::<bool>(reply)
6773    }
6774
6775    /// [`Self::compare`] without blocking: the call is queued, and
6776    /// the program keeps running until the result comes back; see [`crate::task`].
6777    #[cfg(feature = "async")]
6778    pub async fn compare_async(&self, side: impl Into<Number>, fuzzy: Option<bool>) -> Result<bool> {
6779        let args = args(vec![Some(Value::Number(side.into())), fuzzy.map(Value::Bool)]);
6780        let reply = self.invoke_async("compare", args).await?;
6781        single::<bool>(reply)
6782    }
6783
6784    /// Compare the fluid in the selected tank with the fluid in the specified tank on the specified side. Returns true if equal.
6785    ///
6786    /// Lua: `robot.compareFluid(side:number [, tank:number]):boolean`
6787    /// Indirect call: waits for the next server tick.
6788    pub fn compare_fluid(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<bool> {
6789        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
6790        let reply = self.invoke("compareFluid", args)?;
6791        single::<bool>(reply)
6792    }
6793
6794    /// [`Self::compare_fluid`] without blocking: the call is queued, and
6795    /// the program keeps running until the result comes back; see [`crate::task`].
6796    #[cfg(feature = "async")]
6797    pub async fn compare_fluid_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<bool> {
6798        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
6799        let reply = self.invoke_async("compareFluid", args).await?;
6800        single::<bool>(reply)
6801    }
6802
6803    /// Compares the fluids in the selected and the specified tank. Returns true if equal.
6804    ///
6805    /// Lua: `robot.compareFluidTo(index:number):boolean`
6806    /// Indirect call: waits for the next server tick.
6807    pub fn compare_fluid_to(&self, index: impl Into<Number>) -> Result<bool> {
6808        let args = args(vec![Some(Value::Number(index.into()))]);
6809        let reply = self.invoke("compareFluidTo", args)?;
6810        single::<bool>(reply)
6811    }
6812
6813    /// [`Self::compare_fluid_to`] without blocking: the call is queued, and
6814    /// the program keeps running until the result comes back; see [`crate::task`].
6815    #[cfg(feature = "async")]
6816    pub async fn compare_fluid_to_async(&self, index: impl Into<Number>) -> Result<bool> {
6817        let args = args(vec![Some(Value::Number(index.into()))]);
6818        let reply = self.invoke_async("compareFluidTo", args).await?;
6819        single::<bool>(reply)
6820    }
6821
6822    /// Compare the contents of the selected slot to the contents of the specified slot.
6823    ///
6824    /// Lua: `robot.compareTo(otherSlot:number[, checkNBT:boolean=false]):boolean`
6825    /// Indirect call: waits for the next server tick.
6826    /// `check_nbt` defaults to `false`.
6827    pub fn compare_to(&self, other_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
6828        let args = args(vec![Some(Value::Number(other_slot.into())), check_nbt.map(Value::Bool)]);
6829        let reply = self.invoke("compareTo", args)?;
6830        single::<bool>(reply)
6831    }
6832
6833    /// [`Self::compare_to`] without blocking: the call is queued, and
6834    /// the program keeps running until the result comes back; see [`crate::task`].
6835    #[cfg(feature = "async")]
6836    pub async fn compare_to_async(&self, other_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
6837        let args = args(vec![Some(Value::Number(other_slot.into())), check_nbt.map(Value::Bool)]);
6838        let reply = self.invoke_async("compareTo", args).await?;
6839        single::<bool>(reply)
6840    }
6841
6842    /// Get the number of items in the specified slot, otherwise in the selected slot.
6843    ///
6844    /// Lua: `robot.count([slot:number]):number`
6845    /// Direct call (runs immediately, drawing on the per-tick budget).
6846    pub fn count(&self, slot: Option<Number>) -> Result<Number> {
6847        let args = args(vec![slot.map(Value::Number)]);
6848        let reply = self.invoke("count", args)?;
6849        single::<Number>(reply)
6850    }
6851
6852    /// [`Self::count`] without blocking: the call is queued, and
6853    /// the program keeps running until the result comes back; see [`crate::task`].
6854    #[cfg(feature = "async")]
6855    pub async fn count_async(&self, slot: Option<Number>) -> Result<Number> {
6856        let args = args(vec![slot.map(Value::Number)]);
6857        let reply = self.invoke_async("count", args).await?;
6858        single::<Number>(reply)
6859    }
6860
6861    /// Checks the contents of the block on the specified sides and returns the findings.
6862    ///
6863    /// Lua: `robot.detect(side:number):boolean, string`
6864    /// Indirect call: waits for the next server tick.
6865    pub fn detect(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
6866        let args = args(vec![Some(Value::Number(side.into()))]);
6867        let reply = self.invoke("detect", args)?;
6868        FromReply::from_reply(reply)
6869    }
6870
6871    /// [`Self::detect`] without blocking: the call is queued, and
6872    /// the program keeps running until the result comes back; see [`crate::task`].
6873    #[cfg(feature = "async")]
6874    pub async fn detect_async(&self, side: impl Into<Number>) -> Result<(bool, OcString)> {
6875        let args = args(vec![Some(Value::Number(side.into()))]);
6876        let reply = self.invoke_async("detect", args).await?;
6877        FromReply::from_reply(reply)
6878    }
6879
6880    /// Drains the specified amount of fluid from the specified side. Returns the amount drained, or an error message.
6881    ///
6882    /// Lua: `robot.drain(side:number[, amount:number=1000]):boolean, number or string`
6883    /// Indirect call: waits for the next server tick.
6884    /// `amount` defaults to `1000`.
6885    pub fn drain(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
6886        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
6887        let reply = self.invoke("drain", args)?;
6888        FromReply::from_reply(reply)
6889    }
6890
6891    /// [`Self::drain`] without blocking: the call is queued, and
6892    /// the program keeps running until the result comes back; see [`crate::task`].
6893    #[cfg(feature = "async")]
6894    pub async fn drain_async(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
6895        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
6896        let reply = self.invoke_async("drain", args).await?;
6897        FromReply::from_reply(reply)
6898    }
6899
6900    /// Drops items from the selected slot towards the specified side.
6901    ///
6902    /// Lua: `robot.drop(side:number[, count:number=64]):boolean`
6903    /// Indirect call: waits for the next server tick.
6904    /// `count` defaults to `64`.
6905    pub fn drop(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
6906        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
6907        let reply = self.invoke("drop", args)?;
6908        single::<bool>(reply)
6909    }
6910
6911    /// [`Self::drop`] without blocking: the call is queued, and
6912    /// the program keeps running until the result comes back; see [`crate::task`].
6913    #[cfg(feature = "async")]
6914    pub async fn drop_async(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
6915        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
6916        let reply = self.invoke_async("drop", args).await?;
6917        single::<bool>(reply)
6918    }
6919
6920    /// Get the durability of the currently equipped tool.
6921    ///
6922    /// Lua: `robot.durability():number`
6923    /// Indirect call: waits for the next server tick.
6924    pub fn durability(&self) -> Result<Number> {
6925        let args = args(vec![]);
6926        let reply = self.invoke("durability", args)?;
6927        single::<Number>(reply)
6928    }
6929
6930    /// [`Self::durability`] without blocking: the call is queued, and
6931    /// the program keeps running until the result comes back; see [`crate::task`].
6932    #[cfg(feature = "async")]
6933    pub async fn durability_async(&self) -> Result<Number> {
6934        let args = args(vec![]);
6935        let reply = self.invoke_async("durability", args).await?;
6936        single::<Number>(reply)
6937    }
6938
6939    /// Eject the specified amount of fluid to the specified side. Returns the amount ejected or an error message.
6940    ///
6941    /// Lua: `robot.fill(side:number[, amount:number=1000]):boolean, number or string`
6942    /// Indirect call: waits for the next server tick.
6943    /// `amount` defaults to `1000`.
6944    pub fn fill(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
6945        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
6946        let reply = self.invoke("fill", args)?;
6947        FromReply::from_reply(reply)
6948    }
6949
6950    /// [`Self::fill`] without blocking: the call is queued, and
6951    /// the program keeps running until the result comes back; see [`crate::task`].
6952    #[cfg(feature = "async")]
6953    pub async fn fill_async(&self, side: impl Into<Number>, amount: Option<Number>) -> Result<(bool, Value)> {
6954        let args = args(vec![Some(Value::Number(side.into())), amount.map(Value::Number)]);
6955        let reply = self.invoke_async("fill", args).await?;
6956        FromReply::from_reply(reply)
6957    }
6958
6959    /// Get the current color of the activity light as an integer encoded RGB value (0xRRGGBB).
6960    ///
6961    /// Lua: `robot.getLightColor():number`
6962    /// Indirect call: waits for the next server tick.
6963    pub fn get_light_color(&self) -> Result<Number> {
6964        let args = args(vec![]);
6965        let reply = self.invoke("getLightColor", args)?;
6966        single::<Number>(reply)
6967    }
6968
6969    /// [`Self::get_light_color`] without blocking: the call is queued, and
6970    /// the program keeps running until the result comes back; see [`crate::task`].
6971    #[cfg(feature = "async")]
6972    pub async fn get_light_color_async(&self) -> Result<Number> {
6973        let args = args(vec![]);
6974        let reply = self.invoke_async("getLightColor", args).await?;
6975        single::<Number>(reply)
6976    }
6977
6978    /// Returns the robot name.
6979    ///
6980    /// Lua: `robot.getName():string`
6981    /// Indirect call: waits for the next server tick.
6982    pub fn get_name(&self) -> Result<OcString> {
6983        let args = args(vec![]);
6984        let reply = self.invoke("getName", args)?;
6985        single::<OcString>(reply)
6986    }
6987
6988    /// [`Self::get_name`] without blocking: the call is queued, and
6989    /// the program keeps running until the result comes back; see [`crate::task`].
6990    #[cfg(feature = "async")]
6991    pub async fn get_name_async(&self) -> Result<OcString> {
6992        let args = args(vec![]);
6993        let reply = self.invoke_async("getName", args).await?;
6994        single::<OcString>(reply)
6995    }
6996
6997    /// The size of this device's internal inventory.
6998    ///
6999    /// Lua: `robot.inventorySize():number`
7000    /// Indirect call: waits for the next server tick.
7001    pub fn inventory_size(&self) -> Result<Number> {
7002        let args = args(vec![]);
7003        let reply = self.invoke("inventorySize", args)?;
7004        single::<Number>(reply)
7005    }
7006
7007    /// [`Self::inventory_size`] without blocking: the call is queued, and
7008    /// the program keeps running until the result comes back; see [`crate::task`].
7009    #[cfg(feature = "async")]
7010    pub async fn inventory_size_async(&self) -> Result<Number> {
7011        let args = args(vec![]);
7012        let reply = self.invoke_async("inventorySize", args).await?;
7013        single::<Number>(reply)
7014    }
7015
7016    /// Returns whether the robot is running.
7017    ///
7018    /// Lua: `robot.isRunning():boolean`
7019    /// Direct call (runs immediately, drawing on the per-tick budget).
7020    pub fn is_running(&self) -> Result<bool> {
7021        let args = args(vec![]);
7022        let reply = self.invoke("isRunning", args)?;
7023        single::<bool>(reply)
7024    }
7025
7026    /// [`Self::is_running`] without blocking: the call is queued, and
7027    /// the program keeps running until the result comes back; see [`crate::task`].
7028    #[cfg(feature = "async")]
7029    pub async fn is_running_async(&self) -> Result<bool> {
7030        let args = args(vec![]);
7031        let reply = self.invoke_async("isRunning", args).await?;
7032        single::<bool>(reply)
7033    }
7034
7035    /// Move in the specified direction.
7036    ///
7037    /// Lua: `robot.move(direction:number):boolean`
7038    /// Indirect call: waits for the next server tick.
7039    pub fn r#move(&self, direction: impl Into<Number>) -> Result<bool> {
7040        let args = args(vec![Some(Value::Number(direction.into()))]);
7041        let reply = self.invoke("move", args)?;
7042        single::<bool>(reply)
7043    }
7044
7045    /// [`Self::move`] without blocking: the call is queued, and
7046    /// the program keeps running until the result comes back; see [`crate::task`].
7047    #[cfg(feature = "async")]
7048    pub async fn move_async(&self, direction: impl Into<Number>) -> Result<bool> {
7049        let args = args(vec![Some(Value::Number(direction.into()))]);
7050        let reply = self.invoke_async("move", args).await?;
7051        single::<bool>(reply)
7052    }
7053
7054    /// Get the name of the agent.
7055    ///
7056    /// Lua: `robot.name():string`
7057    /// Indirect call: waits for the next server tick.
7058    pub fn name(&self) -> Result<OcString> {
7059        let args = args(vec![]);
7060        let reply = self.invoke("name", args)?;
7061        single::<OcString>(reply)
7062    }
7063
7064    /// [`Self::name`] without blocking: the call is queued, and
7065    /// the program keeps running until the result comes back; see [`crate::task`].
7066    #[cfg(feature = "async")]
7067    pub async fn name_async(&self) -> Result<OcString> {
7068        let args = args(vec![]);
7069        let reply = self.invoke_async("name", args).await?;
7070        single::<OcString>(reply)
7071    }
7072
7073    /// Place a block towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
7074    ///
7075    /// Lua: `robot.place(side:number[, face:number=side[, sneaky:boolean=false]]):boolean`
7076    /// Indirect call: waits for the next server tick.
7077    /// `face` defaults to `side`.
7078    /// `sneaky` defaults to `false`.
7079    pub fn place(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<bool> {
7080        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
7081        let reply = self.invoke("place", args)?;
7082        single::<bool>(reply)
7083    }
7084
7085    /// [`Self::place`] without blocking: the call is queued, and
7086    /// the program keeps running until the result comes back; see [`crate::task`].
7087    #[cfg(feature = "async")]
7088    pub async fn place_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<bool> {
7089        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
7090        let reply = self.invoke_async("place", args).await?;
7091        single::<bool>(reply)
7092    }
7093
7094    /// Get the currently selected slot; set the selected slot if specified.
7095    ///
7096    /// Lua: `robot.select([slot:number]):number`
7097    /// Indirect call: waits for the next server tick.
7098    pub fn select(&self, slot: Option<Number>) -> Result<Number> {
7099        let args = args(vec![slot.map(Value::Number)]);
7100        let reply = self.invoke("select", args)?;
7101        single::<Number>(reply)
7102    }
7103
7104    /// [`Self::select`] without blocking: the call is queued, and
7105    /// the program keeps running until the result comes back; see [`crate::task`].
7106    #[cfg(feature = "async")]
7107    pub async fn select_async(&self, slot: Option<Number>) -> Result<Number> {
7108        let args = args(vec![slot.map(Value::Number)]);
7109        let reply = self.invoke_async("select", args).await?;
7110        single::<Number>(reply)
7111    }
7112
7113    /// Select a tank and/or get the number of the currently selected tank.
7114    ///
7115    /// Lua: `robot.selectTank([index:number]):number`
7116    /// Indirect call: waits for the next server tick.
7117    pub fn select_tank(&self, index: Option<Number>) -> Result<Number> {
7118        let args = args(vec![index.map(Value::Number)]);
7119        let reply = self.invoke("selectTank", args)?;
7120        single::<Number>(reply)
7121    }
7122
7123    /// [`Self::select_tank`] without blocking: the call is queued, and
7124    /// the program keeps running until the result comes back; see [`crate::task`].
7125    #[cfg(feature = "async")]
7126    pub async fn select_tank_async(&self, index: Option<Number>) -> Result<Number> {
7127        let args = args(vec![index.map(Value::Number)]);
7128        let reply = self.invoke_async("selectTank", args).await?;
7129        single::<Number>(reply)
7130    }
7131
7132    /// Set the color of the activity light to the specified integer encoded RGB value (0xRRGGBB).
7133    ///
7134    /// Lua: `robot.setLightColor(value:number):number`
7135    /// Indirect call: waits for the next server tick.
7136    pub fn set_light_color(&self, value: impl Into<Number>) -> Result<Number> {
7137        let args = args(vec![Some(Value::Number(value.into()))]);
7138        let reply = self.invoke("setLightColor", args)?;
7139        single::<Number>(reply)
7140    }
7141
7142    /// [`Self::set_light_color`] without blocking: the call is queued, and
7143    /// the program keeps running until the result comes back; see [`crate::task`].
7144    #[cfg(feature = "async")]
7145    pub async fn set_light_color_async(&self, value: impl Into<Number>) -> Result<Number> {
7146        let args = args(vec![Some(Value::Number(value.into()))]);
7147        let reply = self.invoke_async("setLightColor", args).await?;
7148        single::<Number>(reply)
7149    }
7150
7151    /// Sets a new name and returns the old name. Robot must not be running
7152    ///
7153    /// Lua: `robot.setName(name: string):string`
7154    /// Indirect call: waits for the next server tick.
7155    pub fn set_name(&self, name: impl AsRef<[u8]>) -> Result<OcString> {
7156        let args = args(vec![Some(Value::text(name.as_ref()))]);
7157        let reply = self.invoke("setName", args)?;
7158        single::<OcString>(reply)
7159    }
7160
7161    /// [`Self::set_name`] without blocking: the call is queued, and
7162    /// the program keeps running until the result comes back; see [`crate::task`].
7163    #[cfg(feature = "async")]
7164    pub async fn set_name_async(&self, name: impl AsRef<[u8]>) -> Result<OcString> {
7165        let args = args(vec![Some(Value::text(name.as_ref()))]);
7166        let reply = self.invoke_async("setName", args).await?;
7167        single::<OcString>(reply)
7168    }
7169
7170    /// Get the remaining space in the specified slot, otherwise in the selected slot.
7171    ///
7172    /// Lua: `robot.space([slot:number]):number`
7173    /// Direct call (runs immediately, drawing on the per-tick budget).
7174    pub fn space(&self, slot: Option<Number>) -> Result<Number> {
7175        let args = args(vec![slot.map(Value::Number)]);
7176        let reply = self.invoke("space", args)?;
7177        single::<Number>(reply)
7178    }
7179
7180    /// [`Self::space`] without blocking: the call is queued, and
7181    /// the program keeps running until the result comes back; see [`crate::task`].
7182    #[cfg(feature = "async")]
7183    pub async fn space_async(&self, slot: Option<Number>) -> Result<Number> {
7184        let args = args(vec![slot.map(Value::Number)]);
7185        let reply = self.invoke_async("space", args).await?;
7186        single::<Number>(reply)
7187    }
7188
7189    /// Starts the robot. Returns true if the state changed.
7190    ///
7191    /// Lua: `robot.start():boolean`
7192    /// Indirect call: waits for the next server tick.
7193    pub fn start(&self) -> Result<bool> {
7194        let args = args(vec![]);
7195        let reply = self.invoke("start", args)?;
7196        single::<bool>(reply)
7197    }
7198
7199    /// [`Self::start`] without blocking: the call is queued, and
7200    /// the program keeps running until the result comes back; see [`crate::task`].
7201    #[cfg(feature = "async")]
7202    pub async fn start_async(&self) -> Result<bool> {
7203        let args = args(vec![]);
7204        let reply = self.invoke_async("start", args).await?;
7205        single::<bool>(reply)
7206    }
7207
7208    /// Stops the robot. Returns true if the state changed.
7209    ///
7210    /// Lua: `robot.stop():boolean`
7211    /// Indirect call: waits for the next server tick.
7212    pub fn stop(&self) -> Result<bool> {
7213        let args = args(vec![]);
7214        let reply = self.invoke("stop", args)?;
7215        single::<bool>(reply)
7216    }
7217
7218    /// [`Self::stop`] without blocking: the call is queued, and
7219    /// the program keeps running until the result comes back; see [`crate::task`].
7220    #[cfg(feature = "async")]
7221    pub async fn stop_async(&self) -> Result<bool> {
7222        let args = args(vec![]);
7223        let reply = self.invoke_async("stop", args).await?;
7224        single::<bool>(reply)
7225    }
7226
7227    /// Suck up items from the specified side.
7228    ///
7229    /// Lua: `robot.suck(side:number[, count:number=64]):boolean`
7230    /// Indirect call: waits for the next server tick.
7231    /// `count` defaults to `64`.
7232    pub fn suck(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
7233        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
7234        let reply = self.invoke("suck", args)?;
7235        single::<bool>(reply)
7236    }
7237
7238    /// [`Self::suck`] without blocking: the call is queued, and
7239    /// the program keeps running until the result comes back; see [`crate::task`].
7240    #[cfg(feature = "async")]
7241    pub async fn suck_async(&self, side: impl Into<Number>, count: Option<Number>) -> Result<bool> {
7242        let args = args(vec![Some(Value::Number(side.into())), count.map(Value::Number)]);
7243        let reply = self.invoke_async("suck", args).await?;
7244        single::<bool>(reply)
7245    }
7246
7247    /// Perform a 'left click' towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
7248    ///
7249    /// Lua: `robot.swing(side:number[, face:number=side[, sneaky:boolean=false]]):boolean, string`
7250    /// Indirect call: waits for the next server tick.
7251    /// `face` defaults to `side`.
7252    /// `sneaky` defaults to `false`.
7253    pub fn swing(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<(bool, OcString)> {
7254        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
7255        let reply = self.invoke("swing", args)?;
7256        FromReply::from_reply(reply)
7257    }
7258
7259    /// [`Self::swing`] without blocking: the call is queued, and
7260    /// the program keeps running until the result comes back; see [`crate::task`].
7261    #[cfg(feature = "async")]
7262    pub async fn swing_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>) -> Result<(bool, OcString)> {
7263        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool)]);
7264        let reply = self.invoke_async("swing", args).await?;
7265        FromReply::from_reply(reply)
7266    }
7267
7268    /// The number of tanks installed in the device.
7269    ///
7270    /// Lua: `robot.tankCount():number`
7271    /// Indirect call: waits for the next server tick.
7272    pub fn tank_count(&self) -> Result<Number> {
7273        let args = args(vec![]);
7274        let reply = self.invoke("tankCount", args)?;
7275        single::<Number>(reply)
7276    }
7277
7278    /// [`Self::tank_count`] without blocking: the call is queued, and
7279    /// the program keeps running until the result comes back; see [`crate::task`].
7280    #[cfg(feature = "async")]
7281    pub async fn tank_count_async(&self) -> Result<Number> {
7282        let args = args(vec![]);
7283        let reply = self.invoke_async("tankCount", args).await?;
7284        single::<Number>(reply)
7285    }
7286
7287    /// Get the fluid amount in the specified or selected tank.
7288    ///
7289    /// Lua: `robot.tankLevel([index:number]):number`
7290    /// Direct call (runs immediately, drawing on the per-tick budget).
7291    pub fn tank_level(&self, index: Option<Number>) -> Result<Number> {
7292        let args = args(vec![index.map(Value::Number)]);
7293        let reply = self.invoke("tankLevel", args)?;
7294        single::<Number>(reply)
7295    }
7296
7297    /// [`Self::tank_level`] without blocking: the call is queued, and
7298    /// the program keeps running until the result comes back; see [`crate::task`].
7299    #[cfg(feature = "async")]
7300    pub async fn tank_level_async(&self, index: Option<Number>) -> Result<Number> {
7301        let args = args(vec![index.map(Value::Number)]);
7302        let reply = self.invoke_async("tankLevel", args).await?;
7303        single::<Number>(reply)
7304    }
7305
7306    /// Get the remaining fluid capacity in the specified or selected tank.
7307    ///
7308    /// Lua: `robot.tankSpace([index:number]):number`
7309    /// Direct call (runs immediately, drawing on the per-tick budget).
7310    pub fn tank_space(&self, index: Option<Number>) -> Result<Number> {
7311        let args = args(vec![index.map(Value::Number)]);
7312        let reply = self.invoke("tankSpace", args)?;
7313        single::<Number>(reply)
7314    }
7315
7316    /// [`Self::tank_space`] without blocking: the call is queued, and
7317    /// the program keeps running until the result comes back; see [`crate::task`].
7318    #[cfg(feature = "async")]
7319    pub async fn tank_space_async(&self, index: Option<Number>) -> Result<Number> {
7320        let args = args(vec![index.map(Value::Number)]);
7321        let reply = self.invoke_async("tankSpace", args).await?;
7322        single::<Number>(reply)
7323    }
7324
7325    /// Move the specified amount of fluid from the selected tank into the specified tank.
7326    ///
7327    /// Lua: `robot.transferFluidTo(index:number[, count:number=1000]):boolean`
7328    /// Indirect call: waits for the next server tick.
7329    /// `count` defaults to `1000`.
7330    pub fn transfer_fluid_to(&self, index: impl Into<Number>, count: Option<Number>) -> Result<bool> {
7331        let args = args(vec![Some(Value::Number(index.into())), count.map(Value::Number)]);
7332        let reply = self.invoke("transferFluidTo", args)?;
7333        single::<bool>(reply)
7334    }
7335
7336    /// [`Self::transfer_fluid_to`] without blocking: the call is queued, and
7337    /// the program keeps running until the result comes back; see [`crate::task`].
7338    #[cfg(feature = "async")]
7339    pub async fn transfer_fluid_to_async(&self, index: impl Into<Number>, count: Option<Number>) -> Result<bool> {
7340        let args = args(vec![Some(Value::Number(index.into())), count.map(Value::Number)]);
7341        let reply = self.invoke_async("transferFluidTo", args).await?;
7342        single::<bool>(reply)
7343    }
7344
7345    /// Move up to the specified amount of items from the selected slot into the specified slot.
7346    ///
7347    /// Lua: `robot.transferTo(toSlot:number[, amount:number]):boolean`
7348    /// Indirect call: waits for the next server tick.
7349    pub fn transfer_to(&self, to_slot: impl Into<Number>, amount: Option<Number>) -> Result<bool> {
7350        let args = args(vec![Some(Value::Number(to_slot.into())), amount.map(Value::Number)]);
7351        let reply = self.invoke("transferTo", args)?;
7352        single::<bool>(reply)
7353    }
7354
7355    /// [`Self::transfer_to`] without blocking: the call is queued, and
7356    /// the program keeps running until the result comes back; see [`crate::task`].
7357    #[cfg(feature = "async")]
7358    pub async fn transfer_to_async(&self, to_slot: impl Into<Number>, amount: Option<Number>) -> Result<bool> {
7359        let args = args(vec![Some(Value::Number(to_slot.into())), amount.map(Value::Number)]);
7360        let reply = self.invoke_async("transferTo", args).await?;
7361        single::<bool>(reply)
7362    }
7363
7364    /// Rotate in the specified direction.
7365    ///
7366    /// Lua: `robot.turn(clockwise:boolean):boolean`
7367    /// Indirect call: waits for the next server tick.
7368    pub fn turn(&self, clockwise: bool) -> Result<bool> {
7369        let args = args(vec![Some(Value::Bool(clockwise))]);
7370        let reply = self.invoke("turn", args)?;
7371        single::<bool>(reply)
7372    }
7373
7374    /// [`Self::turn`] without blocking: the call is queued, and
7375    /// the program keeps running until the result comes back; see [`crate::task`].
7376    #[cfg(feature = "async")]
7377    pub async fn turn_async(&self, clockwise: bool) -> Result<bool> {
7378        let args = args(vec![Some(Value::Bool(clockwise))]);
7379        let reply = self.invoke_async("turn", args).await?;
7380        single::<bool>(reply)
7381    }
7382
7383    /// Perform a 'right click' towards the specified side. The `face' allows a more precise click calibration, and is relative to the targeted blockspace.
7384    ///
7385    /// Lua: `robot.use(side:number[, face:number=side[, sneaky:boolean=false[, duration:number=0]]]):boolean, string`
7386    /// Indirect call: waits for the next server tick.
7387    /// `face` defaults to `side`.
7388    /// `sneaky` defaults to `false`.
7389    /// `duration` defaults to `0`.
7390    pub fn r#use(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>, duration: Option<Number>) -> Result<(bool, OcString)> {
7391        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool), duration.map(Value::Number)]);
7392        let reply = self.invoke("use", args)?;
7393        FromReply::from_reply(reply)
7394    }
7395
7396    /// [`Self::use`] without blocking: the call is queued, and
7397    /// the program keeps running until the result comes back; see [`crate::task`].
7398    #[cfg(feature = "async")]
7399    pub async fn use_async(&self, side: impl Into<Number>, face: Option<Number>, sneaky: Option<bool>, duration: Option<Number>) -> Result<(bool, OcString)> {
7400        let args = args(vec![Some(Value::Number(side.into())), face.map(Value::Number), sneaky.map(Value::Bool), duration.map(Value::Number)]);
7401        let reply = self.invoke_async("use", args).await?;
7402        FromReply::from_reply(reply)
7403    }
7404}
7405
7406/// The `screen` component (9 methods).
7407///
7408/// Provided by OpenComputers' `Screen, TextBuffer, TextBufferBase`.
7409#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7410pub struct Screen(pub Address);
7411
7412impl Component for Screen {
7413    const KIND: &'static str = "screen";
7414    fn from_address(address: Address) -> Self {
7415        Self(address)
7416    }
7417    fn address(&self) -> &Address {
7418        &self.0
7419    }
7420}
7421
7422impl Screen {
7423    /// The aspect ratio of the screen. For multi-block screens this is the number of blocks, horizontal and vertical.
7424    ///
7425    /// Lua: `screen.getAspectRatio():number, number`
7426    /// Direct call (runs immediately, drawing on the per-tick budget).
7427    pub fn get_aspect_ratio(&self) -> Result<(Number, Number)> {
7428        let args = args(vec![]);
7429        let reply = self.invoke("getAspectRatio", args)?;
7430        FromReply::from_reply(reply)
7431    }
7432
7433    /// [`Self::get_aspect_ratio`] without blocking: the call is queued, and
7434    /// the program keeps running until the result comes back; see [`crate::task`].
7435    #[cfg(feature = "async")]
7436    pub async fn get_aspect_ratio_async(&self) -> Result<(Number, Number)> {
7437        let args = args(vec![]);
7438        let reply = self.invoke_async("getAspectRatio", args).await?;
7439        FromReply::from_reply(reply)
7440    }
7441
7442    /// The list of keyboards attached to the screen.
7443    ///
7444    /// Lua: `screen.getKeyboards():table`
7445    /// Indirect call: waits for the next server tick.
7446    pub fn get_keyboards(&self) -> Result<Value> {
7447        let args = args(vec![]);
7448        let reply = self.invoke("getKeyboards", args)?;
7449        single::<Value>(reply)
7450    }
7451
7452    /// [`Self::get_keyboards`] without blocking: the call is queued, and
7453    /// the program keeps running until the result comes back; see [`crate::task`].
7454    #[cfg(feature = "async")]
7455    pub async fn get_keyboards_async(&self) -> Result<Value> {
7456        let args = args(vec![]);
7457        let reply = self.invoke_async("getKeyboards", args).await?;
7458        single::<Value>(reply)
7459    }
7460
7461    /// Returns whether the screen is currently on.
7462    ///
7463    /// Lua: `screen.isOn():boolean`
7464    /// Direct call (runs immediately, drawing on the per-tick budget).
7465    pub fn is_on(&self) -> Result<bool> {
7466        let args = args(vec![]);
7467        let reply = self.invoke("isOn", args)?;
7468        single::<bool>(reply)
7469    }
7470
7471    /// [`Self::is_on`] without blocking: the call is queued, and
7472    /// the program keeps running until the result comes back; see [`crate::task`].
7473    #[cfg(feature = "async")]
7474    pub async fn is_on_async(&self) -> Result<bool> {
7475        let args = args(vec![]);
7476        let reply = self.invoke_async("isOn", args).await?;
7477        single::<bool>(reply)
7478    }
7479
7480    /// Returns whether the screen is in high precision mode (sub-pixel mouse event positions).
7481    ///
7482    /// Lua: `screen.isPrecise():boolean`
7483    /// Direct call (runs immediately, drawing on the per-tick budget).
7484    pub fn is_precise(&self) -> Result<bool> {
7485        let args = args(vec![]);
7486        let reply = self.invoke("isPrecise", args)?;
7487        single::<bool>(reply)
7488    }
7489
7490    /// [`Self::is_precise`] without blocking: the call is queued, and
7491    /// the program keeps running until the result comes back; see [`crate::task`].
7492    #[cfg(feature = "async")]
7493    pub async fn is_precise_async(&self) -> Result<bool> {
7494        let args = args(vec![]);
7495        let reply = self.invoke_async("isPrecise", args).await?;
7496        single::<bool>(reply)
7497    }
7498
7499    /// Whether touch mode is inverted (sneak-activate opens GUI, instead of normal activate).
7500    ///
7501    /// Lua: `screen.isTouchModeInverted():boolean`
7502    /// Direct call (runs immediately, drawing on the per-tick budget).
7503    pub fn is_touch_mode_inverted(&self) -> Result<bool> {
7504        let args = args(vec![]);
7505        let reply = self.invoke("isTouchModeInverted", args)?;
7506        single::<bool>(reply)
7507    }
7508
7509    /// [`Self::is_touch_mode_inverted`] without blocking: the call is queued, and
7510    /// the program keeps running until the result comes back; see [`crate::task`].
7511    #[cfg(feature = "async")]
7512    pub async fn is_touch_mode_inverted_async(&self) -> Result<bool> {
7513        let args = args(vec![]);
7514        let reply = self.invoke_async("isTouchModeInverted", args).await?;
7515        single::<bool>(reply)
7516    }
7517
7518    /// Set whether to use high precision mode (sub-pixel mouse event positions).
7519    ///
7520    /// Lua: `screen.setPrecise(enabled:boolean):boolean`
7521    /// Indirect call: waits for the next server tick.
7522    pub fn set_precise(&self, enabled: bool) -> Result<bool> {
7523        let args = args(vec![Some(Value::Bool(enabled))]);
7524        let reply = self.invoke("setPrecise", args)?;
7525        single::<bool>(reply)
7526    }
7527
7528    /// [`Self::set_precise`] without blocking: the call is queued, and
7529    /// the program keeps running until the result comes back; see [`crate::task`].
7530    #[cfg(feature = "async")]
7531    pub async fn set_precise_async(&self, enabled: bool) -> Result<bool> {
7532        let args = args(vec![Some(Value::Bool(enabled))]);
7533        let reply = self.invoke_async("setPrecise", args).await?;
7534        single::<bool>(reply)
7535    }
7536
7537    /// Sets whether to invert touch mode (sneak-activate opens GUI, instead of normal activate).
7538    ///
7539    /// Lua: `screen.setTouchModeInverted(value:boolean):boolean`
7540    /// Indirect call: waits for the next server tick.
7541    pub fn set_touch_mode_inverted(&self, value: bool) -> Result<bool> {
7542        let args = args(vec![Some(Value::Bool(value))]);
7543        let reply = self.invoke("setTouchModeInverted", args)?;
7544        single::<bool>(reply)
7545    }
7546
7547    /// [`Self::set_touch_mode_inverted`] without blocking: the call is queued, and
7548    /// the program keeps running until the result comes back; see [`crate::task`].
7549    #[cfg(feature = "async")]
7550    pub async fn set_touch_mode_inverted_async(&self, value: bool) -> Result<bool> {
7551        let args = args(vec![Some(Value::Bool(value))]);
7552        let reply = self.invoke_async("setTouchModeInverted", args).await?;
7553        single::<bool>(reply)
7554    }
7555
7556    /// Turns the screen off. Returns whether the state changed, and whether it is now on.
7557    ///
7558    /// Lua: `screen.turnOff():boolean`
7559    /// Indirect call: waits for the next server tick.
7560    pub fn turn_off(&self) -> Result<bool> {
7561        let args = args(vec![]);
7562        let reply = self.invoke("turnOff", args)?;
7563        single::<bool>(reply)
7564    }
7565
7566    /// [`Self::turn_off`] without blocking: the call is queued, and
7567    /// the program keeps running until the result comes back; see [`crate::task`].
7568    #[cfg(feature = "async")]
7569    pub async fn turn_off_async(&self) -> Result<bool> {
7570        let args = args(vec![]);
7571        let reply = self.invoke_async("turnOff", args).await?;
7572        single::<bool>(reply)
7573    }
7574
7575    /// Turns the screen on. Returns whether the state changed, and whether it is now on.
7576    ///
7577    /// Lua: `screen.turnOn():boolean`
7578    /// Indirect call: waits for the next server tick.
7579    pub fn turn_on(&self) -> Result<bool> {
7580        let args = args(vec![]);
7581        let reply = self.invoke("turnOn", args)?;
7582        single::<bool>(reply)
7583    }
7584
7585    /// [`Self::turn_on`] without blocking: the call is queued, and
7586    /// the program keeps running until the result comes back; see [`crate::task`].
7587    #[cfg(feature = "async")]
7588    pub async fn turn_on_async(&self) -> Result<bool> {
7589        let args = args(vec![]);
7590        let reply = self.invoke_async("turnOn", args).await?;
7591        single::<bool>(reply)
7592    }
7593}
7594
7595/// The `sign` component (2 methods).
7596///
7597/// Provided by OpenComputers' `UpgradeSignInAdapter, UpgradeSignInRotatable`.
7598#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7599pub struct Sign(pub Address);
7600
7601impl Component for Sign {
7602    const KIND: &'static str = "sign";
7603    fn from_address(address: Address) -> Self {
7604        Self(address)
7605    }
7606    fn address(&self) -> &Address {
7607        &self.0
7608    }
7609}
7610
7611impl Sign {
7612    /// Get the text on the sign on the specified side of the adapter.
7613    ///
7614    /// Lua: `sign.getValue(side:number):string`
7615    /// Indirect call: waits for the next server tick.
7616    pub fn get_value(&self, side: impl Into<Number>) -> Result<OcString> {
7617        let args = args(vec![Some(Value::Number(side.into()))]);
7618        let reply = self.invoke("getValue", args)?;
7619        single::<OcString>(reply)
7620    }
7621
7622    /// [`Self::get_value`] without blocking: the call is queued, and
7623    /// the program keeps running until the result comes back; see [`crate::task`].
7624    #[cfg(feature = "async")]
7625    pub async fn get_value_async(&self, side: impl Into<Number>) -> Result<OcString> {
7626        let args = args(vec![Some(Value::Number(side.into()))]);
7627        let reply = self.invoke_async("getValue", args).await?;
7628        single::<OcString>(reply)
7629    }
7630
7631    /// Set the text on the sign on the specified side of the adapter.
7632    ///
7633    /// Lua: `sign.setValue(side:number, value:string):string`
7634    /// Indirect call: waits for the next server tick.
7635    pub fn set_value(&self, side: impl Into<Number>, value: impl AsRef<[u8]>) -> Result<OcString> {
7636        let args = args(vec![Some(Value::Number(side.into())), Some(Value::text(value.as_ref()))]);
7637        let reply = self.invoke("setValue", args)?;
7638        single::<OcString>(reply)
7639    }
7640
7641    /// [`Self::set_value`] without blocking: the call is queued, and
7642    /// the program keeps running until the result comes back; see [`crate::task`].
7643    #[cfg(feature = "async")]
7644    pub async fn set_value_async(&self, side: impl Into<Number>, value: impl AsRef<[u8]>) -> Result<OcString> {
7645        let args = args(vec![Some(Value::Number(side.into())), Some(Value::text(value.as_ref()))]);
7646        let reply = self.invoke_async("setValue", args).await?;
7647        single::<OcString>(reply)
7648    }
7649}
7650
7651/// The `tablet` component (2 methods).
7652///
7653/// Provided by OpenComputers' `Tablet`.
7654#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7655pub struct Tablet(pub Address);
7656
7657impl Component for Tablet {
7658    const KIND: &'static str = "tablet";
7659    fn from_address(address: Address) -> Self {
7660        Self(address)
7661    }
7662    fn address(&self) -> &Address {
7663        &self.0
7664    }
7665}
7666
7667impl Tablet {
7668    /// Gets the pitch of the player holding the tablet.
7669    ///
7670    /// Lua: `tablet.getPitch():number`
7671    /// Indirect call: waits for the next server tick.
7672    pub fn get_pitch(&self) -> Result<Number> {
7673        let args = args(vec![]);
7674        let reply = self.invoke("getPitch", args)?;
7675        single::<Number>(reply)
7676    }
7677
7678    /// [`Self::get_pitch`] without blocking: the call is queued, and
7679    /// the program keeps running until the result comes back; see [`crate::task`].
7680    #[cfg(feature = "async")]
7681    pub async fn get_pitch_async(&self) -> Result<Number> {
7682        let args = args(vec![]);
7683        let reply = self.invoke_async("getPitch", args).await?;
7684        single::<Number>(reply)
7685    }
7686
7687    /// Gets the yaw of the player holding the tablet.
7688    ///
7689    /// Lua: `tablet.getYaw():number`
7690    /// Indirect call: waits for the next server tick.
7691    pub fn get_yaw(&self) -> Result<Number> {
7692        let args = args(vec![]);
7693        let reply = self.invoke("getYaw", args)?;
7694        single::<Number>(reply)
7695    }
7696
7697    /// [`Self::get_yaw`] without blocking: the call is queued, and
7698    /// the program keeps running until the result comes back; see [`crate::task`].
7699    #[cfg(feature = "async")]
7700    pub async fn get_yaw_async(&self) -> Result<Number> {
7701        let args = args(vec![]);
7702        let reply = self.invoke_async("getYaw", args).await?;
7703        single::<Number>(reply)
7704    }
7705}
7706
7707/// The `tank_controller` component (10 methods).
7708///
7709/// Provided by OpenComputers' `UpgradeTankController$Adapter, UpgradeTankController$Drone, UpgradeTankController$Robot`.
7710#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7711pub struct TankController(pub Address);
7712
7713impl Component for TankController {
7714    const KIND: &'static str = "tank_controller";
7715    fn from_address(address: Address) -> Self {
7716        Self(address)
7717    }
7718    fn address(&self) -> &Address {
7719        &self.0
7720    }
7721}
7722
7723impl TankController {
7724    /// Transfers fluid from a tank in the selected inventory slot to the selected tank.
7725    ///
7726    /// Lua: `tank_controller.drain([amount:number]):boolean`
7727    /// Indirect call: waits for the next server tick.
7728    pub fn drain(&self, amount: Option<Number>) -> Result<bool> {
7729        let args = args(vec![amount.map(Value::Number)]);
7730        let reply = self.invoke("drain", args)?;
7731        single::<bool>(reply)
7732    }
7733
7734    /// [`Self::drain`] without blocking: the call is queued, and
7735    /// the program keeps running until the result comes back; see [`crate::task`].
7736    #[cfg(feature = "async")]
7737    pub async fn drain_async(&self, amount: Option<Number>) -> Result<bool> {
7738        let args = args(vec![amount.map(Value::Number)]);
7739        let reply = self.invoke_async("drain", args).await?;
7740        single::<bool>(reply)
7741    }
7742
7743    /// Transfers fluid from the selected tank to a tank in the selected inventory slot.
7744    ///
7745    /// Lua: `tank_controller.fill([amount:number]):boolean`
7746    /// Indirect call: waits for the next server tick.
7747    pub fn fill(&self, amount: Option<Number>) -> Result<bool> {
7748        let args = args(vec![amount.map(Value::Number)]);
7749        let reply = self.invoke("fill", args)?;
7750        single::<bool>(reply)
7751    }
7752
7753    /// [`Self::fill`] without blocking: the call is queued, and
7754    /// the program keeps running until the result comes back; see [`crate::task`].
7755    #[cfg(feature = "async")]
7756    pub async fn fill_async(&self, amount: Option<Number>) -> Result<bool> {
7757        let args = args(vec![amount.map(Value::Number)]);
7758        let reply = self.invoke_async("fill", args).await?;
7759        single::<bool>(reply)
7760    }
7761
7762    /// Get a description of the fluid in the tank in the specified slot or the selected slot.
7763    ///
7764    /// Lua: `tank_controller.getFluidInInternalTank([tank:number]):table`
7765    /// Indirect call: waits for the next server tick.
7766    pub fn get_fluid_in_internal_tank(&self, tank: Option<Number>) -> Result<Value> {
7767        let args = args(vec![tank.map(Value::Number)]);
7768        let reply = self.invoke("getFluidInInternalTank", args)?;
7769        single::<Value>(reply)
7770    }
7771
7772    /// [`Self::get_fluid_in_internal_tank`] without blocking: the call is queued, and
7773    /// the program keeps running until the result comes back; see [`crate::task`].
7774    #[cfg(feature = "async")]
7775    pub async fn get_fluid_in_internal_tank_async(&self, tank: Option<Number>) -> Result<Value> {
7776        let args = args(vec![tank.map(Value::Number)]);
7777        let reply = self.invoke_async("getFluidInInternalTank", args).await?;
7778        single::<Value>(reply)
7779    }
7780
7781    /// Get a description of the fluid in the tank on the specified side.
7782    ///
7783    /// Lua: `tank_controller.getFluidInTank(side:number [, tank:number]):table`
7784    /// Indirect call: waits for the next server tick.
7785    pub fn get_fluid_in_tank(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Value> {
7786        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7787        let reply = self.invoke("getFluidInTank", args)?;
7788        single::<Value>(reply)
7789    }
7790
7791    /// [`Self::get_fluid_in_tank`] without blocking: the call is queued, and
7792    /// the program keeps running until the result comes back; see [`crate::task`].
7793    #[cfg(feature = "async")]
7794    pub async fn get_fluid_in_tank_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Value> {
7795        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7796        let reply = self.invoke_async("getFluidInTank", args).await?;
7797        single::<Value>(reply)
7798    }
7799
7800    /// Get a description of the fluid in the tank item in the specified slot or the selected slot.
7801    ///
7802    /// Lua: `tank_controller.getFluidInTankInSlot([slot:number]):table`
7803    /// Indirect call: waits for the next server tick.
7804    pub fn get_fluid_in_tank_in_slot(&self, slot: Option<Number>) -> Result<Value> {
7805        let args = args(vec![slot.map(Value::Number)]);
7806        let reply = self.invoke("getFluidInTankInSlot", args)?;
7807        single::<Value>(reply)
7808    }
7809
7810    /// [`Self::get_fluid_in_tank_in_slot`] without blocking: the call is queued, and
7811    /// the program keeps running until the result comes back; see [`crate::task`].
7812    #[cfg(feature = "async")]
7813    pub async fn get_fluid_in_tank_in_slot_async(&self, slot: Option<Number>) -> Result<Value> {
7814        let args = args(vec![slot.map(Value::Number)]);
7815        let reply = self.invoke_async("getFluidInTankInSlot", args).await?;
7816        single::<Value>(reply)
7817    }
7818
7819    /// Get the capacity of the tank on the specified side.
7820    ///
7821    /// Lua: `tank_controller.getTankCapacity(side:number [, tank:number]):number`
7822    /// Indirect call: waits for the next server tick.
7823    pub fn get_tank_capacity(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
7824        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7825        let reply = self.invoke("getTankCapacity", args)?;
7826        single::<Number>(reply)
7827    }
7828
7829    /// [`Self::get_tank_capacity`] without blocking: the call is queued, and
7830    /// the program keeps running until the result comes back; see [`crate::task`].
7831    #[cfg(feature = "async")]
7832    pub async fn get_tank_capacity_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
7833        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7834        let reply = self.invoke_async("getTankCapacity", args).await?;
7835        single::<Number>(reply)
7836    }
7837
7838    /// Get the capacity of the tank item in the specified slot of the robot or the selected slot.
7839    ///
7840    /// Lua: `tank_controller.getTankCapacityInSlot([slot:number]):number`
7841    /// Indirect call: waits for the next server tick.
7842    pub fn get_tank_capacity_in_slot(&self, slot: Option<Number>) -> Result<Number> {
7843        let args = args(vec![slot.map(Value::Number)]);
7844        let reply = self.invoke("getTankCapacityInSlot", args)?;
7845        single::<Number>(reply)
7846    }
7847
7848    /// [`Self::get_tank_capacity_in_slot`] without blocking: the call is queued, and
7849    /// the program keeps running until the result comes back; see [`crate::task`].
7850    #[cfg(feature = "async")]
7851    pub async fn get_tank_capacity_in_slot_async(&self, slot: Option<Number>) -> Result<Number> {
7852        let args = args(vec![slot.map(Value::Number)]);
7853        let reply = self.invoke_async("getTankCapacityInSlot", args).await?;
7854        single::<Number>(reply)
7855    }
7856
7857    /// Get the number of tanks available on the specified side.
7858    ///
7859    /// Lua: `tank_controller.getTankCount(side:number):number`
7860    /// Indirect call: waits for the next server tick.
7861    pub fn get_tank_count(&self, side: impl Into<Number>) -> Result<Number> {
7862        let args = args(vec![Some(Value::Number(side.into()))]);
7863        let reply = self.invoke("getTankCount", args)?;
7864        single::<Number>(reply)
7865    }
7866
7867    /// [`Self::get_tank_count`] without blocking: the call is queued, and
7868    /// the program keeps running until the result comes back; see [`crate::task`].
7869    #[cfg(feature = "async")]
7870    pub async fn get_tank_count_async(&self, side: impl Into<Number>) -> Result<Number> {
7871        let args = args(vec![Some(Value::Number(side.into()))]);
7872        let reply = self.invoke_async("getTankCount", args).await?;
7873        single::<Number>(reply)
7874    }
7875
7876    /// Get the amount of fluid in the tank on the specified side.
7877    ///
7878    /// Lua: `tank_controller.getTankLevel(side:number [, tank:number]):number`
7879    /// Indirect call: waits for the next server tick.
7880    pub fn get_tank_level(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
7881        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7882        let reply = self.invoke("getTankLevel", args)?;
7883        single::<Number>(reply)
7884    }
7885
7886    /// [`Self::get_tank_level`] without blocking: the call is queued, and
7887    /// the program keeps running until the result comes back; see [`crate::task`].
7888    #[cfg(feature = "async")]
7889    pub async fn get_tank_level_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
7890        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
7891        let reply = self.invoke_async("getTankLevel", args).await?;
7892        single::<Number>(reply)
7893    }
7894
7895    /// Get the amount of fluid in the tank item in the specified slot or the selected slot.
7896    ///
7897    /// Lua: `tank_controller.getTankLevelInSlot([slot:number]):number`
7898    /// Indirect call: waits for the next server tick.
7899    pub fn get_tank_level_in_slot(&self, slot: Option<Number>) -> Result<Number> {
7900        let args = args(vec![slot.map(Value::Number)]);
7901        let reply = self.invoke("getTankLevelInSlot", args)?;
7902        single::<Number>(reply)
7903    }
7904
7905    /// [`Self::get_tank_level_in_slot`] without blocking: the call is queued, and
7906    /// the program keeps running until the result comes back; see [`crate::task`].
7907    #[cfg(feature = "async")]
7908    pub async fn get_tank_level_in_slot_async(&self, slot: Option<Number>) -> Result<Number> {
7909        let args = args(vec![slot.map(Value::Number)]);
7910        let reply = self.invoke_async("getTankLevelInSlot", args).await?;
7911        single::<Number>(reply)
7912    }
7913}
7914
7915/// The `tractor_beam` component (1 methods).
7916///
7917/// Provided by OpenComputers' `UpgradeTractorBeam$Common, UpgradeTractorBeam$Drone, UpgradeTractorBeam$Player`.
7918#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7919pub struct TractorBeam(pub Address);
7920
7921impl Component for TractorBeam {
7922    const KIND: &'static str = "tractor_beam";
7923    fn from_address(address: Address) -> Self {
7924        Self(address)
7925    }
7926    fn address(&self) -> &Address {
7927        &self.0
7928    }
7929}
7930
7931impl TractorBeam {
7932    /// Tries to pick up a random item in the robots' vicinity.
7933    ///
7934    /// Lua: `tractor_beam.suck():boolean`
7935    /// Indirect call: waits for the next server tick.
7936    pub fn suck(&self) -> Result<bool> {
7937        let args = args(vec![]);
7938        let reply = self.invoke("suck", args)?;
7939        single::<bool>(reply)
7940    }
7941
7942    /// [`Self::suck`] without blocking: the call is queued, and
7943    /// the program keeps running until the result comes back; see [`crate::task`].
7944    #[cfg(feature = "async")]
7945    pub async fn suck_async(&self) -> Result<bool> {
7946        let args = args(vec![]);
7947        let reply = self.invoke_async("suck", args).await?;
7948        single::<bool>(reply)
7949    }
7950}
7951
7952/// The `trading` component (1 methods).
7953///
7954/// Provided by OpenComputers' `UpgradeTrading, UpgradeTradingBase`.
7955#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7956pub struct Trading(pub Address);
7957
7958impl Component for Trading {
7959    const KIND: &'static str = "trading";
7960    fn from_address(address: Address) -> Self {
7961        Self(address)
7962    }
7963    fn address(&self) -> &Address {
7964        &self.0
7965    }
7966}
7967
7968impl Trading {
7969    /// Returns a table of trades in range as userdata objects.
7970    ///
7971    /// Lua: `trading.getTrades():table`
7972    /// Indirect call: waits for the next server tick.
7973    pub fn get_trades(&self) -> Result<Value> {
7974        let args = args(vec![]);
7975        let reply = self.invoke("getTrades", args)?;
7976        single::<Value>(reply)
7977    }
7978
7979    /// [`Self::get_trades`] without blocking: the call is queued, and
7980    /// the program keeps running until the result comes back; see [`crate::task`].
7981    #[cfg(feature = "async")]
7982    pub async fn get_trades_async(&self) -> Result<Value> {
7983        let args = args(vec![]);
7984        let reply = self.invoke_async("getTrades", args).await?;
7985        single::<Value>(reply)
7986    }
7987}
7988
7989/// The `transposer` component (25 methods).
7990///
7991/// Provided by OpenComputers' `Transposer$Block, Transposer$Common, Transposer$Upgrade, TransposerBase`.
7992#[derive(Clone, Debug, PartialEq, Eq, Hash)]
7993pub struct Transposer(pub Address);
7994
7995impl Component for Transposer {
7996    const KIND: &'static str = "transposer";
7997    fn from_address(address: Address) -> Self {
7998        Self(address)
7999    }
8000    fn address(&self) -> &Address {
8001        &self.0
8002    }
8003}
8004
8005impl Transposer {
8006    /// Get whether the items in the two specified slots of the inventory on the specified side of the device are equivalent (have shared item tags).
8007    ///
8008    /// Lua: `transposer.areStacksEquivalent(side:number, slotA:number, slotB:number):boolean`
8009    /// Indirect call: waits for the next server tick.
8010    pub fn are_stacks_equivalent(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
8011        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
8012        let reply = self.invoke("areStacksEquivalent", args)?;
8013        single::<bool>(reply)
8014    }
8015
8016    /// [`Self::are_stacks_equivalent`] without blocking: the call is queued, and
8017    /// the program keeps running until the result comes back; see [`crate::task`].
8018    #[cfg(feature = "async")]
8019    pub async fn are_stacks_equivalent_async(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>) -> Result<bool> {
8020        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into()))]);
8021        let reply = self.invoke_async("areStacksEquivalent", args).await?;
8022        single::<bool>(reply)
8023    }
8024
8025    /// Compare an item in the specified slot in the inventory on the specified side with one in the database with the specified address.
8026    ///
8027    /// Lua: `transposer.compareStackToDatabase(side:number, slot:number, dbAddress:string, dbSlot:number[, checkNBT:boolean=false]):boolean`
8028    /// Indirect call: waits for the next server tick.
8029    /// `check_nbt` defaults to `false`.
8030    pub fn compare_stack_to_database(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
8031        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
8032        let reply = self.invoke("compareStackToDatabase", args)?;
8033        single::<bool>(reply)
8034    }
8035
8036    /// [`Self::compare_stack_to_database`] without blocking: the call is queued, and
8037    /// the program keeps running until the result comes back; see [`crate::task`].
8038    #[cfg(feature = "async")]
8039    pub async fn compare_stack_to_database_async(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
8040        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into())), check_nbt.map(Value::Bool)]);
8041        let reply = self.invoke_async("compareStackToDatabase", args).await?;
8042        single::<bool>(reply)
8043    }
8044
8045    /// Get whether the items in the two specified slots of the inventory on the specified side of the device are of the same type.
8046    ///
8047    /// Lua: `transposer.compareStacks(side:number, slotA:number, slotB:number[, checkNBT:boolean=false]):boolean`
8048    /// Indirect call: waits for the next server tick.
8049    /// `check_nbt` defaults to `false`.
8050    pub fn compare_stacks(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
8051        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), check_nbt.map(Value::Bool)]);
8052        let reply = self.invoke("compareStacks", args)?;
8053        single::<bool>(reply)
8054    }
8055
8056    /// [`Self::compare_stacks`] without blocking: the call is queued, and
8057    /// the program keeps running until the result comes back; see [`crate::task`].
8058    #[cfg(feature = "async")]
8059    pub async fn compare_stacks_async(&self, side: impl Into<Number>, slot_a: impl Into<Number>, slot_b: impl Into<Number>, check_nbt: Option<bool>) -> Result<bool> {
8060        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot_a.into())), Some(Value::Number(slot_b.into())), check_nbt.map(Value::Bool)]);
8061        let reply = self.invoke_async("compareStacks", args).await?;
8062        single::<bool>(reply)
8063    }
8064
8065    /// Get a description of all stacks in the inventory on the specified side of the device.
8066    ///
8067    /// Lua: `transposer.getAllStacks(side:number):userdata`
8068    /// Indirect call: waits for the next server tick.
8069    pub fn get_all_stacks(&self, side: impl Into<Number>) -> Result<Handle> {
8070        let args = args(vec![Some(Value::Number(side.into()))]);
8071        let reply = self.invoke("getAllStacks", args)?;
8072        single::<Handle>(reply)
8073    }
8074
8075    /// [`Self::get_all_stacks`] without blocking: the call is queued, and
8076    /// the program keeps running until the result comes back; see [`crate::task`].
8077    #[cfg(feature = "async")]
8078    pub async fn get_all_stacks_async(&self, side: impl Into<Number>) -> Result<Handle> {
8079        let args = args(vec![Some(Value::Number(side.into()))]);
8080        let reply = self.invoke_async("getAllStacks", args).await?;
8081        single::<Handle>(reply)
8082    }
8083
8084    /// Get the capacity of the fluid container in the specified slot.
8085    ///
8086    /// Lua: `transposer.getContainerCapacityInSlot(side:number, slot:number):number`
8087    /// Indirect call: waits for the next server tick.
8088    pub fn get_container_capacity_in_slot(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8089        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8090        let reply = self.invoke("getContainerCapacityInSlot", args)?;
8091        single::<Number>(reply)
8092    }
8093
8094    /// [`Self::get_container_capacity_in_slot`] without blocking: the call is queued, and
8095    /// the program keeps running until the result comes back; see [`crate::task`].
8096    #[cfg(feature = "async")]
8097    pub async fn get_container_capacity_in_slot_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8098        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8099        let reply = self.invoke_async("getContainerCapacityInSlot", args).await?;
8100        single::<Number>(reply)
8101    }
8102
8103    /// Get the level of the fluid container in the specified slot.
8104    ///
8105    /// Lua: `transposer.getContainerLevelInSlot(side:number, slot:number):number`
8106    /// Indirect call: waits for the next server tick.
8107    pub fn get_container_level_in_slot(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8108        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8109        let reply = self.invoke("getContainerLevelInSlot", args)?;
8110        single::<Number>(reply)
8111    }
8112
8113    /// [`Self::get_container_level_in_slot`] without blocking: the call is queued, and
8114    /// the program keeps running until the result comes back; see [`crate::task`].
8115    #[cfg(feature = "async")]
8116    pub async fn get_container_level_in_slot_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8117        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8118        let reply = self.invoke_async("getContainerLevelInSlot", args).await?;
8119        single::<Number>(reply)
8120    }
8121
8122    /// Get a description of the fluid in the container in the specified slot.
8123    ///
8124    /// Lua: `transposer.getFluidInContainerInSlot(side:number, slot:number):table`
8125    /// Indirect call: waits for the next server tick.
8126    pub fn get_fluid_in_container_in_slot(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
8127        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8128        let reply = self.invoke("getFluidInContainerInSlot", args)?;
8129        single::<Value>(reply)
8130    }
8131
8132    /// [`Self::get_fluid_in_container_in_slot`] without blocking: the call is queued, and
8133    /// the program keeps running until the result comes back; see [`crate::task`].
8134    #[cfg(feature = "async")]
8135    pub async fn get_fluid_in_container_in_slot_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
8136        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8137        let reply = self.invoke_async("getFluidInContainerInSlot", args).await?;
8138        single::<Value>(reply)
8139    }
8140
8141    /// Get a description of the fluid in the tank on the specified side.
8142    ///
8143    /// Lua: `transposer.getFluidInTank(side:number [, tank:number]):table`
8144    /// Indirect call: waits for the next server tick.
8145    pub fn get_fluid_in_tank(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Value> {
8146        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8147        let reply = self.invoke("getFluidInTank", args)?;
8148        single::<Value>(reply)
8149    }
8150
8151    /// [`Self::get_fluid_in_tank`] without blocking: the call is queued, and
8152    /// the program keeps running until the result comes back; see [`crate::task`].
8153    #[cfg(feature = "async")]
8154    pub async fn get_fluid_in_tank_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Value> {
8155        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8156        let reply = self.invoke_async("getFluidInTank", args).await?;
8157        single::<Value>(reply)
8158    }
8159
8160    /// Returns the fluid transfer rate in liters per second.
8161    ///
8162    /// Lua: `transposer.getFluidTransferRate():number`
8163    /// Indirect call: waits for the next server tick.
8164    pub fn get_fluid_transfer_rate(&self) -> Result<Number> {
8165        let args = args(vec![]);
8166        let reply = self.invoke("getFluidTransferRate", args)?;
8167        single::<Number>(reply)
8168    }
8169
8170    /// [`Self::get_fluid_transfer_rate`] without blocking: the call is queued, and
8171    /// the program keeps running until the result comes back; see [`crate::task`].
8172    #[cfg(feature = "async")]
8173    pub async fn get_fluid_transfer_rate_async(&self) -> Result<Number> {
8174        let args = args(vec![]);
8175        let reply = self.invoke_async("getFluidTransferRate", args).await?;
8176        single::<Number>(reply)
8177    }
8178
8179    /// Get the name of the inventory on the specified side of the device.
8180    ///
8181    /// Lua: `transposer.getInventoryName(side:number):string`
8182    /// Indirect call: waits for the next server tick.
8183    pub fn get_inventory_name(&self, side: impl Into<Number>) -> Result<OcString> {
8184        let args = args(vec![Some(Value::Number(side.into()))]);
8185        let reply = self.invoke("getInventoryName", args)?;
8186        single::<OcString>(reply)
8187    }
8188
8189    /// [`Self::get_inventory_name`] without blocking: the call is queued, and
8190    /// the program keeps running until the result comes back; see [`crate::task`].
8191    #[cfg(feature = "async")]
8192    pub async fn get_inventory_name_async(&self, side: impl Into<Number>) -> Result<OcString> {
8193        let args = args(vec![Some(Value::Number(side.into()))]);
8194        let reply = self.invoke_async("getInventoryName", args).await?;
8195        single::<OcString>(reply)
8196    }
8197
8198    /// Get the number of slots in the inventory on the specified side of the device.
8199    ///
8200    /// Lua: `transposer.getInventorySize(side:number):number`
8201    /// Indirect call: waits for the next server tick.
8202    pub fn get_inventory_size(&self, side: impl Into<Number>) -> Result<Number> {
8203        let args = args(vec![Some(Value::Number(side.into()))]);
8204        let reply = self.invoke("getInventorySize", args)?;
8205        single::<Number>(reply)
8206    }
8207
8208    /// [`Self::get_inventory_size`] without blocking: the call is queued, and
8209    /// the program keeps running until the result comes back; see [`crate::task`].
8210    #[cfg(feature = "async")]
8211    pub async fn get_inventory_size_async(&self, side: impl Into<Number>) -> Result<Number> {
8212        let args = args(vec![Some(Value::Number(side.into()))]);
8213        let reply = self.invoke_async("getInventorySize", args).await?;
8214        single::<Number>(reply)
8215    }
8216
8217    /// Get the maximum number of items in the specified slot of the inventory on the specified side of the device.
8218    ///
8219    /// Lua: `transposer.getSlotMaxStackSize(side:number, slot:number):number`
8220    /// Indirect call: waits for the next server tick.
8221    pub fn get_slot_max_stack_size(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8222        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8223        let reply = self.invoke("getSlotMaxStackSize", args)?;
8224        single::<Number>(reply)
8225    }
8226
8227    /// [`Self::get_slot_max_stack_size`] without blocking: the call is queued, and
8228    /// the program keeps running until the result comes back; see [`crate::task`].
8229    #[cfg(feature = "async")]
8230    pub async fn get_slot_max_stack_size_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8231        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8232        let reply = self.invoke_async("getSlotMaxStackSize", args).await?;
8233        single::<Number>(reply)
8234    }
8235
8236    /// Get number of items in the specified slot of the inventory on the specified side of the device.
8237    ///
8238    /// Lua: `transposer.getSlotStackSize(side:number, slot:number):number`
8239    /// Indirect call: waits for the next server tick.
8240    pub fn get_slot_stack_size(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8241        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8242        let reply = self.invoke("getSlotStackSize", args)?;
8243        single::<Number>(reply)
8244    }
8245
8246    /// [`Self::get_slot_stack_size`] without blocking: the call is queued, and
8247    /// the program keeps running until the result comes back; see [`crate::task`].
8248    #[cfg(feature = "async")]
8249    pub async fn get_slot_stack_size_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Number> {
8250        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8251        let reply = self.invoke_async("getSlotStackSize", args).await?;
8252        single::<Number>(reply)
8253    }
8254
8255    /// Get a description of the stack in the inventory on the specified side of the device.
8256    ///
8257    /// Lua: `transposer.getStackInSlot(side:number, slot:number):table`
8258    /// Indirect call: waits for the next server tick.
8259    pub fn get_stack_in_slot(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
8260        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8261        let reply = self.invoke("getStackInSlot", args)?;
8262        single::<Value>(reply)
8263    }
8264
8265    /// [`Self::get_stack_in_slot`] without blocking: the call is queued, and
8266    /// the program keeps running until the result comes back; see [`crate::task`].
8267    #[cfg(feature = "async")]
8268    pub async fn get_stack_in_slot_async(&self, side: impl Into<Number>, slot: impl Into<Number>) -> Result<Value> {
8269        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into()))]);
8270        let reply = self.invoke_async("getStackInSlot", args).await?;
8271        single::<Value>(reply)
8272    }
8273
8274    /// Get the capacity of the tank on the specified side.
8275    ///
8276    /// Lua: `transposer.getTankCapacity(side:number [, tank:number]):number`
8277    /// Indirect call: waits for the next server tick.
8278    pub fn get_tank_capacity(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
8279        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8280        let reply = self.invoke("getTankCapacity", args)?;
8281        single::<Number>(reply)
8282    }
8283
8284    /// [`Self::get_tank_capacity`] without blocking: the call is queued, and
8285    /// the program keeps running until the result comes back; see [`crate::task`].
8286    #[cfg(feature = "async")]
8287    pub async fn get_tank_capacity_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
8288        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8289        let reply = self.invoke_async("getTankCapacity", args).await?;
8290        single::<Number>(reply)
8291    }
8292
8293    /// Get the number of tanks available on the specified side.
8294    ///
8295    /// Lua: `transposer.getTankCount(side:number):number`
8296    /// Indirect call: waits for the next server tick.
8297    pub fn get_tank_count(&self, side: impl Into<Number>) -> Result<Number> {
8298        let args = args(vec![Some(Value::Number(side.into()))]);
8299        let reply = self.invoke("getTankCount", args)?;
8300        single::<Number>(reply)
8301    }
8302
8303    /// [`Self::get_tank_count`] without blocking: the call is queued, and
8304    /// the program keeps running until the result comes back; see [`crate::task`].
8305    #[cfg(feature = "async")]
8306    pub async fn get_tank_count_async(&self, side: impl Into<Number>) -> Result<Number> {
8307        let args = args(vec![Some(Value::Number(side.into()))]);
8308        let reply = self.invoke_async("getTankCount", args).await?;
8309        single::<Number>(reply)
8310    }
8311
8312    /// Get the amount of fluid in the tank on the specified side.
8313    ///
8314    /// Lua: `transposer.getTankLevel(side:number [, tank:number]):number`
8315    /// Indirect call: waits for the next server tick.
8316    pub fn get_tank_level(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
8317        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8318        let reply = self.invoke("getTankLevel", args)?;
8319        single::<Number>(reply)
8320    }
8321
8322    /// [`Self::get_tank_level`] without blocking: the call is queued, and
8323    /// the program keeps running until the result comes back; see [`crate::task`].
8324    #[cfg(feature = "async")]
8325    pub async fn get_tank_level_async(&self, side: impl Into<Number>, tank: Option<Number>) -> Result<Number> {
8326        let args = args(vec![Some(Value::Number(side.into())), tank.map(Value::Number)]);
8327        let reply = self.invoke_async("getTankLevel", args).await?;
8328        single::<Number>(reply)
8329    }
8330
8331    /// Change the display name of the stack.
8332    ///
8333    /// Lua: `transposer.setStackDisplayName(side:number, slot:number, label:string):boolean`
8334    /// Indirect call: waits for the next server tick.
8335    pub fn set_stack_display_name(&self, side: impl Into<Number>, slot: impl Into<Number>, label: impl AsRef<[u8]>) -> Result<bool> {
8336        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(label.as_ref()))]);
8337        let reply = self.invoke("setStackDisplayName", args)?;
8338        single::<bool>(reply)
8339    }
8340
8341    /// [`Self::set_stack_display_name`] without blocking: the call is queued, and
8342    /// the program keeps running until the result comes back; see [`crate::task`].
8343    #[cfg(feature = "async")]
8344    pub async fn set_stack_display_name_async(&self, side: impl Into<Number>, slot: impl Into<Number>, label: impl AsRef<[u8]>) -> Result<bool> {
8345        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(label.as_ref()))]);
8346        let reply = self.invoke_async("setStackDisplayName", args).await?;
8347        single::<bool>(reply)
8348    }
8349
8350    /// Store an item stack description in the specified slot of the database with the specified address.
8351    ///
8352    /// Lua: `transposer.store(side:number, slot:number, dbAddress:string, dbSlot:number):boolean`
8353    /// Indirect call: waits for the next server tick.
8354    pub fn store(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
8355        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
8356        let reply = self.invoke("store", args)?;
8357        single::<bool>(reply)
8358    }
8359
8360    /// [`Self::store`] without blocking: the call is queued, and
8361    /// the program keeps running until the result comes back; see [`crate::task`].
8362    #[cfg(feature = "async")]
8363    pub async fn store_async(&self, side: impl Into<Number>, slot: impl Into<Number>, db_address: impl AsRef<[u8]>, db_slot: impl Into<Number>) -> Result<bool> {
8364        let args = args(vec![Some(Value::Number(side.into())), Some(Value::Number(slot.into())), Some(Value::text(db_address.as_ref())), Some(Value::Number(db_slot.into()))]);
8365        let reply = self.invoke_async("store", args).await?;
8366        single::<bool>(reply)
8367    }
8368
8369    /// Swap two inventory slots if and only if both directions succeed.
8370    ///
8371    /// Lua: `transposer.swap(sourceSide:number, sinkSide:number, sourceSlot:number, sinkSlot:number[, safe:boolean]):boolean`
8372    /// Indirect call: waits for the next server tick.
8373    pub fn swap(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, source_slot: impl Into<Number>, sink_slot: impl Into<Number>, safe: Option<bool>) -> Result<bool> {
8374        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), Some(Value::Number(source_slot.into())), Some(Value::Number(sink_slot.into())), safe.map(Value::Bool)]);
8375        let reply = self.invoke("swap", args)?;
8376        single::<bool>(reply)
8377    }
8378
8379    /// [`Self::swap`] without blocking: the call is queued, and
8380    /// the program keeps running until the result comes back; see [`crate::task`].
8381    #[cfg(feature = "async")]
8382    pub async fn swap_async(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, source_slot: impl Into<Number>, sink_slot: impl Into<Number>, safe: Option<bool>) -> Result<bool> {
8383        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), Some(Value::Number(source_slot.into())), Some(Value::Number(sink_slot.into())), safe.map(Value::Bool)]);
8384        let reply = self.invoke_async("swap", args).await?;
8385        single::<bool>(reply)
8386    }
8387
8388    /// Transfer some fluid between two tanks. Returns operation result and filled amount
8389    ///
8390    /// Lua: `transposer.transferFluid(sourceSide:number, sinkSide:number[, count:number [, sourceTank:number]]):boolean, number`
8391    /// Indirect call: waits for the next server tick.
8392    pub fn transfer_fluid(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, count: Option<Number>, source_tank: Option<Number>) -> Result<(bool, Number)> {
8393        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), count.map(Value::Number), source_tank.map(Value::Number)]);
8394        let reply = self.invoke("transferFluid", args)?;
8395        FromReply::from_reply(reply)
8396    }
8397
8398    /// [`Self::transfer_fluid`] without blocking: the call is queued, and
8399    /// the program keeps running until the result comes back; see [`crate::task`].
8400    #[cfg(feature = "async")]
8401    pub async fn transfer_fluid_async(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, count: Option<Number>, source_tank: Option<Number>) -> Result<(bool, Number)> {
8402        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), count.map(Value::Number), source_tank.map(Value::Number)]);
8403        let reply = self.invoke_async("transferFluid", args).await?;
8404        FromReply::from_reply(reply)
8405    }
8406
8407    /// Transfer some fluid between containers.
8408    ///
8409    /// Lua: `transposer.transferFluidBetweenContainers(sourceSide:number, sourceSlot:number, sinkSide:number, sinkSlot:number[, count:number, ...]):boolean, number`
8410    /// Indirect call: waits for the next server tick.
8411    pub fn transfer_fluid_between_containers(&self, source_side: impl Into<Number>, source_slot: impl Into<Number>, sink_side: impl Into<Number>, sink_slot: impl Into<Number>, count: Option<Number>, arg5: &[Value]) -> Result<(bool, Number)> {
8412        let mut args: Vec<Value> = vec![Some(Value::Number(source_side.into())), Some(Value::Number(source_slot.into())), Some(Value::Number(sink_side.into())), Some(Value::Number(sink_slot.into())), count.map(Value::Number)].into_iter().map(Option::unwrap_or_default).collect();
8413        args.extend_from_slice(arg5);
8414        let reply = self.invoke("transferFluidBetweenContainers", args)?;
8415        FromReply::from_reply(reply)
8416    }
8417
8418    /// [`Self::transfer_fluid_between_containers`] without blocking: the call is queued, and
8419    /// the program keeps running until the result comes back; see [`crate::task`].
8420    #[cfg(feature = "async")]
8421    pub async fn transfer_fluid_between_containers_async(&self, source_side: impl Into<Number>, source_slot: impl Into<Number>, sink_side: impl Into<Number>, sink_slot: impl Into<Number>, count: Option<Number>, arg5: &[Value]) -> Result<(bool, Number)> {
8422        let mut args: Vec<Value> = vec![Some(Value::Number(source_side.into())), Some(Value::Number(source_slot.into())), Some(Value::Number(sink_side.into())), Some(Value::Number(sink_slot.into())), count.map(Value::Number)].into_iter().map(Option::unwrap_or_default).collect();
8423        args.extend_from_slice(arg5);
8424        let reply = self.invoke_async("transferFluidBetweenContainers", args).await?;
8425        FromReply::from_reply(reply)
8426    }
8427
8428    /// Transfer some fluid from the container to the tank.
8429    ///
8430    /// Lua: `transposer.transferFluidFromContainerToTank(inventorySide:number, inventorySlot:number, tankSide:number[, count:number[, outputSide:number[, outputSlot:number]]]):boolean, number`
8431    /// Indirect call: waits for the next server tick.
8432    pub fn transfer_fluid_from_container_to_tank(&self, inventory_side: impl Into<Number>, inventory_slot: impl Into<Number>, tank_side: impl Into<Number>, count: Option<Number>, output_side: Option<Number>, output_slot: Option<Number>) -> Result<(bool, Number)> {
8433        let args = args(vec![Some(Value::Number(inventory_side.into())), Some(Value::Number(inventory_slot.into())), Some(Value::Number(tank_side.into())), count.map(Value::Number), output_side.map(Value::Number), output_slot.map(Value::Number)]);
8434        let reply = self.invoke("transferFluidFromContainerToTank", args)?;
8435        FromReply::from_reply(reply)
8436    }
8437
8438    /// [`Self::transfer_fluid_from_container_to_tank`] without blocking: the call is queued, and
8439    /// the program keeps running until the result comes back; see [`crate::task`].
8440    #[cfg(feature = "async")]
8441    pub async fn transfer_fluid_from_container_to_tank_async(&self, inventory_side: impl Into<Number>, inventory_slot: impl Into<Number>, tank_side: impl Into<Number>, count: Option<Number>, output_side: Option<Number>, output_slot: Option<Number>) -> Result<(bool, Number)> {
8442        let args = args(vec![Some(Value::Number(inventory_side.into())), Some(Value::Number(inventory_slot.into())), Some(Value::Number(tank_side.into())), count.map(Value::Number), output_side.map(Value::Number), output_slot.map(Value::Number)]);
8443        let reply = self.invoke_async("transferFluidFromContainerToTank", args).await?;
8444        FromReply::from_reply(reply)
8445    }
8446
8447    /// Transfer some fluid from the tank to the container.
8448    ///
8449    /// Lua: `transposer.transferFluidFromTankToContainer(tankSide:number, inventorySide:number, inventorySlot:number[, count:number[, sourceTank:number[, outputSide:number[, outputSlot:number]]]]):boolean, number`
8450    /// Indirect call: waits for the next server tick.
8451    pub fn transfer_fluid_from_tank_to_container(&self, tank_side: impl Into<Number>, inventory_side: impl Into<Number>, inventory_slot: impl Into<Number>, count: Option<Number>, source_tank: Option<Number>, output_side: Option<Number>, output_slot: Option<Number>) -> Result<(bool, Number)> {
8452        let args = args(vec![Some(Value::Number(tank_side.into())), Some(Value::Number(inventory_side.into())), Some(Value::Number(inventory_slot.into())), count.map(Value::Number), source_tank.map(Value::Number), output_side.map(Value::Number), output_slot.map(Value::Number)]);
8453        let reply = self.invoke("transferFluidFromTankToContainer", args)?;
8454        FromReply::from_reply(reply)
8455    }
8456
8457    /// [`Self::transfer_fluid_from_tank_to_container`] without blocking: the call is queued, and
8458    /// the program keeps running until the result comes back; see [`crate::task`].
8459    #[cfg(feature = "async")]
8460    pub async fn transfer_fluid_from_tank_to_container_async(&self, tank_side: impl Into<Number>, inventory_side: impl Into<Number>, inventory_slot: impl Into<Number>, count: Option<Number>, source_tank: Option<Number>, output_side: Option<Number>, output_slot: Option<Number>) -> Result<(bool, Number)> {
8461        let args = args(vec![Some(Value::Number(tank_side.into())), Some(Value::Number(inventory_side.into())), Some(Value::Number(inventory_slot.into())), count.map(Value::Number), source_tank.map(Value::Number), output_side.map(Value::Number), output_slot.map(Value::Number)]);
8462        let reply = self.invoke_async("transferFluidFromTankToContainer", args).await?;
8463        FromReply::from_reply(reply)
8464    }
8465
8466    /// Transfer some items between two inventories.
8467    ///
8468    /// Lua: `transposer.transferItem(sourceSide:number, sinkSide:number[, count:number[, sourceSlot:number[, sinkSlot:number]]]):boolean`
8469    /// Indirect call: waits for the next server tick.
8470    pub fn transfer_item(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, count: Option<Number>, source_slot: Option<Number>, sink_slot: Option<Number>) -> Result<bool> {
8471        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), count.map(Value::Number), source_slot.map(Value::Number), sink_slot.map(Value::Number)]);
8472        let reply = self.invoke("transferItem", args)?;
8473        single::<bool>(reply)
8474    }
8475
8476    /// [`Self::transfer_item`] without blocking: the call is queued, and
8477    /// the program keeps running until the result comes back; see [`crate::task`].
8478    #[cfg(feature = "async")]
8479    pub async fn transfer_item_async(&self, source_side: impl Into<Number>, sink_side: impl Into<Number>, count: Option<Number>, source_slot: Option<Number>, sink_slot: Option<Number>) -> Result<bool> {
8480        let args = args(vec![Some(Value::Number(source_side.into())), Some(Value::Number(sink_side.into())), count.map(Value::Number), source_slot.map(Value::Number), sink_slot.map(Value::Number)]);
8481        let reply = self.invoke_async("transferItem", args).await?;
8482        single::<bool>(reply)
8483    }
8484}
8485
8486/// The `tunnel` component (5 methods).
8487///
8488/// Provided by OpenComputers' `LinkedCard`.
8489#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8490pub struct Tunnel(pub Address);
8491
8492impl Component for Tunnel {
8493    const KIND: &'static str = "tunnel";
8494    fn from_address(address: Address) -> Self {
8495        Self(address)
8496    }
8497    fn address(&self) -> &Address {
8498        &self.0
8499    }
8500}
8501
8502impl Tunnel {
8503    /// Gets this link card's shared channel address
8504    ///
8505    /// Lua: `tunnel.getChannel():string`
8506    /// Direct call (runs immediately, drawing on the per-tick budget).
8507    pub fn get_channel(&self) -> Result<OcString> {
8508        let args = args(vec![]);
8509        let reply = self.invoke("getChannel", args)?;
8510        single::<OcString>(reply)
8511    }
8512
8513    /// [`Self::get_channel`] without blocking: the call is queued, and
8514    /// the program keeps running until the result comes back; see [`crate::task`].
8515    #[cfg(feature = "async")]
8516    pub async fn get_channel_async(&self) -> Result<OcString> {
8517        let args = args(vec![]);
8518        let reply = self.invoke_async("getChannel", args).await?;
8519        single::<OcString>(reply)
8520    }
8521
8522    /// Get the current wake-up message.
8523    ///
8524    /// Lua: `tunnel.getWakeMessage():string, boolean`
8525    /// Direct call (runs immediately, drawing on the per-tick budget).
8526    pub fn get_wake_message(&self) -> Result<(OcString, bool)> {
8527        let args = args(vec![]);
8528        let reply = self.invoke("getWakeMessage", args)?;
8529        FromReply::from_reply(reply)
8530    }
8531
8532    /// [`Self::get_wake_message`] without blocking: the call is queued, and
8533    /// the program keeps running until the result comes back; see [`crate::task`].
8534    #[cfg(feature = "async")]
8535    pub async fn get_wake_message_async(&self) -> Result<(OcString, bool)> {
8536        let args = args(vec![]);
8537        let reply = self.invoke_async("getWakeMessage", args).await?;
8538        FromReply::from_reply(reply)
8539    }
8540
8541    /// Gets the maximum packet size (config setting).
8542    ///
8543    /// Lua: `tunnel.maxPacketSize():number`
8544    /// Direct call (runs immediately, drawing on the per-tick budget).
8545    pub fn max_packet_size(&self) -> Result<Number> {
8546        let args = args(vec![]);
8547        let reply = self.invoke("maxPacketSize", args)?;
8548        single::<Number>(reply)
8549    }
8550
8551    /// [`Self::max_packet_size`] without blocking: the call is queued, and
8552    /// the program keeps running until the result comes back; see [`crate::task`].
8553    #[cfg(feature = "async")]
8554    pub async fn max_packet_size_async(&self) -> Result<Number> {
8555        let args = args(vec![]);
8556        let reply = self.invoke_async("maxPacketSize", args).await?;
8557        single::<Number>(reply)
8558    }
8559
8560    /// Sends the specified data to the card this one is linked to.
8561    ///
8562    /// Lua: `tunnel.send(data...)`
8563    /// Indirect call: waits for the next server tick.
8564    pub fn send(&self, data: &[Value]) -> Result<()> {
8565        let mut args: Vec<Value> = vec![].into_iter().map(Option::unwrap_or_default).collect();
8566        args.extend_from_slice(data);
8567        let reply = self.invoke("send", args)?;
8568        FromReply::from_reply(reply)
8569    }
8570
8571    /// [`Self::send`] without blocking: the call is queued, and
8572    /// the program keeps running until the result comes back; see [`crate::task`].
8573    #[cfg(feature = "async")]
8574    pub async fn send_async(&self, data: &[Value]) -> Result<()> {
8575        let mut args: Vec<Value> = vec![].into_iter().map(Option::unwrap_or_default).collect();
8576        args.extend_from_slice(data);
8577        let reply = self.invoke_async("send", args).await?;
8578        FromReply::from_reply(reply)
8579    }
8580
8581    /// Set the wake-up message and whether to ignore additional data/parameters.
8582    ///
8583    /// Lua: `tunnel.setWakeMessage(message:string[, fuzzy:boolean]):string`
8584    /// Indirect call: waits for the next server tick.
8585    pub fn set_wake_message(&self, message: impl AsRef<[u8]>, fuzzy: Option<bool>) -> Result<OcString> {
8586        let args = args(vec![Some(Value::text(message.as_ref())), fuzzy.map(Value::Bool)]);
8587        let reply = self.invoke("setWakeMessage", args)?;
8588        single::<OcString>(reply)
8589    }
8590
8591    /// [`Self::set_wake_message`] without blocking: the call is queued, and
8592    /// the program keeps running until the result comes back; see [`crate::task`].
8593    #[cfg(feature = "async")]
8594    pub async fn set_wake_message_async(&self, message: impl AsRef<[u8]>, fuzzy: Option<bool>) -> Result<OcString> {
8595        let args = args(vec![Some(Value::text(message.as_ref())), fuzzy.map(Value::Bool)]);
8596        let reply = self.invoke_async("setWakeMessage", args).await?;
8597        single::<OcString>(reply)
8598    }
8599}
8600
8601/// The `waypoint` component (2 methods).
8602///
8603/// Provided by OpenComputers' `Waypoint`.
8604#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8605pub struct Waypoint(pub Address);
8606
8607impl Component for Waypoint {
8608    const KIND: &'static str = "waypoint";
8609    fn from_address(address: Address) -> Self {
8610        Self(address)
8611    }
8612    fn address(&self) -> &Address {
8613        &self.0
8614    }
8615}
8616
8617impl Waypoint {
8618    /// Get the current label of this waypoint.
8619    ///
8620    /// Lua: `waypoint.getLabel(): string`
8621    /// Indirect call: waits for the next server tick.
8622    pub fn get_label(&self) -> Result<OcString> {
8623        let args = args(vec![]);
8624        let reply = self.invoke("getLabel", args)?;
8625        single::<OcString>(reply)
8626    }
8627
8628    /// [`Self::get_label`] without blocking: the call is queued, and
8629    /// the program keeps running until the result comes back; see [`crate::task`].
8630    #[cfg(feature = "async")]
8631    pub async fn get_label_async(&self) -> Result<OcString> {
8632        let args = args(vec![]);
8633        let reply = self.invoke_async("getLabel", args).await?;
8634        single::<OcString>(reply)
8635    }
8636
8637    /// Set the label for this waypoint.
8638    ///
8639    /// Lua: `waypoint.setLabel(value:string)`
8640    /// Indirect call: waits for the next server tick.
8641    pub fn set_label(&self, value: impl AsRef<[u8]>) -> Result<()> {
8642        let args = args(vec![Some(Value::text(value.as_ref()))]);
8643        let reply = self.invoke("setLabel", args)?;
8644        FromReply::from_reply(reply)
8645    }
8646
8647    /// [`Self::set_label`] without blocking: the call is queued, and
8648    /// the program keeps running until the result comes back; see [`crate::task`].
8649    #[cfg(feature = "async")]
8650    pub async fn set_label_async(&self, value: impl AsRef<[u8]>) -> Result<()> {
8651        let args = args(vec![Some(Value::text(value.as_ref()))]);
8652        let reply = self.invoke_async("setLabel", args).await?;
8653        FromReply::from_reply(reply)
8654    }
8655}
8656
8657#[allow(dead_code)]
8658fn _uses(_: Handle, _: OcString, _: Number) {}