Skip to main content

Document

Struct Document 

Source
pub struct Document<'a> { /* private fields */ }
Expand description

One C0DATA document: an optional SYN heading, a body, an optional EOT. Document::new reads the first document in a buffer; use Container for a buffer holding several documents or an EM tail.

Implementations§

Source§

impl<'a> Document<'a>

Source

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

Read the document at the start of buf.

Source

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

Read the document starting at start.

Source

pub fn heading(&self) -> &Heading<'a>

Source

pub fn body(&self) -> &Body<'a>

Source

pub fn start(&self) -> usize

Offset where the document begins.

Source

pub fn stop(&self) -> usize

Offset just past EOT (or past the body when there is none).

Source

pub fn has_syn(&self) -> bool

Source

pub fn has_eot(&self) -> bool

Source

pub fn warnings(&self) -> &[String]

Loud and ordinary warnings met while reading; never an error.

Source

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

The document’s bytes.

Source

pub fn shape(&self) -> Option<&str>

Source

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

Source

pub fn files(&self) -> &[FileView<'a>]

Source

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

Source

pub fn group_count(&self) -> usize

Source

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

Source

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

Source

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

Source

pub fn records(&self) -> &[Record<'a>]

Auto Trait Implementations§

§

impl<'a> Forget for Document<'a>

§

impl<'a> Freeze for Document<'a>

§

impl<'a> RefUnwindSafe for Document<'a>

§

impl<'a> Send for Document<'a>

§

impl<'a> Sync for Document<'a>

§

impl<'a> Unpin for Document<'a>

§

impl<'a> UnsafeUnpin for Document<'a>

§

impl<'a> UnwindSafe for Document<'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.