Skip to content

Commit

Permalink
Cleanup, remove DateOfBirth struct in favor of timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
novacrazy committed Dec 16, 2023
1 parent 8271b8c commit dfbf2b5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/api/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,11 @@ macro_rules! command {
}
}

$(#[$($meta)*])*
#[derive(Debug)]
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
$(#[$($meta)*])*
pub struct $name {
$($(#[$($field_meta)*])* $field_vis $field_name: $field_ty, )*

Expand All @@ -419,11 +419,11 @@ macro_rules! command {
}

$(
$(#[$body_meta])*
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
$(#[$body_meta])*
pub struct $body_name {
$( $(#[$($body_field_meta)*])* $body_field_vis $body_field_name: $body_field_ty ),*
}
Expand Down
1 change: 1 addition & 0 deletions src/api/commands/party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ command! {
;
#[derive(Default, PartialEq)]
#[cfg_attr(feature = "builder", derive(typed_builder::TypedBuilder))]
#[cfg_attr(feature = "rkyv", archive(compare(PartialEq)))]
struct PatchPartyForm {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "builder", builder(default, setter(into)))]
Expand Down
3 changes: 1 addition & 2 deletions src/api/commands/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ command! {
#[cfg_attr(feature = "builder", builder(setter(into)))]
pub password: SmolStr,

#[serde(flatten)]
pub dob: DateOfBirth,
pub dob: Timestamp,

/// hCaptcha token
pub token: String, // TODO: Don't allocate?
Expand Down
29 changes: 0 additions & 29 deletions src/models/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,6 @@ impl UserFlags {
pub const SYSTEM_USER: UserFlags = UserFlags::empty().with_elevation(ElevationLevel::System).union(UserFlags::VERIFIED);
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
pub struct DateOfBirth {
pub year: i32,
pub month: u8,
pub day: u8,
}

impl From<time::Date> for DateOfBirth {
fn from(d: time::Date) -> Self {
let (year, month, day) = d.to_calendar_date();
DateOfBirth {
year,
month: month as u8,
day,
}
}
}

impl TryFrom<DateOfBirth> for time::Date {
type Error = time::error::ComponentRange;

fn try_from(d: DateOfBirth) -> Result<Self, Self::Error> {
time::Date::from_calendar_date(d.year, time::Month::try_from(d.month)?, d.day)
}
}

bitflags::bitflags! {
#[derive(Default)]
pub struct UserProfileBits: i32 {
Expand Down

0 comments on commit dfbf2b5

Please sign in to comment.