Add common types section to CONTRIBUTING.md

This commit is contained in:
Jonas Platte 2020-04-19 22:40:24 +02:00
parent fc976a57ea
commit 8443213766
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -49,6 +49,20 @@ help you on your way:
## Coding Style
### Common types
When writing endpoint definitions, use the following mapping from request /
response field types listed in the specification to Rust types:
Specification type | Rust type
-------------------|---------------------------------------------------------------------------------------------------------------------
`boolean` | `bool`
`integer` | `js_int::UInt` (unless denoted as signed, then `js_int::Int`)
`string` | If for an identifier (e.g. user ID, room ID), use one of the types from `ruma-identifiers`. Otherwise, use `String`.
`object` | `serde_json::Value`
`[…]` | `Vec<…>`
`{string: …}` | `BTreeMap<String, …>` (or `BTreeMap<SomeId, …>`)
### Import Formatting
Organize your imports into three groups separated by blank lines: