Skip to content
This repository has been 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

Open
JeanMertz opened this issue Apr 3, 2019 · 0 comments
Open

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

JeanMertz opened this issue Apr 3, 2019 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@JeanMertz
Copy link
Member

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"))]
@JeanMertz JeanMertz added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Apr 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Development

No branches or pull requests

1 participant