pub struct Body<'a> { /* private fields */ }Expand description
A document body: the bytes between a heading and EOT, or the inside of a nested level. Indexes files, groups, header rows and records once; everything it returns borrows the original buffer.
Records before the first GS of a file form an unnamed group; records and groups before the first FS form an unnamed file.
Implementations§
Source§impl<'a> Body<'a>
impl<'a> Body<'a>
Sourcepub fn slice(buf: &'a [u8], start: usize, stop: usize) -> Result<Self>
pub fn slice(buf: &'a [u8], start: usize, stop: usize) -> Result<Self>
Index buf[start..stop] as a body.
Sourcepub fn of_level(raw: &'a [u8]) -> Result<Self>
pub fn of_level(raw: &'a [u8]) -> Result<Self>
The contents of a nested level: raw is a unit holding DLE … CAN
(layout at its edges allowed).
Sourcepub fn files(&self) -> &[FileView<'a>]
pub fn files(&self) -> &[FileView<'a>]
The files of the body, in order. There is always at least one (the unnamed file, when the body has no FS).
Sourcepub fn groups(&self) -> impl Iterator<Item = &Group<'a>> + '_
pub fn groups(&self) -> impl Iterator<Item = &Group<'a>> + '_
All groups of all files, in order.
Sourcepub fn group_count(&self) -> usize
pub fn group_count(&self) -> usize
Groups of the first file.
Sourcepub fn group_by_name(&self, name: &str) -> Result<&Group<'a>>
pub fn group_by_name(&self, name: &str) -> Result<&Group<'a>>
The first file’s group named name.
Sourcepub fn group_names(&self) -> Vec<&'a [u8]>
pub fn group_names(&self) -> Vec<&'a [u8]>
Names of the first file’s groups.
Sourcepub fn records(&self) -> &[Record<'a>]
pub fn records(&self) -> &[Record<'a>]
Records of the body when it is a bare record stream (no FS, no GS): the unnamed group’s records.