use crate::basic_type::ST_Loc;
#[derive(Debug, Clone)]
pub struct DocBody {
pub doc_root: ST_Loc,
pub doc_info: Option<String>,
pub signatures: Option<ST_Loc>,
}
impl DocBody {
#[must_use]
pub fn new(doc_root: ST_Loc) -> Self {
Self {
doc_root,
doc_info: None,
signatures: None,
}
}
#[must_use]
pub fn doc_info(mut self, info: impl Into<String>) -> Self {
self.doc_info = Some(info.into());
self
}
#[must_use]
pub fn signatures(mut self, path: ST_Loc) -> Self {
self.signatures = Some(path);
self
}
#[must_use]
pub fn doc_root(&self) -> &ST_Loc {
&self.doc_root
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn doc_body_new() {
let db = DocBody::new(ST_Loc::new("Doc_0/Document.xml"));
assert_eq!(db.doc_root.loc(), "Doc_0/Document.xml");
assert!(db.doc_info.is_none());
assert!(db.signatures.is_none());
}
#[test]
fn doc_body_builder() {
let db = DocBody::new(ST_Loc::new("Doc_0/Document.xml"))
.doc_info("test info")
.signatures(ST_Loc::new("Doc_0/Signs/Signatures.xml"));
assert!(db.doc_info.is_some());
assert!(db.signatures.is_some());
}
#[test]
fn doc_body_clone_debug() {
let db = DocBody::new(ST_Loc::new("Doc_0/Document.xml"));
let db2 = db.clone();
assert_eq!(db2.doc_root.loc(), "Doc_0/Document.xml");
assert!(format!("{db:?}").contains("DocBody"));
}
}