Derive Macro crossmist::Object

source ·
#[derive(Object)]
Expand description

Make a structure or a enum serializable.

This derive macro enables the corresponding type to be passed via channels and to and from child processes. Object can be implemented for a struct/enum if all of its fields implement Object:

This is okay:

#[derive(Object)]
struct Test(String, i32);

This is not okay:

struct NotObject;

#[derive(Object)]
struct Test(String, i32, NotObject);

Generics are supported. In this case, to ensure that all fields implement Object, constraints might be necessary:

This is okay:

#[derive(Object)]
struct MyPair<T: Object>(T, T);

This is not okay:

#[derive(Object)]
struct MyPair<T>(T, T);