2020-02-11 10:01:39 +02:00
|
|
|
use serde::Serialize;
|
2024-11-05 04:22:32 +02:00
|
|
|
use std::io::Write;
|
2020-02-11 10:01:39 +02:00
|
|
|
|
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 {
|
2024-11-05 04:22:32 +02:00
|
|
|
fn build_to<W: Write>(
|
|
|
|
&self,
|
|
|
|
stream: xml::writer::EventWriter<W>,
|
|
|
|
) -> xml::writer::Result<xml::writer::EventWriter<W>> {
|
|
|
|
XMLBuilder::from(stream)
|
|
|
|
.bookmark_end(&self.id.to_string())?
|
|
|
|
.into_inner()
|
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
|
|
|
}
|
|
|
|
}
|