Skip to main content

Body

Struct Body 

Source
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. 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>

Source

pub fn new(buf: &'a [u8]) -> Result<Self>

Parse a whole buffer as a body (no SYN, no EOT).

Source

pub fn slice(buf: &'a [u8], start: usize, stop: usize) -> Result<Self>

Parse buf[start..stop] as a body.

Source

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).

Source

pub fn buf(&self) -> &'a [u8] ⓘ

The buffer the body indexes.

Source

pub fn start(&self) -> usize

Offset of the body’s first byte in the buffer.

Source

pub fn stop(&self) -> usize

Offset just past the body in the buffer.

Source

pub fn raw(&self) -> &'a [u8] ⓘ

The body’s bytes.

Source

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).

Source

pub fn groups(&self) -> impl Iterator<Item = &Group<'a>> + '_

All groups of all files, in order.

Source

pub fn group_count(&self) -> usize

Groups of the first file.

Source

pub fn group(&self, i: usize) -> &Group<'a>

Group i of the first file.

Source

pub fn group_by_name(&self, name: &str) -> Result<&Group<'a>>

The first file’s group named name.

Source

pub fn group_names(&self) -> Vec<&'a [u8]>

Names of the first file’s groups.

Source

pub fn name(&self) -> &'a [u8] ⓘ

Name of the first file (empty when the body has no FS).

Source

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.

Source

pub fn record_count(&self) -> usize

Source

pub fn record(&self, i: usize) -> Record<'a>

Source

pub fn bare(&self) -> bool

Whether the body is just records: one unnamed file, at most one unnamed group.

Auto Trait Implementations§

§

impl<'a> Forget for Body<'a>

§

impl<'a> Freeze for Body<'a>

§

impl<'a> Move for Body<'a>

§

impl<'a> RefUnwindSafe for Body<'a>

§

impl<'a> Send for Body<'a>

§

impl<'a> Sync for Body<'a>

§

impl<'a> Unpin for Body<'a>

§

impl<'a> UnsafeUnpin for Body<'a>

§

impl<'a> UnwindSafe for Body<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.