Module dto

Source
Expand description

Digital Transfer Object (DTO) definitions

Since some serializers (like postcard e.g.) cannot work with serde’s skip feature (e.g. #[serde(skip_serializing_if = "Option::is_none")]), the base definitions in this crate do not use this feature. However, when working with API’s we typically encode things as jsons (and the json serializer does not have this problem). In such cases, including fields that are not present creates a lot of waste in the encoding:

{
 "name": "flipper-contract",
 "app_name": null,
 "app_module": null,
 "capabilities": null,
 "pkg_type": "contract",
 "meta": {
   "authors": [],
   "description": null,
   "documentation": null,
   "license": null,
   "repository": null
 }
 // ...
}

This is where the DTO’s come in handy. They are an almost identical representation, but with additional serde features, that make working with APIs more easy and produce a cleaner user experience.

Please note: Not every datatype requires a DTO version, since this is only necessary if some conditional serialization for defaultable fields is involved.

Structs§

PkgMetaDto
DTO for PkgMeta
RegistryDto
DTO for Registry
WasmPkgDto
DTO for WasmPkg
WasmPkgNoSourceDto
DTO for WasmPkgNoSource