pub struct Document {
pub package: Package,
pub content: Element,
pub styles_part: Option<Element>,
pub styles: Styles,
pub meta: Meta,
}Expand description
A document read from a package: everything the three formats share.
Fields§
§package: PackageThe package itself, which keeps every entry whether or not it was read here, so that writing gives back a document and not a subset of one.
content: ElementThe parsed content.xml.
styles_part: Option<Element>The parsed styles.xml, if the package has one.
styles: StylesEvery style in the document, from both parts.
meta: MetaWhat the document says about itself.
Implementations§
Source§impl Document
impl Document
Sourcepub fn read(
bytes: &[u8],
wanted: &'static [&'static str],
) -> Result<Self, Error>
pub fn read( bytes: &[u8], wanted: &'static [&'static str], ) -> Result<Self, Error>
Read a package and check its media type.
§Errors
The bytes are not a package, the package declares a different media type,
or content.xml is absent or not well formed.
Sourcepub fn body(&self) -> Option<&Element>
pub fn body(&self) -> Option<&Element>
The office:body element, which every format has exactly one of.
Sourcepub fn body_of(&self, local: &str) -> Option<&Element>
pub fn body_of(&self, local: &str) -> Option<&Element>
The part of the body this format keeps its content in: office:text,
office:spreadsheet or office:presentation.
Sourcepub fn version(&self) -> Option<&str>
pub fn version(&self) -> Option<&str>
The version of the format the document declares, as office:version.
Sourcepub fn picture(&self, href: &str) -> Option<&[u8]>
pub fn picture(&self, href: &str) -> Option<&[u8]>
The bytes of a picture, by the xlink:href that referred to it.
A href that names an entry of the package gives those bytes. A href that
is a URL to somewhere else gives None: reaching it would be a network
request, which nothing in this suite makes.