Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Don't serialize back to Pinboard API named fields in template #3

@JeanMertz

Description

@JeanMertz

The Pinboard API calls a title description, and a description extended. When deserializing the JSON response to the Post struct, we rename those fields using Serde:

bulletin/src/main.rs

Lines 52 to 55 in e16f06e

#[serde(rename = "description")]
title: String,
#[serde(rename = "extended")]
description: String,

However, when serializing the Posts to be used in the final template (using Tera's built-in support for Serde), the fields get renamed back to their original Pinboard-described names:

bulletin/src/main.rs

Lines 109 to 114 in e16f06e

fn render(template: &str, data: Data) -> Result<String, String> {
match Tera::one_off_value(template, &data, true) {
Ok(s) => Ok(s),
Err(err) => Err(format!("{}", err)),
}
}

We should keep the new title and description field names instead. This can be done using the (undocumented) attribute:

#[serde(rename(deserialize = "description"))]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions