XML work
This commit is contained in:
parent
f8575ec041
commit
0971ef1260
20
Cargo.lock
generated
20
Cargo.lock
generated
|
@ -330,6 +330,12 @@ dependencies = [
|
||||||
"versioning",
|
"versioning",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simple_xml_serialize"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f8896c3696f051907ae5e59f0c2d9fb9f7521c29d636e4a1ea4ff0e4e5aac15"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "std"
|
name = "std"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -478,3 +484,17 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"logos",
|
"logos",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xml-builder"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "efc4f1a86af7800dfc4056c7833648ea4515ae21502060b5c98114d828f5333b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "xml_tests"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"simple_xml_serialize",
|
||||||
|
"xml-builder",
|
||||||
|
]
|
||||||
|
|
|
@ -35,7 +35,7 @@ members = [
|
||||||
"programs/table_view",
|
"programs/table_view",
|
||||||
"programs/undelete",
|
"programs/undelete",
|
||||||
"programs/wat2wasm",
|
"programs/wat2wasm",
|
||||||
|
"programs/xml_tests",
|
||||||
|
|
||||||
"programs/std_test",
|
"programs/std_test",
|
||||||
]
|
]
|
||||||
|
|
5
libraries/exi/assets/sample.xml
Normal file
5
libraries/exi/assets/sample.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<mouse last_updated="10:10:15.204">
|
||||||
|
<left_button pressed="True" just_pressed="False"/>
|
||||||
|
<right_button pressed="False" just_pressed="False"/>
|
||||||
|
<position x="0" y="0" x_change="-3" y_change="10"/>
|
||||||
|
</mouse>
|
|
@ -56,3 +56,32 @@ pub struct ExiHeader {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ExiDocument {}
|
pub struct ExiDocument {}
|
||||||
|
impl ExiDocument {
|
||||||
|
pub fn new_from_xml(xml_string: String) -> Self {
|
||||||
|
println!("{}", xml_string);
|
||||||
|
Self {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
mod unix {
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
io::Read,
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::ExiDocument;
|
||||||
|
fn parse_exi_from_file(path: &Path) -> ExiDocument {
|
||||||
|
let file_contents = fs::read_to_string(path).unwrap();
|
||||||
|
|
||||||
|
ExiDocument::new_from_xml(file_contents)
|
||||||
|
// ExiDocument {}
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_xml_to_exi() {
|
||||||
|
parse_exi_from_file(Path::new(
|
||||||
|
"/home/able/Projects/ableos_userland/libraries/exi/assets/sample.xml",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
programs/xml_tests/Cargo.toml
Normal file
10
programs/xml_tests/Cargo.toml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[package]
|
||||||
|
name = "xml_tests"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
simple_xml_serialize = "*"
|
||||||
|
xml-builder = "0.5.2"
|
28
programs/xml_tests/src/main.rs
Normal file
28
programs/xml_tests/src/main.rs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// use simple_xml_serialize::XMLElement;
|
||||||
|
|
||||||
|
// fn main() {
|
||||||
|
// let mut ele = XMLElement::new("mouse");
|
||||||
|
|
||||||
|
// println!("{}", ele);
|
||||||
|
// }
|
||||||
|
|
||||||
|
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut xml = XMLBuilder::new()
|
||||||
|
.version(XMLVersion::XML1_1)
|
||||||
|
.encoding("UTF-8".into())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let mut mouse = XMLElement::new("mouse");
|
||||||
|
mouse.add_attribute("x", "8");
|
||||||
|
mouse.add_attribute("y", "0");
|
||||||
|
mouse.add_attribute("y_change", "-1");
|
||||||
|
mouse.add_attribute("x_change", "1");
|
||||||
|
|
||||||
|
xml.set_root_element(mouse);
|
||||||
|
|
||||||
|
let mut writer: Vec<u8> = Vec::new();
|
||||||
|
xml.generate(&mut writer).unwrap();
|
||||||
|
println!("{}", String::from_utf8_lossy(&writer));
|
||||||
|
}
|
Loading…
Reference in a new issue