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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use crate::parsoid::{ImmutableWikicode, Wikicode};
use mwapi_responses::timestamp::Timestamp;
use serde::Deserialize;
pub struct SaveOptions {
pub(crate) summary: String,
pub(crate) mark_as_bot: Option<bool>,
pub(crate) tags: Vec<String>,
}
impl SaveOptions {
pub fn summary(summary: &str) -> Self {
Self {
summary: summary.to_string(),
mark_as_bot: None,
tags: vec![],
}
}
pub fn set_summary(mut self, summary: &str) -> Self {
self.summary = summary.to_string();
self
}
pub fn mark_as_bot(mut self, mark: bool) -> Self {
self.mark_as_bot = Some(mark);
self
}
pub fn add_tag(mut self, tag: &str) -> Self {
self.tags.push(tag.to_string());
self
}
}
pub enum Saveable {
Wikitext(String),
Html(ImmutableWikicode),
}
impl From<String> for Saveable {
fn from(wikitext: String) -> Self {
Self::Wikitext(wikitext)
}
}
impl From<&str> for Saveable {
fn from(wikitext: &str) -> Self {
Self::Wikitext(wikitext.to_string())
}
}
impl From<&String> for Saveable {
fn from(wikitext: &String) -> Self {
Self::Wikitext(wikitext.to_string())
}
}
impl From<Wikicode> for Saveable {
fn from(html: Wikicode) -> Self {
html.into_immutable().into()
}
}
impl From<ImmutableWikicode> for Saveable {
fn from(html: ImmutableWikicode) -> Self {
Self::Html(html)
}
}
#[derive(Deserialize, Clone, Debug)]
pub struct EditResponse {
pub contentmodel: String,
pub newrevid: Option<u64>,
pub newtimestamp: Option<Timestamp>,
pub oldrevid: Option<u64>,
#[serde(default)]
pub nochange: bool,
#[serde(default)]
pub new: bool,
pub pageid: u32,
pub result: String,
pub title: String,
}