Exactly what the error says, you have to call your rule macro from inside a defmodule body.
rule
defmodule