Derive Macro aurum_actors::AurumInterface[][src]

#[derive(AurumInterface)]
{
    // Attributes available to this derive:
    #[aurum]
}
Expand description

Implements RootMessage and other traits for a root message type.

This derive macro is applicable to enums only. It generates all the necessary implementations for the message type to interact with the UnifiedType and produce interfaces. It uses the #[aurum] atrribute to configure interfaces. The #[aurum] attribute has a single optional argument: local. Use #[aurum(local)] to notify AurumInterface that the interface is exclusively local.

use aurum_actors::AurumInterface;

type StrStaticRef = &'static str;

#[derive(AurumInterface)]
#[aurum(local)]
enum DiverseMsgType {
  #[aurum]
  MyStringInterface(String),
  #[aurum(local)]
  MyNonserializableInterface(StrStaticRef),
  MyOtherMsg(u128),
}

In this example, because one of the message options is not serializable, the message type as a whole is not serializable. However, you can use an ActorRef<MyUnifiedType, String> to send a string from a remote machine to whatever actor uses this message type. You can also create a LocalRef<&’static str>, but not a usable ActorRef.

AurumInterface creates an implementation of RootMessage for the type it is invoked on. The RootMessage implementation is blanketed over all types implementing UnifiedType. The blanket is bounded by Case implementation for the root type and each remote interface. In the example, the implementation is bounded by Case<MyMsgType> and Case<String> but not Case<&'static str>.

AurumInterface implements From on every interface type, local or not. In the example, From<String> and From<&'static str> are implemented for MyMsgType.

This macro’s parsing is a work in progress, so for now you will need to create aliases for some types.