mirror of
https://codeberg.org/postscriptum/snac2nex.git
synced 2026-03-31 21:25:28 +00:00
unify post type member name
This commit is contained in:
parent
abbb7f6986
commit
3aba70cb31
2 changed files with 6 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ mod tag;
|
|||
|
||||
use attachment::Attachment;
|
||||
use chrono::{DateTime, Utc};
|
||||
use ptype::Type;
|
||||
use ptype::Ptype;
|
||||
use serde::{Deserialize, de::Error};
|
||||
use std::str::FromStr;
|
||||
use tag::Tag;
|
||||
|
|
@ -13,7 +13,7 @@ use tag::Tag;
|
|||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Post {
|
||||
#[serde(rename = "type", deserialize_with = "ptype")]
|
||||
pub ptype: Type,
|
||||
pub ptype: Ptype,
|
||||
pub attachment: Option<Vec<Attachment>>,
|
||||
pub id: String,
|
||||
#[serde(default, deserialize_with = "time")]
|
||||
|
|
@ -27,13 +27,13 @@ pub struct Post {
|
|||
|
||||
impl Post {
|
||||
pub fn is_note(&self) -> bool {
|
||||
matches!(self.ptype, Type::Note)
|
||||
matches!(self.ptype, Ptype::Note)
|
||||
}
|
||||
}
|
||||
|
||||
fn ptype<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Type, D::Error> {
|
||||
fn ptype<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Ptype, D::Error> {
|
||||
if String::deserialize(d)?.to_lowercase() == "note" {
|
||||
return Ok(Type::Note);
|
||||
return Ok(Ptype::Note);
|
||||
}
|
||||
Err(D::Error::custom("Invalid post type"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#[derive(Debug)]
|
||||
pub enum Type {
|
||||
pub enum Ptype {
|
||||
Note,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue