Skip to main content

vmix_core/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4
5pub mod models;
6
7// Re-export for convenience
8pub use models::*;
9
10// XML parsing features (optional)
11#[cfg(feature = "xml")]
12pub use quick_xml;
13
14#[cfg(feature = "xml")]
15/// Parse XML string into Vmix structure
16///
17/// # Examples
18///
19/// ```ignore
20/// use vmix_core::{Vmix, from_str};
21///
22/// let xml = r#"<vmix><version>1.0</version>...</vmix>"#;
23/// let vmix: Vmix = from_str(xml)?;
24/// ```
25pub fn from_str(s: &str) -> Result<Vmix, quick_xml::DeError> {
26    quick_xml::de::from_str(s)
27}
28
29#[cfg(feature = "xml")]
30/// Serialize Vmix structure to XML string
31///
32/// # Examples
33///
34/// ```ignore
35/// use vmix_core::{Vmix, to_string};
36///
37/// let vmix = Vmix { /* ... */ };
38/// let xml = to_string(&vmix)?;
39/// ```
40pub fn to_string(vmix: &Vmix) -> Result<alloc::string::String, quick_xml::DeError> {
41    quick_xml::se::to_string(vmix)
42}