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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
use crate::documents::BuildXML; use crate::xml_builder::*; #[derive(Debug)] pub struct Rels {} impl Rels { pub fn new() -> Rels { Default::default() } } impl Default for Rels { fn default() -> Self { Rels {} } } impl BuildXML for Rels { fn build(&self) -> Vec<u8> { let b = XMLBuilder::new(); b.declaration(None) .open_relationships("http://schemas.openxmlformats.org/package/2006/relationships") .relationship( "rId1", "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", "docProps/core.xml" ) .relationship( "rId2", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", "docProps/app.xml" ) .relationship( "rId3", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "word/document.xml" ) .close() .build() } } #[cfg(test)] mod tests { use super::*; #[cfg(test)] use pretty_assertions::assert_eq; use std::str; #[test] fn test_build() { let c = Rels::new(); let b = c.build(); assert_eq!( str::from_utf8(&b).unwrap(), r#"<?xml version="1.0" encoding="UTF-8"?> <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"> <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" /> <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" /> <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /> </Relationships>"# ); } }