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
/// HTML that is safe to write into a page as it is: what `v-html` may render.
///
/// Implement it only for a type whose every value has already been made safe: the output of a
/// sanitiser, never a string that merely looks fine. [`BasicHtml`](crate::BasicHtml) and, with the
/// `ammonia` feature, `Sanitised` implement it; the guide's `escaping` page says how to choose.
///
/// # Example
///
/// ```
/// use ferrovue::{trusted_into, TrustedHtml};
///
/// /// HTML a sanitiser produced: the only way to make one is through it.
/// struct Sanitised(String);
///
/// impl Sanitised {
/// fn new(untrusted: &str) -> Self {
/// // A real project calls its sanitiser (ammonia, for example) here.
/// Sanitised(untrusted.replace('<', "<"))
/// }
/// }
///
/// impl TrustedHtml for Sanitised {
/// fn trusted_html(&self) -> &str {
/// &self.0
/// }
/// }
///
/// let mut out = String::new();
/// trusted_into(&mut out, &Sanitised::new("<script>"));
/// assert_eq!(out, "<script>");
/// ```
/// `v-html`: the value, unescaped. Only a [`TrustedHtml`] can reach it.