Skip to main content

Document

Struct Document 

Source
pub struct Document { /* private fields */ }
Expand description

A complete TaskPaper doing file represented as an ordered list of sections.

The document preserves section ordering from the original file and can track non-entry content at the top and bottom of the file for round-trip fidelity.

Implementations§

Source§

impl Document

Source

pub fn create_file(path: &Path, default_section: &str) -> Result<()>

Create a new doing file at path with a single default section.

If the file already exists and is non-empty, this is a no-op. Creates parent directories as needed.

Source

pub fn new() -> Self

Create a new empty document.

Source

pub fn parse(content: &str) -> Self

Parse a doing file string into a structured Document.

Source

pub fn add_section(&mut self, section: Section)

Add a section to the document. Does nothing if a section with the same name (case-insensitive) already exists.

Source

pub fn all_entries(&self) -> Vec<&Entry>

Return all entries across all sections.

Source

pub fn dedup(&mut self)

Deduplicate entries across all sections by ID, keeping the first occurrence.

Source

pub fn entries_in_section(&self, name: &str) -> Vec<&Entry>

Return entries from a specific section by name (case-insensitive). If name is “all” (case-insensitive), returns entries from all sections.

Source

pub fn has_section(&self, name: &str) -> bool

Return true if a section with the given name exists (case-insensitive).

Source

pub fn is_empty(&self) -> bool

Return true if the document has no sections.

Source

pub fn len(&self) -> usize

Return the number of sections in the document.

Source

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

Return non-entry content from the bottom of the file.

Source

pub fn other_content_bottom_mut(&mut self) -> &mut Vec<String>

Return a mutable reference to non-entry content from the bottom of the file.

Source

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

Return non-entry content from the top of the file.

Source

pub fn other_content_top_mut(&mut self) -> &mut Vec<String>

Return a mutable reference to non-entry content from the top of the file.

Source

pub fn remove_section(&mut self, name: &str) -> usize

Remove a section by name (case-insensitive), returning the number removed.

Source

pub fn section_by_name(&self, name: &str) -> Option<&Section>

Look up a section by name (case-insensitive).

Source

pub fn section_by_name_mut(&mut self, name: &str) -> Option<&mut Section>

Look up a mutable section by name (case-insensitive).

Source

pub fn sections(&self) -> &[Section]

Return a slice of all sections.

Source

pub fn sections_mut(&mut self) -> &mut Vec<Section>

Return a mutable reference to all sections.

Source

pub fn sort_entries(&mut self, reverse: bool)

Sort entries within each section by date then title, in ascending order. If reverse is true, sort in descending order.

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Document

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Document

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Format as a complete TaskPaper doing file.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.