6#include <portals/document_source.hpp>
12 std::optional<std::uint64_t>
end;
18 std::optional<DocumentError>
error;
42 virtual std::expected<void, DocumentError>
finish(std::stop_token stop) {
57 static std::expected<std::shared_ptr<DocumentFileSink>,
DocumentError>
create(std::filesystem::path path);
64 std::expected<void, DocumentError>
finish(std::stop_token stop)
override;
67 explicit DocumentFileSink(std::filesystem::path path);
68 std::expected<void, DocumentError> open();
69 std::filesystem::path path_;
87 std::optional<DocumentError>
error;
102 DocumentExportOptions options = {}, std::stop_token stop = {});
113std::expected<std::shared_ptr<const DocumentCopy>,
DocumentError>
115 std::stop_token stop = {});
123 std::span<const std::byte>
bytes() const noexcept {
133 friend std::expected<std::shared_ptr<const DocumentCopy>,
DocumentError>
136 DocumentCopy() =
default;
139 std::shared_ptr<SourceArena> arena_;
140 std::span<const std::byte> bytes_;
Immutable bounded byte copy whose accounting outlives its payload.
Definition document_export.hpp:118
friend std::expected< std::shared_ptr< const DocumentCopy >, DocumentError > copyDocumentBytes(std::shared_ptr< ByteDocumentSource >, DocumentByteRange, std::size_t, std::stop_token)
DocumentRevision revision() const noexcept
Definition document_export.hpp:128
std::span< const std::byte > bytes() const noexcept
Definition document_export.hpp:123
~DocumentCopy()=default
Destroy bytes before returning the retained credit.
Worker sink; storage/output policy belongs to the host implementation. write borrows bytes only for i...
Definition document_export.hpp:27
virtual ~DocumentExportSink()=default
Release owned output handles; no scene is retained.
virtual std::expected< void, DocumentError > finish(std::stop_token stop)
Definition document_export.hpp:42
virtual DocumentWriteReply write(std::span< const std::byte > bytes, std::stop_token stop)=0
static std::expected< std::shared_ptr< DocumentFileSink >, DocumentError > create(std::filesystem::path path)
DocumentWriteReply write(std::span< const std::byte > bytes, std::stop_token stop) override
std::expected< void, DocumentError > finish(std::stop_token stop) override
~DocumentFileSink() override
Close any still-owned descriptor without deleting a path.
Move-only credit; backing storage must be destroyed before this final credit owner.
Definition source_budget.hpp:64
Public Portals API.
Definition action.hpp:8
DocumentExportResult exportDocument(std::shared_ptr< ByteDocumentSource > source, std::shared_ptr< DocumentExportSink > sink, DocumentByteRange range={}, DocumentExportOptions options={}, std::stop_token stop={})
std::expected< std::shared_ptr< const DocumentCopy >, DocumentError > copyDocumentBytes(std::shared_ptr< ByteDocumentSource > source, DocumentByteRange range, std::size_t maxBytes=64 *1024, std::stop_token stop={})
Half-open original logical-byte range; an omitted end requests this snapshot through EOF.
Definition document_export.hpp:10
std::optional< std::uint64_t > end
Exclusive original byte offset; absence means the observed end.
Definition document_export.hpp:12
std::uint64_t begin
Inclusive original byte offset, without decoding or normalization.
Definition document_export.hpp:11
Failure with an optional native provider cause, preserved by source operations.
Definition document_source.hpp:13
Bounded export work configuration, independent of range/document size.
Definition document_export.hpp:75
std::size_t blockBytes
Positive read quantum, additionally clamped to the source page maximum.
Definition document_export.hpp:76
Export outcome, including the prefix preserved after an error.
Definition document_export.hpp:80
DocumentByteRange range
Requested range, with an observed exact end when available.
Definition document_export.hpp:82
std::uint64_t bytesWritten
Exactly accepted output bytes unless writtenCountExact is false.
Definition document_export.hpp:84
std::uint64_t bytesRead
Accepted source bytes, including unwritten pages and a possible range-start probe.
Definition document_export.hpp:83
bool complete
True only after the complete range and successful sink finalization.
Definition document_export.hpp:86
DocumentRevision revision
Source and revision fixed before the first output write.
Definition document_export.hpp:81
std::optional< DocumentError > error
First failure only; a later finish failure is discarded. Empty on success.
Definition document_export.hpp:87
bool writtenCountExact
False if a throwing/invalid sink reply prevented exact admission accounting.
Definition document_export.hpp:85
Exact document namespace and provider revision.
Definition document_source.hpp:24
One synchronous sink admission, including partial writes followed by an error.
Definition document_export.hpp:16
std::size_t written
Exactly accepted bytes from this call, at most the supplied span length.
Definition document_export.hpp:17
std::optional< DocumentError > error
Failure after the reported prefix, or empty to continue.
Definition document_export.hpp:18