macro_rules! service {
($x:ty) => { ... };
}Expand description
Registers a service with the inventory.
The argument is the service struct’s path. The struct must have both #[ffi(service)]
on the struct and #[ffi] on its impl block. All methods and their types are
registered automatically.
#[ffi]
pub enum MyError { General }
#[ffi(service)]
pub struct MyService { count: u32 }
#[ffi]
impl MyService {
pub fn create() -> ffi::Result<Self, MyError> { ffi::Ok(Self { count: 0 }) }
pub fn fetch(&self) -> u32 { self.count }
}
pub fn ffi_inventory() -> RustInventory {
RustInventory::new()
.register(service!(MyService))
.validate()
}