#[derive(Any)]
{
// Attributes available to this derive:
#[rune]
}
Expand description
Macro to mark a value as external, which will implement all the appropriate traits.
This is required to support the external type as a type argument in a registered function.
§#[rune(item = <path>)]
Specify the item prefix which contains this time.
This is required in order to calculate the correct type hash, if this is omitted and the item is defined in a nested module the type hash won’t match the expected path hash.
use rune::Any;
#[derive(Any)]
#[rune(item = ::process)]
struct Process {
/* .. */
}
fn install() -> Result<rune::Module, rune::ContextError> {
let mut module = rune::Module::with_crate("process")?;
module.ty::<Process>()?;
Ok(module)
}
§#[rune(name = <ident>)]
attribute
The name of a type defaults to its identifiers, so struct Foo {}
would be
given the name Foo
.
This can be overrided with the #[rune(name = <ident>)]
attribute:
use rune::Any;
#[derive(Any)]
#[rune(name = Bar)]
struct Foo {
}
fn install() -> Result<rune::Module, rune::ContextError> {
let mut module = rune::Module::new();
module.ty::<Foo>()?;
Ok(module)
}