#[non_exhaustive]pub enum PdfBlock {
Show 14 variants
Heading {
level: u8,
text: String,
source: SourceLocation,
},
Paragraph {
text: String,
source: SourceLocation,
},
List {
ordered: bool,
items: Vec<ListItem>,
source: SourceLocation,
},
Table {
headers: Vec<String>,
rows: Vec<Vec<String>>,
source: SourceLocation,
},
Image {
data: ImageData,
source: SourceLocation,
},
Code {
language: Option<String>,
text: String,
source: SourceLocation,
},
Formula {
latex: String,
source: SourceLocation,
},
PageBreak {
source: SourceLocation,
},
Footnote {
reference_id: String,
text: String,
source: SourceLocation,
},
TableCell {
row_span: u32,
col_span: u32,
text: String,
source: SourceLocation,
},
BlockQuote {
text: String,
source: SourceLocation,
},
HorizontalRule {
source: SourceLocation,
},
Link {
url: String,
text: String,
source: SourceLocation,
},
Unknown {
raw: String,
source: SourceLocation,
},
}Expand description
从 PDF 页面识别出的语义内容块。
#[non_exhaustive] 保证未来新增变体不会破坏下游代码。
消费方应始终包含通配分支(_ => ...)或使用 block_type
进行分发。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Heading
分级标题。
Paragraph
普通段落。
List
有序或无序列表。
Table
表格数据。
Image
图片引用。
Code
代码块。
Fields
§
source: SourceLocation源位置。
Formula
数学公式(LaTeX 语法)。
PageBreak
分页符。
Fields
§
source: SourceLocation源位置。
Footnote
脚注。
TableCell
表格单元格(细粒度识别)。
BlockQuote
引用块。
HorizontalRule
水平分隔线。
Fields
§
source: SourceLocation源位置。
Link
超链接。
Unknown
无法识别的内容。
Implementations§
Source§impl PdfBlock
impl PdfBlock
Sourcepub fn paragraph(text: impl Into<String>, source: SourceLocation) -> Self
pub fn paragraph(text: impl Into<String>, source: SourceLocation) -> Self
创建普通段落。
Sourcepub fn table(
headers: Vec<String>,
rows: Vec<Vec<String>>,
source: SourceLocation,
) -> Self
pub fn table( headers: Vec<String>, rows: Vec<Vec<String>>, source: SourceLocation, ) -> Self
创建表格。
Sourcepub fn image(data: ImageData, source: SourceLocation) -> Self
pub fn image(data: ImageData, source: SourceLocation) -> Self
创建图片引用。
Sourcepub fn code(text: impl Into<String>, source: SourceLocation) -> Self
pub fn code(text: impl Into<String>, source: SourceLocation) -> Self
创建代码块。
Sourcepub fn code_with_language(
language: impl Into<String>,
text: impl Into<String>,
source: SourceLocation,
) -> Self
pub fn code_with_language( language: impl Into<String>, text: impl Into<String>, source: SourceLocation, ) -> Self
创建带语言标识的代码块。
Sourcepub fn formula(latex: impl Into<String>, source: SourceLocation) -> Self
pub fn formula(latex: impl Into<String>, source: SourceLocation) -> Self
创建数学公式。
Sourcepub const fn page_break(source: SourceLocation) -> Self
pub const fn page_break(source: SourceLocation) -> Self
创建分页符。
Sourcepub fn footnote(
ref_id: impl Into<String>,
text: impl Into<String>,
source: SourceLocation,
) -> Self
pub fn footnote( ref_id: impl Into<String>, text: impl Into<String>, source: SourceLocation, ) -> Self
创建脚注。
Sourcepub fn table_cell(
row_span: u32,
col_span: u32,
text: impl Into<String>,
source: SourceLocation,
) -> Self
pub fn table_cell( row_span: u32, col_span: u32, text: impl Into<String>, source: SourceLocation, ) -> Self
创建表格单元格。
Sourcepub fn block_quote(text: impl Into<String>, source: SourceLocation) -> Self
pub fn block_quote(text: impl Into<String>, source: SourceLocation) -> Self
创建引用块。
Sourcepub const fn horizontal_rule(source: SourceLocation) -> Self
pub const fn horizontal_rule(source: SourceLocation) -> Self
创建水平分隔线。
Sourcepub fn link(
url: impl Into<String>,
text: impl Into<String>,
source: SourceLocation,
) -> Self
pub fn link( url: impl Into<String>, text: impl Into<String>, source: SourceLocation, ) -> Self
创建超链接。
Sourcepub fn unknown(raw: impl Into<String>, source: SourceLocation) -> Self
pub fn unknown(raw: impl Into<String>, source: SourceLocation) -> Self
创建无法识别的内容。
Sourcepub const fn source(&self) -> &SourceLocation
pub const fn source(&self) -> &SourceLocation
返回内容块的源位置。
Sourcepub const fn block_type(&self) -> PdfBlockType
pub const fn block_type(&self) -> PdfBlockType
返回内容块的语义分类。
§Examples
use easypdf_core::{PdfBlock, PdfBlockType, SourceLocation};
use easypdf_core::PageIndex;
let loc = SourceLocation::new(PageIndex::new(0), 1.0);
let block = PdfBlock::heading(1, "Title", loc);
assert_eq!(block.block_type(), PdfBlockType::Heading);Trait Implementations§
impl StructuralPartialEq for PdfBlock
Auto Trait Implementations§
impl Freeze for PdfBlock
impl RefUnwindSafe for PdfBlock
impl Send for PdfBlock
impl Sync for PdfBlock
impl Unpin for PdfBlock
impl UnsafeUnpin for PdfBlock
impl UnwindSafe for PdfBlock
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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> 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