wp_mini/field/part_stub_field.rs
1use crate::field::text_url_field::TextUrlField;
2use crate::field::{AuthRequiredFields, DefaultableFields};
3use crate::impl_field_display;
4use strum_macros::AsRefStr;
5
6/// Represents the fields for a `PartStub` object.
7///
8/// A `PartStub` is typically a lightweight or summary representation of a story part,
9/// often used when a full `Part` object is not required.
10#[derive(Debug, Clone, AsRefStr, PartialEq, Eq, Ord, PartialOrd, Hash)]
11#[strum(serialize_all = "camelCase")]
12pub enum PartStubField {
13 /// The unique numerical identifier of the story part.
14 Id,
15 /// The title of the story part.
16 Title,
17 /// A direct URL to the story part on the Wattpad website.
18 Url,
19
20 /// A complex field for URLs related to the part's text content, with selectable sub-fields.
21 #[strum(disabled)]
22 TextUrl(Vec<TextUrlField>),
23
24 /// The content rating of the story part.
25 Rating,
26 /// A boolean flag indicating whether the part is a draft.
27 Draft,
28 /// The timestamp when the part was created.
29 CreateDate,
30 /// The timestamp when the part was last modified.
31 ModifyDate,
32 /// A boolean flag indicating if the part contains images that have been banned.
33 HasBannedImages,
34 /// The length of the story part, often representing an estimated reading time in seconds.
35 Length,
36 /// The ID of any video associated with the part.
37 VideoId,
38 /// The URL for the part's cover image.
39 PhotoUrl,
40 /// The total number of comments on the part.
41 CommentCount,
42 /// The total number of votes the part has received.
43 VoteCount,
44 /// The total number of reads the part has received.
45 ReadCount,
46
47 /// A boolean flag indicating if the currently authenticated user has voted for this part.
48 /// **Requires authentication.**
49 Voted,
50 /// A boolean flag indicating whether the part has been deleted.
51 Deleted,
52}
53
54impl_field_display!(
55 PartStubField,
56 TextUrl => "text_url"
57);
58
59impl AuthRequiredFields for PartStubField {
60 fn auth_required_fields() -> Vec<Self> {
61 vec![Self::Voted]
62 }
63}
64
65impl DefaultableFields for PartStubField {
66 fn default_fields() -> Vec<Self> {
67 vec![
68 Self::Id,
69 Self::Title,
70 Self::TextUrl(vec![TextUrlField::Text]),
71 Self::Rating,
72 Self::VideoId,
73 Self::PhotoUrl,
74 Self::ModifyDate,
75 ]
76 }
77}