#[derive(Salt)]
{
// Attributes available to this derive:
#[salt]
}
Expand description
Derive macro used to implement the Salt trait
If the user need to use multiple tasks of the same type,
the salt attribute can be used to define a unique salt.
The salt attribute is a string that can contain placeholders
for the fields of the struct. The placeholders must be in the
form of {self.field_name}.
§Example
ⓘ
#[derive(Salt)]
#[salt(format = "Task {self.id} {self.name}")]
struct Task {
id: TaskState<u32>,
name: TaskState<String>,
...
}
struct SecondTask {
id: TaskState<u32>,
...
}In this example, the salt implementation will look like this:
ⓘ
impl Salt for Task {
fn salt(&self) -> String {
format!("Task {} {}", &*self.id.read().unwrap(), &*self.name.read().unwrap())
}
}
impl Salt for SecondTask {}