Skip to content

Commit

Permalink
Add #[serde(with)] to all time types.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Oct 7, 2024
1 parent 770a0e1 commit cb9d1d2
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions deepwell/src/services/blob/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub struct StartBlobUpload {
pub struct StartBlobUploadOutput {
pub pending_blob_id: String,
pub presign_url: String,

#[serde(with = "time::serde::rfc3339")]
pub expires_at: OffsetDateTime,
}

Expand Down Expand Up @@ -60,5 +62,7 @@ pub struct GetBlobOutput {
pub data: Vec<u8>,
pub mime: String,
pub size: i64,

#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
}
4 changes: 4 additions & 0 deletions deepwell/src/services/file/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ pub struct GetFileDetails<'a> {
#[derive(Serialize, Debug, Clone)]
pub struct GetFileOutput {
pub file_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub file_created_at: OffsetDateTime,
pub file_updated_at: Option<OffsetDateTime>,
pub file_deleted_at: Option<OffsetDateTime>,
pub page_id: i64,
pub revision_id: i64,
pub revision_type: FileRevisionType,

#[serde(with = "time::serde::rfc3339")]
pub revision_created_at: OffsetDateTime,
pub revision_number: i32,
pub revision_user_id: i64,
Expand Down
6 changes: 6 additions & 0 deletions deepwell/src/services/import/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use time::{Date, OffsetDateTime};
#[derive(Deserialize, Debug)]
pub struct ImportUser {
pub user_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
pub name: String,
pub slug: String,
Expand All @@ -40,6 +42,8 @@ pub struct ImportUser {
#[derive(Deserialize, Debug)]
pub struct ImportSite {
pub site_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
pub name: String,
pub slug: String,
Expand All @@ -50,6 +54,8 @@ pub struct ImportSite {
pub struct ImportPage {
pub page_id: i64,
pub site_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
pub slug: String,
pub locked: bool,
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/services/link/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub struct GetLinksExternalToOutput {

#[derive(Serialize, Debug, Clone)]
pub struct ToExternalLink {
#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
pub page_id: i64,
Expand Down
10 changes: 10 additions & 0 deletions deepwell/src/services/page/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub struct GetPageAnyDetails {
#[derive(Serialize, Debug, Clone)]
pub struct GetPageOutput {
pub page_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub page_created_at: OffsetDateTime,
pub page_updated_at: Option<OffsetDateTime>,
pub page_deleted_at: Option<OffsetDateTime>,
Expand All @@ -102,11 +104,15 @@ pub struct GetPageOutput {
pub discussion_thread_id: Option<i64>,
pub revision_id: i64,
pub revision_type: PageRevisionType,

#[serde(with = "time::serde::rfc3339")]
pub revision_created_at: OffsetDateTime,
pub revision_number: i32,
pub revision_user_id: i64,
pub wikitext: Option<String>,
pub compiled_html: Option<String>,

#[serde(with = "time::serde::rfc3339")]
pub compiled_at: OffsetDateTime,
pub compiled_generator: String,
pub revision_comments: String,
Expand All @@ -122,8 +128,12 @@ pub struct GetPageOutput {
#[derive(Serialize, Debug, Clone)]
pub struct GetDeletedPageOutput {
pub page_id: i64,

#[serde(with = "time::serde::rfc3339")]
pub page_created_at: OffsetDateTime,
pub page_updated_at: Option<OffsetDateTime>,

#[serde(with = "time::serde::rfc3339")]
pub page_deleted_at: OffsetDateTime,
pub page_revision_count: i32,
pub site_id: i64,
Expand Down
1 change: 1 addition & 0 deletions deepwell/src/services/page_query/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// TODO: add serde, include time fmt conversions
#![allow(dead_code)] // TEMP

use super::prelude::*;
Expand Down
4 changes: 4 additions & 0 deletions deepwell/src/services/page_revision/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ pub struct PageRevisionCountOutput {
pub struct PageRevisionModelFiltered {
pub revision_id: i64,
pub revision_type: PageRevisionType,

#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
pub updated_at: Option<OffsetDateTime>,
pub from_wikidot: bool,
Expand All @@ -168,6 +170,8 @@ pub struct PageRevisionModelFiltered {
pub changes: Vec<String>,
pub wikitext: Option<String>,
pub compiled_html: Option<String>,

#[serde(with = "time::serde::rfc3339")]
pub compiled_at: OffsetDateTime,
pub compiled_generator: String,
pub comments: Option<String>,
Expand Down
2 changes: 2 additions & 0 deletions deepwell/src/services/render/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub struct RenderOutput {
pub html_output: HtmlOutput,
pub errors: Vec<ParseError>,
pub compiled_hash: TextHash,

#[serde(with = "time::serde::rfc3339")]
pub compiled_at: OffsetDateTime,
pub compiled_generator: String,
}

0 comments on commit cb9d1d2

Please sign in to comment.