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
extern crate self as ftd_rt;
mod condition;
mod html;
mod ui;
#[cfg(feature = "wasm")]
mod wasm;
pub use condition::Condition;
pub use html::Node;
pub use ui::{
Align, Color, Column, Common, Container, Element, ExternalFont, FontDisplay, IFrame, Image,
Input, Length, NamedFont, Overflow, Region, Row, Style, Text, TextAlign, TextFormat,
};
#[derive(serde::Serialize, serde::Deserialize, Eq, PartialEq, Debug, Default, Clone)]
pub struct Rendered {
pub original: String,
pub rendered: String,
}
#[derive(thiserror::Error, Debug)]
pub enum Error {}
pub type Map = std::collections::BTreeMap<String, String>;
type Result<T> = std::result::Result<T, Error>;
#[derive(serde::Deserialize)]
#[cfg_attr(
not(feature = "wasm"),
derive(serde::Serialize, PartialEq, Debug, Default, Clone)
)]
pub struct Document {
pub tree: ftd_rt::Node,
pub data: ftd_rt::Map,
}
pub fn e<T, S>(_m: S) -> Result<T>
where
S: Into<String>,
{
todo!()
}
pub fn get_name<'a, 'b>(prefix: &'a str, s: &'b str) -> ftd_rt::Result<&'b str> {
match s.split_once(' ') {
Some((p1, p2)) => {
if p1 != prefix {
return ftd_rt::e(format!("must start with {}", prefix));
}
Ok(p2)
}
None => ftd_rt::e("' ' is missing".to_string()),
}
}
#[cfg(test)]
mod test {
#[test]
fn get_name() {
assert_eq!(super::get_name("fn", "fn foo").unwrap(), "foo")
}
}