Skip to main content

post_archiver/
platform.rs

1use std::hash::Hash;
2
3use serde::{Deserialize, Serialize};
4
5#[cfg(feature = "typescript")]
6use ts_rs::TS;
7
8use crate::PlatformId;
9
10/// A platform that can be used to categorize posts
11///
12/// # Safety
13/// - Name must not be empty
14/// - Name should be kebab-case
15#[cfg_attr(feature = "typescript", derive(TS))]
16#[cfg_attr(feature = "typescript", ts(export))]
17#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
18pub struct Platform {
19    pub id: PlatformId,
20    pub name: String,
21}
22
23impl Platform {
24    pub const UNKNOWN: PlatformId = PlatformId(0);
25}
26
27#[cfg(feature = "utils")]
28mod definitions {
29    use crate::utils::macros::as_table;
30
31    use super::*;
32
33    as_table! {
34        "platforms" => Platform {
35            id: "id",
36            name: "name",
37        }
38    }
39}