This field can be true/false or "true"/"false"
This commit is contained in:
@@ -4,6 +4,7 @@ use chrono::prelude::*;
|
||||
use reqwest::multipart::Form;
|
||||
use ::Result;
|
||||
use std::path::Path;
|
||||
use serde::de::{self, Deserialize, Deserializer, Unexpected};
|
||||
|
||||
/// A struct representing an Account.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
@@ -51,10 +52,35 @@ pub struct Account {
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Source {
|
||||
privacy: ::status_builder::Visibility,
|
||||
#[serde(deserialize_with = "string_or_bool")]
|
||||
sensitive: bool,
|
||||
note: String,
|
||||
}
|
||||
|
||||
fn string_or_bool<'de, D: Deserializer<'de>>(val: D)
|
||||
-> ::std::result::Result<bool, D::Error>
|
||||
{
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum BoolOrString {
|
||||
Bool(bool),
|
||||
Str(String),
|
||||
}
|
||||
|
||||
Ok(match BoolOrString::deserialize(val)? {
|
||||
BoolOrString::Bool(b) => b,
|
||||
BoolOrString::Str(ref s) => {
|
||||
if s == "true" {
|
||||
true
|
||||
} else if s == "false" {
|
||||
false
|
||||
} else {
|
||||
return Err(de::Error::invalid_value(Unexpected::Str(s), &"true or false"));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub struct CredientialsBuilder<'a> {
|
||||
display_name: Option<&'a str>,
|
||||
note: Option<&'a str>,
|
||||
|
||||
Reference in New Issue
Block a user