Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::GzipDocumentProvider Class Referencefinal

Optional gzip-only source with bounded RAM checkpoints and cancellable replay. Logical offsets are decompressed byte offsets. Exact logical extent is unknown until every concatenated member and physical EOF have been validated. Gzip headers, CRC/ISIZE, truncation and trailing garbage are checked strictly. Previously returned bytes can precede a later member-integrity error; they do not prove whole-archive validity. A failing read publishes none of that call's partial output, and never reports clean EOF. More...

#include <gzip_document.hpp>

Inheritance diagram for portals::GzipDocumentProvider:
portals::GzipDocumentProviderportals::GzipDocumentProvider portals::ByteDocumentProvider

Public Member Functions

 ~GzipDocumentProvider () override
 Release all states before their allocator/root owners.
ByteDocumentCapabilities capabilities () const noexcept override
std::size_t pinnedBudgetBytes (const SourceBudget &root) const noexcept override
bool tryReleaseOptionalStorage () noexcept override
std::expected< ByteDocumentMetadata, DocumentError > metadata (std::stop_token stop) override
std::expected< ByteDocumentMetadata, DocumentError > discoverExtent (std::stop_token stop) override
std::expected< ByteReadResult, DocumentError > read (const ByteReadCommand &command, std::span< std::byte > destination, std::stop_token stop) override
Public Member Functions inherited from portals::ByteDocumentProvider
virtual ~ByteDocumentProvider ()=default
 Safe final destruction after worker release.
virtual std::expected< std::unique_ptr< ByteDocumentReadSession >, DocumentError > openReadSession (std::stop_token stop)

Static Public Member Functions

static std::expected< std::shared_ptr< GzipDocumentProvider >, DocumentError > create (std::shared_ptr< ByteDocumentProvider > compressed, std::shared_ptr< SourceBudget > budget, GzipDocumentOptions options={})

Detailed Description

Optional gzip-only source with bounded RAM checkpoints and cancellable replay. Logical offsets are decompressed byte offsets. Exact logical extent is unknown until every concatenated member and physical EOF have been validated. Gzip headers, CRC/ISIZE, truncation and trailing garbage are checked strictly. Previously returned bytes can precede a later member-integrity error; they do not prove whole-archive validity. A failing read publishes none of that call's partial output, and never reports clean EOF.

One provider serializes its operations. Do not concurrently access the same compressed provider through other wrappers; share this gzip provider instead. The first observed compressed revision is frozen. A change requires a new adapter; live compressed append/follow mode and disk caching are not provided. Cold seeks can replay from the beginning and occupy a worker for a long time. Cancellation is checked between bounded inflate/I/O quanta; a mutex wait or an underlying blocking read cannot be forcibly interrupted by this adapter.

Member Function Documentation

◆ capabilities()

ByteDocumentCapabilities portals::GzipDocumentProvider::capabilities ( ) const
overridevirtualnoexcept
Returns
Seekable, frozen logical revision.

Implements portals::ByteDocumentProvider.

◆ create()

std::expected< std::shared_ptr< GzipDocumentProvider >, DocumentError > portals::GzipDocumentProvider::create ( std::shared_ptr< ByteDocumentProvider > compressed,
std::shared_ptr< SourceBudget > budget,
GzipDocumentOptions options = {} )
static
Parameters
compressedSeekable compressed provider retained by the adapter.
budgetThe same root subsequently used by ByteDocumentSource/views.
optionsBounded workspace, checkpoints, replay and header limits.
Returns
Cold adapter without metadata/read/file I/O, or typed failure. All adapter-owned buffers and zlib allocations are charged to budget.

◆ discoverExtent()

std::expected< ByteDocumentMetadata, DocumentError > portals::GzipDocumentProvider::discoverExtent ( std::stop_token stop)
overridevirtual
Parameters
stopCooperative cancellation between bounded inflate/input quanta.
Returns
Frozen revision and validated logical extent after all members and physical EOF, or a typed failure. May replay the compressed source to EOF; decoded output is discarded in bounded storage without text layout.

Reimplemented from portals::ByteDocumentProvider.

◆ metadata()

std::expected< ByteDocumentMetadata, DocumentError > portals::GzipDocumentProvider::metadata ( std::stop_token stop)
overridevirtual
Parameters
stopCooperative cancellation; underlying metadata obeys its own cancellation contract.
Returns
Frozen revision and only a proven logical extent, or a typed source failure.

Implements portals::ByteDocumentProvider.

◆ pinnedBudgetBytes()

std::size_t portals::GzipDocumentProvider::pinnedBudgetBytes ( const SourceBudget & root) const
overridevirtualnoexcept
Parameters
rootRoot whose non-evictable storage is observed.
Returns
Fixed provider bytes on that root; idle inflater/checkpoints can be reclaimed.

Reimplemented from portals::ByteDocumentProvider.

◆ read()

std::expected< ByteReadResult, DocumentError > portals::GzipDocumentProvider::read ( const ByteReadCommand & command,
std::span< std::byte > destination,
std::stop_token stop )
overridevirtual
Parameters
commandFrozen revision and requested decompressed byte offset.
destinationBounded output storage borrowed for this call only.
stopCooperative cancellation between bounded inflate/input quanta.
Returns
Initialized prefix and confirmed archive EOF, or a typed failure without a published page.

Implements portals::ByteDocumentProvider.

◆ tryReleaseOptionalStorage()

bool portals::GzipDocumentProvider::tryReleaseOptionalStorage ( )
overridevirtualnoexcept
Returns
Whether idle inflater/checkpoint storage was reclaimed without blocking or I/O. Busy operations service a deferred request at completion; replay and document data remain valid.

Reimplemented from portals::ByteDocumentProvider.


The documentation for this class was generated from the following file: