Attribute Macro interoptopus_proc::ffi_service[][src]

#[ffi_service]
Expand description

Creates a FFI service from an impl Service {} block.

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 on impl SomeType {} blocks
  • The error parameter must be provided and point to an FFIError type.
  • The respective SomeType type must have an #[ffi_type(opaque)] attribute.
  • Exactly one method inside the impl {} must be marked with #[ffi_service_ctor].

We recommend to have a look at the reference project.

Parameters

The following parameters can be provided:

ParameterExplanation
error = "t"Use t as the FFIError type, mandatory.
prefix = "p"Add p to all generated method names.

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 { })
    }
}