1use std::os::raw::c_void;
13
14pub const ABI_MAJOR: u32 = 2;
17pub const ABI_MINOR: u32 = 5;
18pub const ABI_VERSION: u32 = ABI_MAJOR * 10_000 + ABI_MINOR;
20
21#[repr(C)]
26#[derive(Copy, Clone)]
27pub struct YogStr {
28 pub ptr: *const u8,
29 pub len: u32,
30}
31
32impl YogStr {
33 pub const EMPTY: Self = Self {
34 ptr: std::ptr::null(),
35 len: 0,
36 };
37
38 #[allow(clippy::should_implement_trait)]
40 #[inline]
41 pub fn from_str(s: &str) -> Self {
42 Self {
43 ptr: s.as_ptr(),
44 len: s.len() as u32,
45 }
46 }
47
48 #[inline]
49 pub fn is_empty(self) -> bool {
50 self.len == 0 || self.ptr.is_null()
51 }
52
53 #[inline]
58 pub unsafe fn as_str<'a>(self) -> &'a str {
59 unsafe {
60 if self.ptr.is_null() || self.len == 0 {
61 return "";
62 }
63 std::str::from_utf8_unchecked(std::slice::from_raw_parts(self.ptr, self.len as usize))
64 }
65 }
66}
67
68#[repr(C)]
72#[derive(Copy, Clone)]
73pub struct YogOwnedStr {
74 pub ptr: *mut u8,
75 pub len: u32,
76}
77
78impl YogOwnedStr {
79 pub const NONE: Self = Self {
80 ptr: std::ptr::null_mut(),
81 len: 0,
82 };
83
84 pub fn from_string(s: String) -> Self {
86 let len = s.len() as u32;
87 let ptr = Box::into_raw(s.into_bytes().into_boxed_slice()) as *mut u8;
88 Self { ptr, len }
89 }
90
91 #[inline]
92 pub fn is_none(self) -> bool {
93 self.ptr.is_null()
94 }
95}
96
97#[repr(C)]
99#[derive(Copy, Clone)]
100pub struct YogBlockPos {
101 pub x: i32,
102 pub y: i32,
103 pub z: i32,
104}
105
106#[repr(C)]
108#[derive(Copy, Clone)]
109pub struct YogVec3 {
110 pub x: f64,
111 pub y: f64,
112 pub z: f64,
113}
114
115#[repr(C)]
118pub struct YogBlockBreakEvent {
119 pub player: YogStr,
120 pub block: YogStr,
121 pub pos: YogBlockPos,
122 pub dimension: YogStr,
124}
125
126#[repr(C)]
127pub struct YogChatEvent {
128 pub player: YogStr,
129 pub message: YogStr,
130 pub dimension: YogStr,
131}
132
133#[repr(C)]
135pub struct YogPlayerEvent {
136 pub player: YogStr,
137 pub uuid: YogStr,
138 pub dimension: YogStr,
139}
140
141#[repr(C)]
142pub struct YogUseItemEvent {
143 pub player: YogStr,
144 pub item: YogStr,
145 pub sneaking: bool,
147 pub dimension: YogStr,
148}
149
150#[repr(C)]
151pub struct YogUseBlockEvent {
152 pub player: YogStr,
153 pub block: YogStr,
154 pub pos: YogBlockPos,
155 pub dimension: YogStr,
156}
157
158#[repr(C)]
159pub struct YogAttackEntityEvent {
160 pub player: YogStr,
161 pub target_type: YogStr,
162 pub target_uuid: YogStr,
163 pub dimension: YogStr,
164}
165
166#[repr(C)]
167pub struct YogEntityDamageEvent {
168 pub entity_type: YogStr,
169 pub uuid: YogStr,
170 pub amount: f32,
171 pub source: YogStr,
172 pub dimension: YogStr,
173}
174
175#[repr(C)]
176pub struct YogEntityDeathEvent {
177 pub entity_type: YogStr,
178 pub uuid: YogStr,
179 pub source: YogStr,
180 pub dimension: YogStr,
181}
182
183#[repr(C)]
184pub struct YogEntitySpawnEvent {
185 pub entity_type: YogStr,
186 pub uuid: YogStr,
187 pub dimension: YogStr,
188}
189
190#[repr(C)]
193pub struct YogPlayerDeathEvent {
194 pub player: YogStr,
195 pub uuid: YogStr,
196 pub source: YogStr,
198 pub dimension: YogStr,
199}
200
201#[repr(C)]
203pub struct YogPlayerRespawnEvent {
204 pub player: YogStr,
205 pub uuid: YogStr,
206 pub at_anchor: bool,
208 pub dimension: YogStr,
210}
211
212#[repr(C)]
214pub struct YogAdvancementEvent {
215 pub player: YogStr,
216 pub uuid: YogStr,
217 pub advancement: YogStr,
219 pub dimension: YogStr,
220}
221
222#[repr(C)]
225pub struct YogEntityInteractEvent {
226 pub player: YogStr,
227 pub player_uuid: YogStr,
228 pub entity_type: YogStr,
229 pub entity_uuid: YogStr,
230 pub hand: YogStr,
232 pub dimension: YogStr,
233}
234
235#[repr(C)]
237pub struct YogCraftEvent {
238 pub player: YogStr,
239 pub player_uuid: YogStr,
240 pub result_item: YogStr,
241 pub result_count: u32,
242 pub dimension: YogStr,
243}
244
245#[repr(C)]
251pub struct YogMachineCraftEvent {
252 pub machine: YogStr,
254 pub kind: YogStr,
256 pub recipe: YogStr,
257 pub result_item: YogStr,
258 pub result_count: u32,
259 pub values: YogStr,
261 pub pos: YogBlockPos,
262 pub dimension: YogStr,
263 pub player: YogStr,
264}
265
266#[repr(C)]
269pub struct YogExplosionEvent {
270 pub dimension: YogStr,
271 pub x: f64,
272 pub y: f64,
273 pub z: f64,
274 pub power: f32,
275 pub cause_uuid: YogStr,
277}
278
279#[repr(C)]
283pub struct YogItemPickupEvent {
284 pub player: YogStr,
285 pub player_uuid: YogStr,
286 pub item_id: YogStr,
288 pub item_count: u32,
289 pub entity_uuid: YogStr,
291 pub dimension: YogStr,
292}
293
294#[repr(C)]
296pub struct YogPlayerMoveEvent {
297 pub player: YogStr,
298 pub player_uuid: YogStr,
299 pub x: f64,
300 pub y: f64,
301 pub z: f64,
302 pub yaw: f32,
303 pub pitch: f32,
304 pub dimension: YogStr,
305}
306
307#[repr(C)]
311pub struct YogContainerOpenEvent {
312 pub player: YogStr,
313 pub player_uuid: YogStr,
314 pub container_type: YogStr,
315 pub dimension: YogStr,
316}
317
318#[repr(C)]
320pub struct YogContainerCloseEvent {
321 pub player: YogStr,
322 pub player_uuid: YogStr,
323 pub dimension: YogStr,
324}
325
326#[repr(C)]
329pub struct YogProjectileHitEvent {
330 pub projectile_type: YogStr,
332 pub projectile_uuid: YogStr,
333 pub shooter_uuid: YogStr,
335 pub hit_type: YogStr,
337 pub hit_entity_uuid: YogStr,
339 pub x: f64,
340 pub y: f64,
341 pub z: f64,
342 pub dimension: YogStr,
343}
344
345#[repr(C)]
347pub struct YogPlaceBlockEvent {
348 pub player: YogStr,
349 pub block: YogStr,
350 pub pos: YogBlockPos,
351 pub dimension: YogStr,
352}
353
354#[repr(C)]
355pub struct YogPacketEvent {
356 pub channel: YogStr,
357 pub player: YogStr, pub payload: *const u8,
359 pub payload_len: u32,
360}
361
362#[repr(C)]
363pub struct YogCommandEvent {
364 pub name: YogStr,
365 pub args: YogStr,
366 pub source: YogStr,
367 pub uuid: YogStr,
368 pub dimension: YogStr,
370}
371
372#[repr(C)]
376#[derive(Copy, Clone)]
377pub struct YogKeyPressEvent {
378 pub key_code: i32,
380 pub scan_code: i32,
381 pub action: i32,
383 pub modifiers: i32,
385}
386
387pub type YogBlockBreakFn =
399 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogBlockBreakEvent, u8) -> bool;
400pub type YogChatFn =
401 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogChatEvent, u8) -> bool;
402pub type YogPlayerFn =
403 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerEvent, u8) -> bool;
404pub type YogUseItemFn =
405 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseItemEvent, u8) -> bool;
406pub type YogUseBlockFn =
407 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogUseBlockEvent, u8) -> bool;
408pub type YogAttackEntityFn =
409 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAttackEntityEvent, u8) -> bool;
410pub type YogEntityDamageFn =
411 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDamageEvent, u8) -> bool;
412pub type YogEntityDeathFn =
413 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityDeathEvent, u8) -> bool;
414pub type YogEntitySpawnFn =
415 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntitySpawnEvent, u8) -> bool;
416pub type YogPlaceBlockFn =
417 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlaceBlockEvent, u8) -> bool;
418pub type YogPlayerDeathFn =
419 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerDeathEvent, u8) -> bool;
420pub type YogPlayerRespawnFn =
421 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerRespawnEvent, u8) -> bool;
422pub type YogAdvancementFn =
423 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogAdvancementEvent, u8) -> bool;
424pub type YogEntityInteractFn =
425 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogEntityInteractEvent, u8) -> bool;
426pub type YogCraftFn =
427 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogCraftEvent, u8) -> bool;
428pub type YogMachineCraftFn =
429 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogMachineCraftEvent, u8) -> bool;
430pub type YogExplosionFn =
431 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogExplosionEvent, u8) -> bool;
432pub type YogItemPickupFn =
433 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogItemPickupEvent, u8) -> bool;
434pub type YogPlayerMoveFn =
435 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPlayerMoveEvent, u8) -> bool;
436pub type YogContainerOpenFn =
437 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerOpenEvent, u8) -> bool;
438pub type YogContainerCloseFn =
439 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogContainerCloseEvent, u8) -> bool;
440pub type YogProjectileHitFn =
441 unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogProjectileHitEvent, u8) -> bool;
442
443pub type YogPacketFn = unsafe extern "C" fn(*mut c_void, *const YogServer, *const YogPacketEvent);
445pub type YogServerFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
447pub type YogCommandFn = unsafe extern "C" fn(
449 ud: *mut c_void,
450 srv: *const YogServer,
451 ev: *const YogCommandEvent,
452 reply_buf: *mut u8,
453 reply_cap: u32,
454 reply_len: *mut u32,
455);
456pub type YogScheduledFn = unsafe extern "C" fn(*mut c_void, *const YogServer);
458
459pub type YogClientFn = unsafe extern "C" fn(ud: *mut c_void);
463pub type YogUIEventFn = unsafe extern "C" fn(ud: *mut c_void, ui_id: YogStr, event_id: YogStr);
470pub type YogHudRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
473pub type YogPageDrawFn = unsafe extern "C" fn(
477 ud: *mut c_void,
478 gfx: *const YogGfxApi,
479 data: *const u8,
480 len: usize,
481 x: f32,
482 y: f32,
483 w: f32,
484 h: f32,
485);
486pub type YogTooltipSizeFn =
489 unsafe extern "C" fn(ud: *mut c_void, item: YogStr, snbt: YogStr, w: *mut f32, h: *mut f32) -> bool;
490pub type YogTooltipDrawFn = unsafe extern "C" fn(
493 ud: *mut c_void,
494 gfx: *const YogGfxApi,
495 item: YogStr,
496 snbt: YogStr,
497 x: f32,
498 y: f32,
499 w: f32,
500 h: f32,
501);
502pub type YogTextSink = unsafe extern "C" fn(sink: *mut c_void, text: YogStr);
505pub type YogItemTextFn =
510 unsafe extern "C" fn(ud: *mut c_void, item: YogStr, snbt: YogStr, sink: *mut c_void, write: YogTextSink) -> bool;
511pub type YogWorldRenderFn = unsafe extern "C" fn(ud: *mut c_void, gfx: *const YogGfxApi);
514pub type YogKeyPressFn = unsafe extern "C" fn(ud: *mut c_void, ev: *const YogKeyPressEvent) -> bool;
516pub type YogScreenFn = unsafe extern "C" fn(ud: *mut c_void, screen_class: YogStr) -> bool;
519
520#[repr(C)]
536#[derive(Copy, Clone)]
537pub struct YogGfxApi {
538 pub screen_w: i32,
541 pub screen_h: i32,
543 pub delta_tick: f32,
545 pub scale_factor: f32,
548 pub view_proj: [f32; 16],
551 pub camera_pos: [f32; 3],
553 pub player_pos: [f32; 3],
556 pub _pad1: f32,
557
558 pub buf_create: unsafe extern "C" fn() -> u32,
561 pub buf_delete: unsafe extern "C" fn(handle: u32),
563 pub buf_data: unsafe extern "C" fn(handle: u32, bytes: *const u8, len: u32, dynamic: bool),
566 pub buf_subdata: unsafe extern "C" fn(handle: u32, offset: u32, bytes: *const u8, len: u32),
568
569 pub vao_create: unsafe extern "C" fn() -> u32,
572 pub vao_delete: unsafe extern "C" fn(handle: u32),
574 pub vao_attrib: unsafe extern "C" fn(
577 vao: u32,
578 vbo: u32,
579 index: u32,
580 components: u8,
581 dtype: u8,
582 normalized: bool,
583 stride: u32,
584 offset: u32,
585 ),
586 pub vao_set_ebo: unsafe extern "C" fn(vao: u32, ebo: u32),
588
589 pub prog_create: unsafe extern "C" fn(vert: YogStr, frag: YogStr, out: *mut u32) -> bool,
593 pub prog_delete: unsafe extern "C" fn(handle: u32),
595 pub prog_uniform_1i: unsafe extern "C" fn(prog: u32, name: YogStr, v: i32),
596 pub prog_uniform_1f: unsafe extern "C" fn(prog: u32, name: YogStr, v: f32),
597 pub prog_uniform_2f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32),
598 pub prog_uniform_3f: unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32),
599 pub prog_uniform_4f:
600 unsafe extern "C" fn(prog: u32, name: YogStr, x: f32, y: f32, z: f32, w: f32),
601 pub prog_uniform_mat4: unsafe extern "C" fn(prog: u32, name: YogStr, col_major: *const f32),
603
604 pub tex_create: unsafe extern "C" fn(w: u32, h: u32, rgba: *const u8, linear: bool) -> u32,
608 pub tex_delete: unsafe extern "C" fn(handle: u32),
610 pub tex_bind: unsafe extern "C" fn(unit: u32, handle: u32),
612 pub tex_from_mc: unsafe extern "C" fn(id: YogStr) -> u32,
616
617 pub draw_arrays: unsafe extern "C" fn(vao: u32, prog: u32, mode: u8, first: u32, count: u32),
621 pub draw_elements:
624 unsafe extern "C" fn(vao: u32, ebo: u32, prog: u32, mode: u8, count: u32, u32_idx: bool),
625
626 pub set_blend: unsafe extern "C" fn(enabled: bool, src: u32, dst: u32),
629 pub set_depth: unsafe extern "C" fn(test: bool, write: bool),
631 pub set_scissor: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
635 pub clear_scissor: unsafe extern "C" fn(),
637 pub set_viewport: unsafe extern "C" fn(x: i32, y: i32, w: i32, h: i32),
639
640 pub draw2d_rect: unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, color: u32),
643 pub draw2d_gradient:
645 unsafe extern "C" fn(x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32),
646 pub draw2d_text: unsafe extern "C" fn(text: YogStr, x: f32, y: f32, color: u32, shadow: bool),
648
649 pub draw2d_item: unsafe extern "C" fn(id: YogStr, x: f32, y: f32, size: f32),
655
656 pub draw2d_text_font:
662 unsafe extern "C" fn(text: YogStr, font: YogStr, x: f32, y: f32, color: u32, shadow: bool),
663 pub text_width: unsafe extern "C" fn(text: YogStr, font: YogStr) -> f32,
668
669 pub draw2d_image: unsafe extern "C" fn(
680 source: YogStr,
681 x: f32,
682 y: f32,
683 w: f32,
684 h: f32,
685 u: f32,
686 v: f32,
687 uw: f32,
688 vh: f32,
689 tint: u32,
690 ),
691 pub image_size: unsafe extern "C" fn(source: YogStr, w: *mut f32, h: *mut f32) -> bool,
696
697 pub draw2d_svg: unsafe extern "C" fn(data: YogStr, x: f32, y: f32, w: f32, h: f32),
701 pub draw2d_entity:
705 unsafe extern "C" fn(entity: YogStr, x: f32, y: f32, w: f32, h: f32, yaw: f32, pitch: f32),
706
707 pub draw2d_text_scaled: unsafe extern "C" fn(
711 text: YogStr,
712 font: YogStr,
713 x: f32,
714 y: f32,
715 scale: f32,
716 color: u32,
717 shadow: bool,
718 ),
719 pub draw2d_blocks:
723 unsafe extern "C" fn(blocks: YogStr, x: f32, y: f32, w: f32, h: f32, yaw: f32, pitch: f32),
724}
725
726unsafe impl Send for YogGfxApi {}
727unsafe impl Sync for YogGfxApi {}
728
729#[repr(C)]
739pub struct YogServer {
740 pub ctx: *mut c_void,
741 pub abi_version: u32,
742 pub size: u32,
745
746 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
748
749 pub broadcast: unsafe extern "C" fn(ctx: *mut c_void, msg: YogStr),
751
752 pub get_block:
754 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
755 pub set_block: unsafe extern "C" fn(
756 ctx: *mut c_void,
757 dim: YogStr,
758 pos: YogBlockPos,
759 block: YogStr,
760 ) -> bool,
761 pub world_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, out: *mut i64) -> bool,
762 pub set_time: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, time: i64) -> bool,
763 pub is_raining: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
764 pub set_weather:
765 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, raining: bool, dur: i32) -> bool,
766
767 pub give_item:
769 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item: YogStr, count: u32) -> bool,
770 pub player_teleport:
771 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, pos: YogVec3) -> bool,
772 pub send_to_player: unsafe extern "C" fn(
773 ctx: *mut c_void,
774 player: YogStr,
775 channel: YogStr,
776 data: *const u8,
777 len: u32,
778 ) -> bool,
779 pub send_to_server:
780 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, data: *const u8, len: u32) -> bool,
781 pub kick_player: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, reason: YogStr) -> bool,
782 pub set_gamemode: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, mode: YogStr) -> bool,
783 pub send_title: unsafe extern "C" fn(
784 ctx: *mut c_void,
785 player: YogStr,
786 title: YogStr,
787 sub: YogStr,
788 fi: i32,
789 stay: i32,
790 fo: i32,
791 ) -> bool,
792 pub send_actionbar: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, msg: YogStr) -> bool,
793 pub play_sound: unsafe extern "C" fn(
794 ctx: *mut c_void,
795 dim: YogStr,
796 pos: YogVec3,
797 sound: YogStr,
798 vol: f32,
799 pitch: f32,
800 ) -> bool,
801 pub play_sound_player: unsafe extern "C" fn(
802 ctx: *mut c_void,
803 player: YogStr,
804 sound: YogStr,
805 vol: f32,
806 pitch: f32,
807 ) -> bool,
808
809 pub entity_teleport: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, pos: YogVec3) -> bool,
811 pub entity_position:
812 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
813 pub entity_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut f32) -> bool,
814 pub entity_set_health: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, hp: f32) -> bool,
815 pub entity_kill: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
816 pub spawn_entity: unsafe extern "C" fn(
817 ctx: *mut c_void,
818 type_id: YogStr,
819 dim: YogStr,
820 pos: YogVec3,
821 ) -> YogOwnedStr,
822 pub entity_add_effect: unsafe extern "C" fn(
823 ctx: *mut c_void,
824 uuid: YogStr,
825 fx: YogStr,
826 dur: i32,
827 amp: u8,
828 particles: bool,
829 ) -> bool,
830 pub entity_remove_effect:
831 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, fx: YogStr) -> bool,
832 pub entity_clear_effects: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> bool,
833 pub entity_velocity:
834 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
835 pub entity_set_velocity:
836 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
837 pub entity_add_velocity:
838 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, vel: YogVec3) -> bool,
839
840 pub has_item_tag: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, tag: YogStr) -> bool,
842 pub has_block_tag: unsafe extern "C" fn(ctx: *mut c_void, block: YogStr, tag: YogStr) -> bool,
843 pub drop_loot:
844 unsafe extern "C" fn(ctx: *mut c_void, table: YogStr, dim: YogStr, pos: YogVec3) -> bool,
845
846 pub scoreboard_get:
848 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, out: *mut i32) -> bool,
849 pub scoreboard_set:
850 unsafe extern "C" fn(ctx: *mut c_void, obj: YogStr, player: YogStr, score: i32) -> bool,
851 pub scoreboard_add: unsafe extern "C" fn(
852 ctx: *mut c_void,
853 obj: YogStr,
854 player: YogStr,
855 delta: i32,
856 out: *mut i32,
857 ) -> bool,
858
859 pub bossbar_create: unsafe extern "C" fn(
861 ctx: *mut c_void,
862 id: YogStr,
863 title: YogStr,
864 color: YogStr,
865 style: YogStr,
866 ) -> bool,
867 pub bossbar_remove: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
868 pub bossbar_set_title:
869 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, title: YogStr) -> bool,
870 pub bossbar_set_progress:
871 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, progress: f32) -> bool,
872 pub bossbar_set_color:
873 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, color: YogStr) -> bool,
874 pub bossbar_add_player:
875 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
876 pub bossbar_remove_player:
877 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, player: YogStr) -> bool,
878 pub bossbar_set_visible:
879 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, visible: bool) -> bool,
880
881 pub game_dir: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
883
884 pub online_players: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
887
888 pub get_block_nbt:
891 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
892 pub set_block_nbt:
894 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, snbt: YogStr) -> bool,
895
896 pub player_inventory: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
899 pub player_set_slot: unsafe extern "C" fn(
901 ctx: *mut c_void,
902 player: YogStr,
903 slot: u32,
904 item_id: YogStr,
905 count: u32,
906 ) -> bool,
907
908 pub get_inventory_slot: unsafe extern "C" fn(
912 ctx: *mut c_void,
913 dim: YogStr,
914 pos: YogBlockPos,
915 slot: u32,
916 ) -> YogOwnedStr,
917 pub set_inventory_slot: unsafe extern "C" fn(
921 ctx: *mut c_void,
922 dim: YogStr,
923 pos: YogBlockPos,
924 slot: u32,
925 item_id: YogStr,
926 count: u32,
927 ) -> bool,
928
929 pub player_teleport_dim:
931 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, dim: YogStr, pos: YogVec3) -> bool,
932 pub entity_teleport_dim:
933 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
934
935 pub world_entity_count:
938 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, entity_type: YogStr) -> i32,
939
940 pub entity_get_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
943 pub entity_set_nbt: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, snbt: YogStr) -> bool,
945
946 pub spawn_particles: unsafe extern "C" fn(
951 ctx: *mut c_void,
952 dim: YogStr,
953 pos: YogVec3,
954 particle_type: YogStr,
955 count: i32,
956 dx: f64,
957 dy: f64,
958 dz: f64,
959 speed: f64,
960 ) -> bool,
961
962 pub entity_attribute_get:
967 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, attribute_id: YogStr) -> f64,
968 pub entity_attribute_set: unsafe extern "C" fn(
970 ctx: *mut c_void,
971 uuid: YogStr,
972 attribute_id: YogStr,
973 value: f64,
974 ) -> bool,
975
976 pub get_held_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
980 pub set_held_item_nbt:
983 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
984
985 pub get_offhand_item_nbt: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
988 pub set_offhand_item_nbt:
991 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, snbt: YogStr) -> bool,
992 pub get_slot_item:
995 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, slot: u32) -> YogOwnedStr,
996 pub set_slot_item: unsafe extern "C" fn(
999 ctx: *mut c_void,
1000 player: YogStr,
1001 slot: u32,
1002 item_id: YogStr,
1003 count: u32,
1004 snbt: YogStr,
1005 ) -> bool,
1006
1007 pub entity_rotation:
1011 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, out: *mut YogVec3) -> bool,
1012
1013 pub entity_info: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
1018 pub entities_in_box: unsafe extern "C" fn(
1020 ctx: *mut c_void,
1021 dim: YogStr,
1022 min: YogVec3,
1023 max: YogVec3,
1024 ) -> YogOwnedStr,
1025 pub raycast_block: unsafe extern "C" fn(
1027 ctx: *mut c_void,
1028 dim: YogStr,
1029 from: YogVec3,
1030 to: YogVec3,
1031 ) -> YogOwnedStr,
1032 pub raycast_entity: unsafe extern "C" fn(
1034 ctx: *mut c_void,
1035 dim: YogStr,
1036 from: YogVec3,
1037 to: YogVec3,
1038 exclude: YogStr,
1039 ) -> YogOwnedStr,
1040 pub block_info:
1042 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
1043 pub break_block: unsafe extern "C" fn(
1044 ctx: *mut c_void,
1045 dim: YogStr,
1046 pos: YogBlockPos,
1047 drop: bool,
1048 breaker: YogStr,
1049 ) -> bool,
1050 pub place_block_from_slot: unsafe extern "C" fn(
1051 ctx: *mut c_void,
1052 player: YogStr,
1053 slot: u32,
1054 dim: YogStr,
1055 pos: YogBlockPos,
1056 ) -> bool,
1057 pub bonemeal: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> bool,
1058 pub explode: unsafe extern "C" fn(
1059 ctx: *mut c_void,
1060 dim: YogStr,
1061 pos: YogVec3,
1062 power: f32,
1063 fire: bool,
1064 source: YogStr,
1065 ) -> bool,
1066 pub tellraw: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
1068 pub entity_damage: unsafe extern "C" fn(
1069 ctx: *mut c_void,
1070 uuid: YogStr,
1071 amount: f32,
1072 damage_type: YogStr,
1073 attacker: YogStr,
1074 ) -> bool,
1075 pub entity_set_fire_ticks:
1076 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, ticks: i32) -> bool,
1077 pub player_add_xp: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, amount: i32) -> bool,
1078 pub player_set_may_fly:
1079 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, may_fly: bool) -> bool,
1080 pub player_info: unsafe extern "C" fn(ctx: *mut c_void, player: YogStr) -> YogOwnedStr,
1082 pub spawn_item: unsafe extern "C" fn(
1084 ctx: *mut c_void,
1085 dim: YogStr,
1086 pos: YogVec3,
1087 vel: YogVec3,
1088 item_id: YogStr,
1089 count: u32,
1090 snbt: YogStr,
1091 ) -> YogOwnedStr,
1092 pub item_entity_stack: unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr) -> YogOwnedStr,
1094 pub item_entity_set_stack: unsafe extern "C" fn(
1095 ctx: *mut c_void,
1096 uuid: YogStr,
1097 item_id: YogStr,
1098 count: u32,
1099 snbt: YogStr,
1100 ) -> bool,
1101 pub actionbar_json:
1104 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, json: YogStr) -> bool,
1105 pub use_item_on_block: unsafe extern "C" fn(
1107 ctx: *mut c_void,
1108 dim: YogStr,
1109 pos: YogBlockPos,
1110 face: u8,
1111 item_id: YogStr,
1112 player: YogStr,
1113 ) -> bool,
1114 pub pour_fluid: unsafe extern "C" fn(
1115 ctx: *mut c_void,
1116 dim: YogStr,
1117 pos: YogBlockPos,
1118 bucket_item_id: YogStr,
1119 ) -> bool,
1120 pub has_entity_tag:
1121 unsafe extern "C" fn(ctx: *mut c_void, entity_type: YogStr, tag_id: YogStr) -> bool,
1122 pub item_block: unsafe extern "C" fn(ctx: *mut c_void, item_id: YogStr) -> YogOwnedStr,
1124 pub place_feature: unsafe extern "C" fn(
1125 ctx: *mut c_void,
1126 dim: YogStr,
1127 pos: YogBlockPos,
1128 feature_id: YogStr,
1129 ) -> bool,
1130
1131 pub set_item_cooldown:
1133 unsafe extern "C" fn(ctx: *mut c_void, player: YogStr, item_id: YogStr, ticks: i32) -> bool,
1134 pub entity_teleport_with_passengers:
1135 unsafe extern "C" fn(ctx: *mut c_void, uuid: YogStr, dim: YogStr, pos: YogVec3) -> bool,
1136 pub redstone_power: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> i32,
1138 pub set_redstone_output:
1139 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, level: i32) -> bool,
1140 pub get_block_state: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos) -> YogOwnedStr,
1142 pub set_block_state:
1143 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, pos: YogBlockPos, state: YogStr) -> bool,
1144 pub world_is_thundering: unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr) -> bool,
1145 pub world_set_thunder:
1146 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, thundering: bool, duration_ticks: i32) -> bool,
1147 pub fill_region: unsafe extern "C" fn(
1149 ctx: *mut c_void,
1150 dim: YogStr,
1151 from: YogBlockPos,
1152 to: YogBlockPos,
1153 state: YogStr,
1154 ) -> i32,
1155 pub scan_region:
1157 unsafe extern "C" fn(ctx: *mut c_void, dim: YogStr, from: YogBlockPos, to: YogBlockPos) -> YogOwnedStr,
1158}
1159
1160unsafe impl Send for YogServer {}
1162unsafe impl Sync for YogServer {}
1163
1164#[repr(C)]
1171#[derive(Copy, Clone)]
1172pub struct YogChunkWriterApi {
1173 pub chunk_x: i32,
1175 pub chunk_z: i32,
1177 pub min_y: i32,
1179 pub height: i32,
1181 pub ctx: *mut c_void,
1183 pub set_block:
1186 unsafe extern "C" fn(ctx: *mut c_void, x: i32, y: i32, z: i32, block_id: YogStr) -> bool,
1187}
1188
1189unsafe impl Send for YogChunkWriterApi {}
1190unsafe impl Sync for YogChunkWriterApi {}
1191
1192pub type YogChunkGeneratorFn =
1195 unsafe extern "C" fn(ud: *mut c_void, writer: *const YogChunkWriterApi);
1196
1197#[repr(C)]
1206pub struct YogApi {
1207 pub abi_version: u32,
1208 pub size: u32,
1210 pub ctx: *mut c_void,
1212 pub server: *const YogServer,
1214
1215 pub on_block_break: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogBlockBreakFn),
1218 pub on_chat: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogChatFn),
1219 pub on_player_join: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1220 pub on_player_leave: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerFn),
1221 pub on_use_item: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseItemFn),
1222 pub on_use_block: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogUseBlockFn),
1223 pub on_attack_entity:
1224 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAttackEntityFn),
1225 pub on_entity_damage:
1226 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDamageFn),
1227 pub on_entity_death:
1228 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityDeathFn),
1229 pub on_entity_spawn:
1230 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntitySpawnFn),
1231 pub on_player_place_block:
1232 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlaceBlockFn),
1233 pub on_player_death:
1234 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerDeathFn),
1235 pub on_player_respawn:
1236 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerRespawnFn),
1237 pub on_advancement:
1238 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogAdvancementFn),
1239 pub on_entity_interact:
1241 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogEntityInteractFn),
1242 pub on_item_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogCraftFn),
1243 pub on_explosion: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogExplosionFn),
1244 pub on_item_pickup: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogItemPickupFn),
1246 pub on_player_move: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogPlayerMoveFn),
1247 pub on_container_open:
1248 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerOpenFn),
1249 pub on_container_close:
1250 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogContainerCloseFn),
1251 pub on_projectile_hit:
1252 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogProjectileHitFn),
1253 pub on_server_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1254 pub on_server_started: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1255 pub on_server_stopping: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogServerFn),
1256
1257 pub on_packet:
1259 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1260 pub on_client_packet:
1261 unsafe extern "C" fn(ctx: *mut c_void, channel: YogStr, ud: *mut c_void, h: YogPacketFn),
1262
1263 pub register_command:
1265 unsafe extern "C" fn(ctx: *mut c_void, name: YogStr, ud: *mut c_void, h: YogCommandFn),
1266 pub register_typed_command: unsafe extern "C" fn(
1267 ctx: *mut c_void,
1268 name: YogStr,
1269 schema: YogStr,
1270 ud: *mut c_void,
1271 h: YogCommandFn,
1272 ),
1273
1274 pub register_content: unsafe extern "C" fn(ctx: *mut c_void, kind: YogStr, id: YogStr, data: *const u8, len: usize),
1282
1283 pub schedule_once: unsafe extern "C" fn(
1285 ctx: *mut c_void,
1286 delay_ticks: u64,
1287 ud: *mut c_void,
1288 h: YogScheduledFn,
1289 ),
1290 pub schedule_repeating: unsafe extern "C" fn(
1291 ctx: *mut c_void,
1292 period_ticks: u64,
1293 ud: *mut c_void,
1294 h: YogScheduledFn,
1295 ),
1296
1297 pub on_client_tick: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogClientFn),
1299 pub on_hud_render: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogHudRenderFn),
1300 pub on_key_press: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogKeyPressFn),
1301 pub on_screen_open: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1302 pub on_screen_close: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogScreenFn),
1303
1304 pub on_world_render:
1309 unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, h: YogWorldRenderFn),
1310
1311 pub register_ui: unsafe extern "C" fn(
1316 ctx: *mut c_void,
1317 ui_id: YogStr,
1318 layout_json: YogStr,
1319 ud: *mut c_void,
1320 h: YogUIEventFn,
1321 ),
1322
1323 pub on_ui_render:
1330 unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, ud: *mut c_void, h: YogHudRenderFn),
1331
1332 pub register_menu_entry: unsafe extern "C" fn(ctx: *mut c_void, label: YogStr, ui_id: YogStr),
1338
1339 pub mods_list: unsafe extern "C" fn(ctx: *mut c_void) -> YogOwnedStr,
1346 pub free_str: unsafe extern "C" fn(ptr: *mut u8, len: u32),
1349
1350 pub ui_open: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, modal: bool, pause: bool),
1355
1356 pub interop_export:
1360 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr, ptr: *const c_void),
1361 pub interop_import:
1364 unsafe extern "C" fn(ctx: *mut c_void, mod_id: YogStr, symbol: YogStr) -> *const c_void,
1365
1366 pub register_chunk_generator:
1371 unsafe extern "C" fn(ctx: *mut c_void, id: YogStr, ud: *mut c_void, h: YogChunkGeneratorFn),
1372
1373 pub ui_close: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr),
1378 pub ui_consume_event: unsafe extern "C" fn(ctx: *mut c_void),
1382
1383 pub translate: unsafe extern "C" fn(ctx: *mut c_void, key: YogStr) -> YogOwnedStr,
1391
1392 pub ui_open_flags: unsafe extern "C" fn(ctx: *mut c_void, ui_id: YogStr, flags: u32),
1397 pub client_play_sound: unsafe extern "C" fn(
1401 ctx: *mut c_void,
1402 sound_id: YogStr,
1403 volume: f32,
1404 pitch: f32,
1405 looping: bool,
1406 ) -> u32,
1407 pub client_stop_sound: unsafe extern "C" fn(ctx: *mut c_void, handle: u32),
1409 pub client_held_item: unsafe extern "C" fn(ctx: *mut c_void, off_hand: bool) -> YogOwnedStr,
1412 pub client_key_down: unsafe extern "C" fn(ctx: *mut c_void, key: i32) -> bool,
1414
1415 pub on_book_page:
1419 unsafe extern "C" fn(ctx: *mut c_void, drawer: YogStr, ud: *mut c_void, f: YogPageDrawFn),
1420
1421 pub on_item_tooltip: unsafe extern "C" fn(
1426 ctx: *mut c_void,
1427 item: YogStr,
1428 ud: *mut c_void,
1429 size: YogTooltipSizeFn,
1430 draw: YogTooltipDrawFn,
1431 ),
1432
1433 pub is_mod_loaded: unsafe extern "C" fn(ctx: *mut c_void, id: YogStr) -> bool,
1437 pub java_call: unsafe extern "C" fn(ctx: *mut c_void, expr: YogStr, args: YogStr) -> YogOwnedStr,
1444
1445 pub on_item_text: unsafe extern "C" fn(ctx: *mut c_void, item: YogStr, ud: *mut c_void, f: YogItemTextFn),
1449
1450 pub on_machine_craft: unsafe extern "C" fn(ctx: *mut c_void, ud: *mut c_void, f: YogMachineCraftFn),
1453}
1454
1455pub mod ui_flags {
1457 pub const MODAL: u32 = 1;
1459 pub const PAUSE: u32 = 1 << 1;
1461 pub const NO_BACKGROUND: u32 = 1 << 2;
1463}
1464
1465unsafe impl Send for YogApi {}
1466unsafe impl Sync for YogApi {}
1467
1468#[cfg(test)]
1469mod tests {
1470 use super::*;
1471 use std::mem::{align_of, size_of};
1472
1473 fn layout_fingerprint() -> u64 {
1475 macro_rules! layouts {
1476 ($($t:ty),* $(,)?) => { [$((stringify!($t), size_of::<$t>(), align_of::<$t>())),*] };
1477 }
1478 let all = layouts!(
1479 YogStr, YogOwnedStr, YogBlockPos, YogVec3, YogBlockBreakEvent, YogChatEvent, YogPlayerEvent,
1480 YogUseItemEvent, YogUseBlockEvent, YogAttackEntityEvent, YogEntityDamageEvent, YogEntityDeathEvent,
1481 YogEntitySpawnEvent, YogPlayerDeathEvent, YogPlayerRespawnEvent, YogAdvancementEvent,
1482 YogEntityInteractEvent, YogCraftEvent, YogExplosionEvent, YogItemPickupEvent, YogPlayerMoveEvent,
1483 YogContainerOpenEvent, YogContainerCloseEvent, YogProjectileHitEvent, YogPlaceBlockEvent,
1484 YogPacketEvent, YogCommandEvent,
1485 YogKeyPressEvent, YogGfxApi, YogServer, YogChunkWriterApi, YogApi,
1486 );
1487 let mut h: u64 = 0xcbf2_9ce4_8422_2325;
1489 for (name, size, align) in all {
1490 for b in name.bytes().chain((size as u64).to_le_bytes()).chain((align as u64).to_le_bytes()) {
1491 h = (h ^ b as u64).wrapping_mul(0x0100_0000_01b3);
1492 }
1493 }
1494 h
1495 }
1496
1497 #[test]
1501 #[cfg(target_pointer_width = "64")]
1502 fn the_layout_matches_its_version() {
1503 assert_eq!((ABI_VERSION, layout_fingerprint()), (20003, 0x6693_5ed1_cfbb_8df4), "layout fingerprint: {:#x}", layout_fingerprint());
1504 }
1505
1506 #[test]
1507 fn strings_cross_and_come_back() {
1508 let s = YogStr::from_str("Ünïcode ✓");
1509 assert_eq!(unsafe { s.as_str() }, "Ünïcode ✓");
1510 assert!(YogStr::EMPTY.is_empty());
1511 assert_eq!(unsafe { YogStr::EMPTY.as_str() }, "");
1512 let owned = YogOwnedStr::from_string("runtime".to_string());
1513 assert!(!owned.is_none() && owned.len == 7);
1514 assert!(YogOwnedStr::NONE.is_none());
1515 drop(unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(owned.ptr, owned.len as usize)) });
1517 }
1518}