Skip to main content

ewvx/
lib.rs

1//! Shared library for the EWVX (Ente Wurzel Video XML) format.
2//!
3//! Provides the canonical data types, a v2.0 XML writer, and a v2.0 XML parser
4//! used by both the `ewvx-converter` and `ewvx-player` binaries.
5
6/// Data types representing an EWVX file.
7pub mod types;
8
9/// Streaming XML writer for the EWVX v2.0 format.
10///
11/// # Example
12/// ```
13/// use ewvx::types::EwvxMeta;
14/// use ewvx::writer;
15///
16/// let meta = EwvxMeta {
17///     title: None, author: None, created: None, description: None,
18///     fps: 24.0, width: 100, height: 100,
19///     frame_count: 1, duration: 1.0 / 24.0, ente: true,
20/// };
21///
22/// let mut buf = Vec::new();
23/// writer::write_header(&mut buf, &meta).unwrap();
24/// writer::write_frame(&mut buf, 0, r#"<svg xmlns="http://www.w3.org/2000/svg"/>"#).unwrap();
25/// writer::write_frames_end(&mut buf).unwrap();
26/// writer::write_end(&mut buf).unwrap();
27///
28/// let output = String::from_utf8(buf).unwrap();
29/// assert!(output.contains(r#"version="2.0""#));
30/// assert!(output.contains(r#"<frame index="0">"#));
31/// ```
32pub mod writer;
33
34/// XML parser for the EWVX v2.0 format.
35///
36/// # Example
37/// ```
38/// use ewvx::parser;
39///
40/// let xml = r#"<?xml version="1.0" encoding="UTF-8"?>
41/// <video version="2.0" xmlns="ente-schema:ewvx:2.0">
42///   <meta-ente>
43///     <fps>24.000000</fps>
44///     <width>100</width>
45///     <height>100</height>
46///     <frame-count>1</frame-count>
47///     <duration>0.041667</duration>
48///     <ente>true</ente>
49///   </meta-ente>
50///   <frames>
51///     <frame index="0">
52///       <svg xmlns="http://www.w3.org/2000/svg"/>
53///     </frame>
54///   </frames>
55/// </video>"#;
56///
57/// let data = parser::parse(xml).unwrap();
58/// assert_eq!(data.meta.fps, 24.0);
59/// assert_eq!(data.meta.width, 100);
60/// assert_eq!(data.frames.len(), 1);
61/// assert_eq!(data.frames[0].index, 0);
62/// assert!(data.audio.is_empty());
63/// ```
64pub mod parser;