Skip to main content

Crate caj2pdf_core

Crate caj2pdf_core 

Source
Expand description

Platform-neutral, bounded I/O contracts for CAJ-family conversion.

Format implementations are separate from these contracts. A source must expose a stable size and positioned reads; the output is any std::io::Write, which receives bytes in order. Forward-only input must be spooled by a platform adapter or rejected explicitly.

Modules§

arith
Scaffolding shared by the T.82 QM decoder (crate::qm) and the T.88 MQ decoder (crate::jbig2::mq): the context bank, the coded span, the register snapshot, and the symbol counters. Each decoder keeps its own interval arithmetic and probability states and reads its coded bytes from a Payload in memory.
bundled_fonts
Shared defaults for versioned native-text font resources. Versioned CAJViewer font resource facts and measured native-text presets. Adapters supply the bytes; the core never downloads or opens files.
caj
Checked metadata reader for the observed CAJ\0 container variant.
hnc8
Bounded metadata traversal for the three independently measured HN/C8 container profiles. Image payloads and text are never loaded here. convert_document_pdf and convert_source_pages_pdf convert whole documents; type-0, JPEG and type-3 images are checked and emitted by the one shared composition pipeline. Composition validates the observed text frame while retaining only raw image-coordinate words. Empirical geometry remains diagnostic. Hnc8Reader::application_info reads the trailing C8 application-info package’s DOI, URL and note count.
jbig1
Bounded CAJ-family type-0 rows using the standard T.82 probability states.
jbig2
Bounded T.88 JBIG2 segment framing and arithmetic model primitives.
kdh
Ranged KDH decoding over the PDF input and repair layer.
native
A positioned source over a std::io handle.
pdf
Bounded PDF input, fragment repair, and forward-only PDF 1.7 output.
qm
Experimental, bounded T.82 arithmetic decoder for an already isolated SCD.

Structs§

Bookmark
One outline entry in document order.
ConversionOptions
What convert produces from a document.
ConversionReport
Counters and warnings from a completed conversion.
CountingSource
A RangedSource adapter that adds each count its source returns to a caller-owned byte counter.
Detection
A recognized input family and where its header starts.
DocumentInfo
Bounded summary returned by inspect.
Error
A failure visible to native and JavaScript callers: what went wrong, the absolute input offset and the structure it was found in, when known, and a fixed description.
Fonts
Font resources for native HN/C8 text.
ImageCounts
Images drawn by an HN/C8 conversion, by codec.
InspectOptions
What inspect reads besides the summary.
Limits
Resource limits applied before allocation and during I/O.
NeverCancel
A cancellation signal for operations that cannot be cancelled.
OmittedPage
A page whose content was replaced by an explicit blank page.
Payload
Bytes read into memory, with the source offset of their first byte.

Enums§

Context
The structure a failure was located in.
ErrorKind
What went wrong.
Hnc8Stage
The HN/C8 conversion stage a failure arose in.
InputFormat
Recognized input families. Recognition does not imply conversion support.
Structure
Structure-only document facts; never document text.
Type3Stage
The type-3 image decoding stage a failure arose in.

Constants§

DEFAULT_IO_CHUNK
Default payload per read or write call: 256 KiB.
FONTS_REQUIRE_HNC8
The reason of the error convert returns when Fonts are given for a document other than HN or C8.
MAX_IO_CHUNK
Hard payload ceiling per read or write call: 1 MiB.
PDF_HEADER_SEARCH_BYTES
Leading bytes searched for a %PDF- header that does not start at byte 0. The whole five-byte marker must lie within this prefix.
SIGNATURE_BYTES
Leading bytes that detect_format needs to recognize every signature that must start at byte 0.

Traits§

BookmarkVisitor
A recipient for streamed bookmark entries, called once per entry.
Cancellation
A platform-provided cancellation signal, checked between rows, pages and I/O chunks.
PageVisitor
A recipient for inspect_pages. An error it returns ends the report and is returned as it is.
Progress
What a facade operation tells its caller while it runs, and how the caller stops it. Every method has a default; NeverCancel uses them all.
RangedSource
A source with a stable size snapshot and positioned reads.

Functions§

convert
Convert one document to PDF bytes written to sink.
convert_with_ttkn_response
Convert the measured TTKN server-auth PDF profile using an explicit response. No authentication endpoint is contacted. The response is case-sensitive and is never included in errors. Other TTKN profiles remain unsupported. Atomic-output requirements are the same as for convert.
detect_format
Recognize an input family from its leading bytes, never from a file name: some observed .caj files are plain PDFs.
detect_source
Read the leading bytes of source and recognize its input family as detect_format does, also locating a displaced PDF header.
index_pdf
Index a PDF, whose %PDF- header may follow leading bytes, for crate::pdf::PdfOutlineAppender. Any other family is refused as by super::convert, after Progress::format names it.
inspect
Read bounded document metadata without writing or decoding any page.
inspect_pages
Stream one structural record per page of the HN/C8 document that info (from inspect) describes; image payloads and text content are never reported. Returns false without calling visitor when the family has no per-page records.
native_font_mode
Native rendering mode when the input needs fonts, otherwise None. Uses the same bounded routing as needs_fonts; does not read fonts.
needs_fonts
Whether convert would draw native text for this input and therefore needs Fonts: an HN or C8 document that crate::hnc8::uses_native_text routes to native composition. Other families, and empty or unrecognized inputs, need none; converting them reports their own errors. Only a failed read or cancellation is an error. Progress::format is not called.
read_exact_at
Fill one bounded buffer from a positioned source, tolerating short reads.
read_outline
The outline of a CAJ document, for an outline import. Any other family is refused as by super::convert, after Progress::format names it.
read_payload
Read length bytes at offset into buffer, replacing its contents, in requests of at most one I/O chunk. The length must fit limits.max_allocation_bytes; the buffer is reused between payloads.

Type Aliases§

Result