[−][src]Macro asana_sdk::model
A macro for generating Asana model structs
Examples
The example below will generate a User
struct, linked to the /users
Asana endpoint.
- It will include & deserialize the
email
&name
fields as Strings. - The fields
gid
andresource_type
are included by default, and don't have to be specified.
Any extra fields returned from the Asana API are flattened by [Serde
] into a [Hashmap
]:
use asana_sdk::models::Model; model!(User "users" { email: String, name: String, });
Comma-separated includes are defined after the struct. Their deserialization type must be indicated within the struct.
This will usually be a Vec<Type>
or Option<Type>
.
This example is suitable for getting a set of Tasks, with the set of Projects that tasks belongs to, and the Assignee the task is assigned to.
Of course, you can include more fields than just name
on the includes.
model!(Assignee "assignee" { name: String }); model!(Project "projects" { name: String }); model!(Tasks "tasks" { name: String, assignee: Option<Assignee> projects: Vec<Project> } Project, Assignee);