1#![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#[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 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 #[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 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 #[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#[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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#[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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 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 #[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 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 #[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 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 #[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#[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 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 #[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 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 #[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) {}