Skip to main content

Module declare

Module declare 

Source
Available on crate features http and validation only.
Expand description

Declaring a resource once.

Without this, the same field list is written four times: the Schema, the Resource impl that serializes it, the FromRequest impl that reads a body back, and the JSON Schema those attributes must satisfy. Four copies that have to agree, with nothing checking that they do — rename a field and the compiler stays happy while requests fail at runtime.

resource! takes the list once and writes all four.

Functions§

read_attribute
Read one attribute out of a validated document.
read_relationship
Read one relationship’s id out of a validated document.
read_relationships
Read a to-many relationship’s ids out of a validated document.