pub struct Block {
pub id: BlockId,
pub document_id: DocumentId,
pub block_type: BlockType,
pub content: String,
pub span: Option<Span>,
pub pre: u32,
pub post: u32,
pub properties: Properties,
}Expand description
A single logical block extracted from a Markdown document.
§Interval Index
The pre and post fields implement the Nested Set / Pre-Post Order
interval index for the section hierarchy (defined by headings).
A block A is a descendant of block B iff:
B.pre < A.pre && A.post < B.postThis reduces ancestor/descendant checks to O(1) integer comparisons, eliminating recursive tree traversal entirely.
Fields§
§id: BlockId§document_id: DocumentId§block_type: BlockType§content: StringPlain-text content rendered from the block (without markup).
span: Option<Span>Source location (line/column, 1-based). None for synthetic blocks.
pre: u32Pre-order DFS number – left boundary of the section interval.
post: u32Post-order DFS number – right boundary of the section interval.
properties: PropertiesRow-polymorphic extra attributes; keyed by property name.
Implementations§
Source§impl Block
impl Block
Sourcepub fn contains(&self, other: &Block) -> bool
pub fn contains(&self, other: &Block) -> bool
Returns true if other is a descendant of self in the section
hierarchy (i.e. other is “under” self).
Uses the interval index for O(1) comparison.
Sourcepub fn is_under(&self, ancestor: &Block) -> bool
pub fn is_under(&self, ancestor: &Block) -> bool
Returns true if self is a descendant of ancestor.
Sourcepub fn is_under_interval(&self, anc_pre: u32, anc_post: u32) -> bool
pub fn is_under_interval(&self, anc_pre: u32, anc_post: u32) -> bool
Returns true if self falls within the given ancestor interval
(anc_pre, anc_post).
Sourcepub fn heading_depth(&self) -> Option<u8>
pub fn heading_depth(&self) -> Option<u8>
Heading depth (1–6), or None for non-heading blocks.
Trait Implementations§
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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