2020-02-11 10:01:39 +02:00
|
|
|
use serde::Serialize;
|
|
|
|
|
2019-12-04 09:55:03 +02:00
|
|
|
use crate::documents::BuildXML;
|
|
|
|
use crate::xml_builder::*;
|
|
|
|
|
2020-02-11 10:01:39 +02:00
|
|
|
#[derive(Serialize, Debug, Clone, PartialEq)]
|
2019-12-08 21:14:27 +02:00
|
|
|
pub struct BookmarkEnd {
|
2020-09-07 09:46:23 +03:00
|
|
|
pub id: usize,
|
2019-12-04 09:55:03 +02:00
|
|
|
}
|
|
|
|
|
2019-12-08 21:14:27 +02:00
|
|
|
impl BookmarkEnd {
|
2020-02-11 10:01:39 +02:00
|
|
|
pub fn new(id: usize) -> BookmarkEnd {
|
|
|
|
BookmarkEnd { id }
|
2019-12-04 09:55:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-08 21:14:27 +02:00
|
|
|
impl BuildXML for BookmarkEnd {
|
2019-12-04 09:55:03 +02:00
|
|
|
fn build(&self) -> Vec<u8> {
|
|
|
|
let b = XMLBuilder::new();
|
2020-02-11 10:01:39 +02:00
|
|
|
b.bookmark_end(&format!("{}", self.id)).build()
|
2019-12-04 09:55:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
#[cfg(test)]
|
|
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use std::str;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_bookmark_end() {
|
2020-02-11 10:01:39 +02:00
|
|
|
let c = BookmarkEnd::new(0);
|
2019-12-04 09:55:03 +02:00
|
|
|
let b = c.build();
|
2020-02-11 10:01:39 +02:00
|
|
|
assert_eq!(str::from_utf8(&b).unwrap(), r#"<w:bookmarkEnd w:id="0" />"#);
|
2019-12-04 09:55:03 +02:00
|
|
|
}
|
|
|
|
}
|