[][src]Crate ketos_derive

Derive traits for Ketos scripting language

Provides a set of custom #[derive(...)] macros for convenience when using Ketos.

One or more of the following names can be added to the derive attribute of any struct or enum value. For example:

This example is not tested
#[macro_use] extern crate ketos;

#[derive(Clone, Debug, ForeignValue, FromValue, IntoValue)]
struct Foo {
    // ...


Implements ForeignValue for the given type. The only method implemented by this macro is type_name. All other methods retain their default implementations.

The ForeignValue trait must be implemented (either manually or using this derive) for any of the other derive implementations to succeed.


Implements FromValue for the given type.

The generated implementation requires that the instance of the type held by the Ketos Value is unique, i.e. the contained Rc has a reference count of 1.

If your type implements Clone, derive(FromValueClone) will instead generate an implementation of FromValue that clones the contained value, if necessary.


Implements FromValue for the given type, provided that the type implements the Clone trait.

If the value contained in the Ketos Value is not unique, the result will be a clone of the contained value.


Implements FromValueRef for the given type.


Implements Into<Value> for the given type.


Implements StructValue for the given type, provided that the type implements Clone and all fields implement Clone, FromValue, and Into<Value>.

Types implementing StructValue can be constructed with new in Ketos code and have their fields accessed and modified with the . and .= functions.

Derive Macros