pub struct Section {
pub heading: Heading,
pub content_start: usize,
pub content_end: usize,
pub parent_section: Option<usize>,
pub child_sections: Vec<usize>,
}Expand description
A section in a document, defined by a heading and its content range
Fields§
§heading: HeadingThe heading that starts this section
content_start: usizeStarting offset of the section content (after the heading)
content_end: usizeEnding offset of the section content (before next heading or end of document)
parent_section: Option<usize>Index of parent section in the sections array (None if root level)
child_sections: Vec<usize>Indices of child sections in the sections array
Implementations§
Source§impl Section
impl Section
Sourcepub fn new(heading: Heading, content_start: usize, content_end: usize) -> Self
pub fn new(heading: Heading, content_start: usize, content_end: usize) -> Self
Create a new section
Sourcepub fn content_length(&self) -> usize
pub fn content_length(&self) -> usize
Get the length of the section content in characters
Sourcepub fn contains_offset(&self, offset: usize) -> bool
pub fn contains_offset(&self, offset: usize) -> bool
Check if this section contains the given offset
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Check if this section has children
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Section
impl<'de> Deserialize<'de> for Section
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnsafeUnpin for Section
impl UnwindSafe for Section
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more