2022-10-28 04:58:47 +00:00
|
|
|
use crate::arena::ElementId;
|
2021-08-22 21:08:25 +00:00
|
|
|
|
2022-10-28 04:58:47 +00:00
|
|
|
pub struct Renderer<'a> {
|
|
|
|
mutations: Vec<Mutation<'a>>,
|
|
|
|
}
|
2022-10-20 16:56:09 +00:00
|
|
|
|
2022-10-28 04:58:47 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Mutation<'a> {
|
|
|
|
SetAttribute {
|
2022-10-22 01:54:14 +00:00
|
|
|
name: &'static str,
|
2022-10-28 04:58:47 +00:00
|
|
|
value: &'a str,
|
|
|
|
id: ElementId,
|
|
|
|
},
|
2022-10-20 16:56:09 +00:00
|
|
|
|
2022-10-28 04:58:47 +00:00
|
|
|
LoadTemplate {
|
|
|
|
name: &'static str,
|
|
|
|
index: usize,
|
|
|
|
},
|
|
|
|
|
2022-11-02 01:42:29 +00:00
|
|
|
SaveTemplate {
|
|
|
|
name: &'static str,
|
|
|
|
m: usize,
|
|
|
|
},
|
|
|
|
|
2022-10-28 04:58:47 +00:00
|
|
|
HydrateText {
|
|
|
|
path: &'static [u8],
|
|
|
|
value: &'a str,
|
|
|
|
id: ElementId,
|
|
|
|
},
|
|
|
|
|
|
|
|
SetText {
|
|
|
|
value: &'a str,
|
|
|
|
id: ElementId,
|
|
|
|
},
|
|
|
|
|
|
|
|
ReplacePlaceholder {
|
2022-11-02 01:42:29 +00:00
|
|
|
m: usize,
|
2022-11-02 08:00:37 +00:00
|
|
|
path: &'static [u8],
|
2022-10-28 04:58:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
AssignId {
|
|
|
|
path: &'static [u8],
|
|
|
|
id: ElementId,
|
|
|
|
},
|
|
|
|
|
|
|
|
// Take the current element and replace it with the element with the given id.
|
|
|
|
Replace {
|
|
|
|
id: ElementId,
|
|
|
|
},
|
2022-11-02 01:42:29 +00:00
|
|
|
|
|
|
|
CreateElement {
|
|
|
|
name: &'a str,
|
|
|
|
namespace: Option<&'a str>,
|
|
|
|
id: ElementId,
|
|
|
|
},
|
|
|
|
|
|
|
|
CreateText {
|
|
|
|
value: &'a str,
|
|
|
|
},
|
|
|
|
|
|
|
|
CreatePlaceholder,
|
|
|
|
|
|
|
|
AppendChildren {
|
|
|
|
m: usize,
|
|
|
|
},
|
2021-08-22 21:08:25 +00:00
|
|
|
}
|