abi_stable/
for_examples.rs1use crate::{
4 library::RootModule,
5 sabi_types::VersionStrings,
6 std_types::{ROption, RStr, RString},
7 StableAbi,
8};
9
10#[repr(C)]
12#[derive(StableAbi)]
13#[sabi(kind(Prefix(prefix_ref = Module_Ref, prefix_fields = Module_Prefix)))]
14pub struct Module {
15 pub first: ROption<usize>,
17 #[sabi(last_prefix_field)]
25 pub second: RStr<'static>,
26 pub third: usize,
28}
29
30impl RootModule for Module_Ref {
31 crate::declare_root_module_statics! {Module_Ref}
32 const BASE_NAME: &'static str = "example_root_module";
33 const NAME: &'static str = "example_root_module";
34 const VERSION_STRINGS: VersionStrings = crate::package_version_strings!();
35}
36
37#[repr(C)]
39#[derive(StableAbi)]
40#[sabi(kind(Prefix(prefix_ref = PhantModule_Ref, prefix_fields = PhantModule_Prefix)))]
41pub struct PhantModule<T: Copy> {
42 pub first: ROption<usize>,
44 #[sabi(last_prefix_field)]
52 pub second: RStr<'static>,
53 pub third: usize,
55 pub phantom: std::marker::PhantomData<T>,
57}
58
59#[repr(u8)]
61#[derive(StableAbi, Debug, Clone, PartialEq, Eq)]
64#[sabi(kind(WithNonExhaustive(size = [usize;10], traits(Debug, Clone, PartialEq),)))]
65#[sabi(with_constructor)]
66#[non_exhaustive]
67pub enum ValidTag {
68 #[allow(missing_docs)]
69 Foo,
70 #[allow(missing_docs)]
71 Bar,
72 #[allow(missing_docs)]
73 Tag { name: RString, tag: RString },
74}