Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize serialization #5

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
profile = "default"
channel = "nightly-2023-12-27"
4 changes: 1 addition & 3 deletions src/api/fav/get_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ use serde::{Deserialize, Serialize};
use std::ops::ControlFlow;

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct FavEntry {
#[serde(rename = "Title")]
pub title: String,
#[serde(rename = "LinkUrl")]
pub url: String,
#[serde(rename = "Summary")]
pub summary: String,
#[serde(rename = "Tags")]
pub tags: Vec<String>,
#[serde(rename = "DateAdded")]
pub create_time: String,
Expand Down
8 changes: 1 addition & 7 deletions src/api/ing/get_comment_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct IngCommentEntry {
#[serde(rename = "Id")]
pub id: usize,
#[serde(rename = "Content")]
pub content: String,
#[serde(rename = "DateAdded")]
pub create_time: String,
#[serde(rename = "StatusId")]
pub status_id: usize,
#[serde(rename = "UserAlias")]
pub user_alias: String,
#[serde(rename = "UserDisplayName")]
pub user_name: String,
#[serde(rename = "UserIconUrl")]
pub user_icon_url: String,
#[serde(rename = "UserId")]
pub user_id: usize,
#[serde(rename = "UserGuid")]
pub user_guid: String,
}

Expand Down
11 changes: 1 addition & 10 deletions src/api/ing/get_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,21 @@ use serde::{Deserialize, Serialize};
use std::ops::ControlFlow;

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct IngEntry {
#[serde(rename = "Id")]
pub id: usize,
#[serde(rename = "Content")]
pub content: String,
#[serde(rename = "IsPrivate")]
pub is_private: bool,
#[serde(rename = "IsLucky")]
pub is_lucky: bool,
#[serde(rename = "CommentCount")]
pub comment_count: usize,
#[serde(rename = "DateAdded")]
pub create_time: String,
#[serde(rename = "UserAlias")]
pub user_alias: String,
#[serde(rename = "UserDisplayName")]
pub user_name: String,
#[serde(rename = "UserIconUrl")]
pub user_icon_url: String,
#[serde(rename = "UserId")]
pub user_id: usize,
#[serde(rename = "UserGuid")]
pub user_guid: String,
#[serde(rename = "SendFrom")]
pub send_from: IngSendFrom,
#[serde(rename = "Icons")]
pub icons: String,
Expand Down
8 changes: 1 addition & 7 deletions src/api/news/get_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct NewsEntry {
#[serde(rename = "Id")]
pub id: usize,
#[serde(rename = "Title")]
pub title: String,
#[serde(rename = "Summary")]
pub summary: String,
#[serde(rename = "TopicId")]
pub topic_id: usize,
#[serde(rename = "TopicIcon")]
pub topic_icon_url: Option<String>,
#[serde(rename = "ViewCount")]
pub view_count: usize,
#[serde(rename = "CommentCount")]
pub comment_count: usize,
#[serde(rename = "DiggCount")]
pub digg_count: usize,
#[serde(rename = "DateAdded")]
pub create_time: String,
Expand Down
3 changes: 1 addition & 2 deletions src/api/post/get_comment_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct PostCommentEntry {
#[serde(rename = "Id")]
pub id: usize,
#[serde(rename = "Body")]
pub content: String,
Expand All @@ -19,7 +19,6 @@ pub struct PostCommentEntry {
pub user_home_url: String,
#[serde(rename = "FaceUrl")]
pub avatar_url: String,
#[serde(rename = "Floor")]
pub floor: usize,
#[serde(rename = "DateAdded")]
pub create_time: String,
Expand Down
4 changes: 1 addition & 3 deletions src/api/post/get_one.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde_json::Value;

// TODO: not elegant
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct PostEntry {
pub id: usize,
pub title: String,
Expand All @@ -19,11 +20,8 @@ pub struct PostEntry {
#[serde(rename = "dateUpdated")]
pub modify_time: String,

#[serde(rename = "isDraft")]
pub is_draft: bool,
#[serde(rename = "isPinned")]
pub is_pinned: bool,
#[serde(rename = "isPublished")]
pub is_published: bool,

// WRN:
Expand Down
11 changes: 1 addition & 10 deletions src/api/user/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,21 @@ use anyhow::Result;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "PascalCase")]
pub struct UserInfo {
#[serde(rename = "UserId")]
pub user_id: String,
#[serde(rename = "SpaceUserID")]
pub space_user_id: usize,
#[serde(rename = "BlogId")]
pub blog_id: usize,
#[serde(rename = "DisplayName")]
pub display_name: String,
#[serde(rename = "Face")]
pub face: String,
#[serde(rename = "Avatar")]
pub avatar: String,
#[serde(rename = "Seniority")]
pub seniority: String,
#[serde(rename = "BlogApp")]
pub blog_app: String,
#[serde(rename = "FollowingCount")]
pub following_count: usize,
#[serde(rename = "FollowerCount")]
pub followers_count: usize,
#[serde(rename = "IsVip")]
pub is_vip: bool,
#[serde(rename = "Joined")]
pub joined: String,
}

Expand Down
Loading