-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpost_statuses.rs
More file actions
68 lines (62 loc) · 2.04 KB
/
post_statuses.rs
File metadata and controls
68 lines (62 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt::Display};
use wp_contextual::WpContextual;
#[derive(Debug, Serialize, Deserialize, uniffi::Record, WpContextual)]
#[serde(transparent)]
pub struct SparsePostStatusesResponse {
#[WpContext(edit, embed, view)]
#[WpContextualField]
pub post_statuses: Option<HashMap<PostStatusSlug, SparsePostStatus>>,
}
#[derive(Debug, Serialize, Deserialize, uniffi::Record, WpContextual)]
pub struct SparsePostStatus {
/// The title for the status.
#[WpContext(edit, embed, view)]
pub name: Option<String>,
/// Whether posts with this status should be private.
#[WpContext(edit)]
pub private: Option<bool>,
/// Whether posts with this status should be protected.
#[WpContext(edit)]
pub protected: Option<bool>,
/// Whether posts of this status should be shown in the front end of the site.
#[WpContext(edit, view)]
pub public: Option<bool>,
/// Whether posts with this status should be publicly-queryable.
#[WpContext(edit, view)]
pub queryable: Option<bool>,
/// Whether to include posts in the edit listing for their post type.
#[WpContext(edit)]
pub show_in_list: Option<bool>,
/// An alphanumeric identifier for the status.
#[WpContext(edit, embed, view)]
pub slug: Option<String>,
/// Whether posts of this status may have floating published dates.
#[WpContext(edit, view)]
pub date_floating: Option<bool>,
}
#[derive(
Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, uniffi::Record,
)]
#[uniffi::export(Display)]
#[serde(transparent)]
pub struct PostStatusSlug {
pub slug: String,
}
impl PostStatusSlug {
pub fn new(name: String) -> Self {
Self { slug: name }
}
}
impl From<&str> for PostStatusSlug {
fn from(value: &str) -> Self {
Self {
slug: value.to_string(),
}
}
}
impl Display for PostStatusSlug {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.slug)
}
}