Attribute Macro interoptopus::ffi_service_ctor
source · #[ffi_service_ctor]
Available on crate feature
derive
only.Expand description
Inside a #[ffi_service]
block, mark the FFI constructor.
See the service module for an introduction into services.
§Requirements
For this attribute to work a number of preconditions must be fulfilled:
- The attribute must be used inside an
impl SomeType {}
block marked with#[ffi_service]
. - The method must return
Result<Self, Error>
.
We recommend to have a look at the reference project.
§Example
use interoptopus::{ffi_type, ffi_service, ffi_service_ctor};
#[ffi_type(opaque)]
pub struct SimpleService { }
#[ffi_service(error = "MyFFIError", prefix = "simple_service_")]
impl SimpleService {
#[ffi_service_ctor]
pub fn new_with(some_value: u32) -> Result<Self, Error> {
Ok(Self { })
}
}