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

What it does

Derive a custom address for an actor. This derive macro does the following:

  • Create a unit struct: {Actor}Address(Address<{Actor}>);
  • Implement From<Address<{Actor}>> for this address.
  • Implement RawAddress<Actor = {Actor}> for this address.
  • #[derive(Debug, Clone)] for this address.

The name of the struct can be changed by adding the optional attribute #[address({AddressName})] after the #[derive] usage.

Example

#[derive(Address)]
#[address(MyActorAddress)] // this is optional
struct MyActor {
    ...
}

impl Actor for MyActor {
    type Address = MyActorAddress;
    ...
}

Important!

Don’t forget to set Actor::Address to the new address!.

Addressable

If you would like to be able to directly call methods like .msg() or .req() on your custom address, then you will probably want to #[derive(Addressable)] as well.