5#include <portals/model.hpp>
6#include <portals/window_source.hpp>
19 requires std::is_trivially_copyable_v<T>
26 : snapshot_(std::move(snapshot)), seekRow_(seekRow) {
31 return {
true, seekRow_,
true};
40 std::stop_token stop)
override {
49 auto position = std::uint64_t{};
56 position = snapshot_->rowCount();
66 auto located = snapshot_->locateRow(command.
anchor.
row);
84 auto available = backwards || tail ? position : snapshot_->rowCount() - position;
85 auto count =
static_cast<std::size_t
>(std::min<std::uint64_t>(available, command.
maxRows));
86 auto first = backwards || tail ? position - count : position;
90 return std::unexpected(detail::sourceTreeError(range.error()));
104 for (
const auto &row : range->rows()) {
105 if (stop.stop_requested()) {
109 auto appended = out.
emplace(row.id, snapshot_->revision(), row.value);
112 return std::unexpected(appended.error());
119 return out.
ready({command.
source, {first, 0}}, {command.
source, {first + count, 0}}, edge);
123 std::shared_ptr<const ModelSnapshot<T>> snapshot_;
std::expected< SourceReadReply< T >, SourceError > load(const SourceReadCommand &command, PageBuilder< T > &out, std::stop_token stop) override
Definition window_source_model.hpp:39
SourceCapabilities capabilities() const noexcept override
Definition window_source_model.hpp:30
FiniteWindowProvider(std::shared_ptr< const ModelSnapshot< T > > snapshot, bool seekRow=false)
Definition window_source_model.hpp:25
static std::expected< ModelRange, TreeError > read(std::shared_ptr< const ModelSnapshot< T > > owner, RowRange range, std::size_t max_rows)
Read only memory and retain its snapshot. Bounds/provider contract failures are explicit....
Definition model.hpp:244
Immutable list/table provider storage, independent of view/source lifetime. Implement read as bounded...
Definition model.hpp:94
One reserved worker-only builder. Never expose its writable resource after publication.
Definition window_source.hpp:224
std::expected< void, SourceError > emplace(RowId id, std::uint64_t revision, Args &&...args)
Definition window_source.hpp:242
std::expected< SourceReadReply< T >, SourceError > ready(SourceCursor before, SourceCursor after, SourceEdge edge)
Definition window_source.hpp:278
Worker provider; the source captures capabilities once and never calls load on UI.
Definition window_source.hpp:323
Public Portals API.
Definition action.hpp:8
@ TAIL
Capability-gated available-tail window.
Definition window_source.hpp:55
@ ROW
Capability-gated stable-identity lookup.
Definition window_source.hpp:56
@ ENTRY
Provider entry, without a global-origin promise.
Definition window_source.hpp:53
@ CURSOR
Valid gap token in this immutable session.
Definition window_source.hpp:54
@ FAILED
Provider failure is represented by snapshot-owned text and no rows.
Definition model.hpp:48
@ PENDING
Data is not ready; reading must not block or start work.
Definition model.hpp:46
@ FOUND
The index identifies this RowId in the same snapshot.
Definition model.hpp:74
@ UNSUPPORTED
Provider does not implement an identity index; ordinal scrolling remains available.
Definition model.hpp:72
SourceError
Source protocol and admission failures, independent of a provider's storage format.
Definition source_budget.hpp:14
@ INVALID_CURSOR
The provider cannot validate this opaque token.
Definition source_budget.hpp:25
@ CALLBACK_FAILED
Provider construction/preparation threw an unexpected exception.
Definition source_budget.hpp:21
@ UNSUPPORTED
A required optional capability is unavailable.
Definition source_budget.hpp:23
@ REVISION_CHANGED
Requested provider revision is unavailable or a notification is stale.
Definition source_budget.hpp:26
@ CANCELLED
Explicit navigation cancellation or cooperative worker cancellation.
Definition source_budget.hpp:35
@ ROW_NOT_FOUND
A supported stable-identity lookup did not find its row.
Definition source_budget.hpp:28
@ INVALID_ARGUMENT
Invalid options, enum, identity or command shape.
Definition source_budget.hpp:15
@ BACKWARD
Read before the requested gap.
Definition window_source.hpp:49
@ FORWARD
Read after the requested gap.
Definition window_source.hpp:48
@ FINAL_END
Definitive boundary in this direction for this session.
Definition window_source.hpp:62
@ MORE
Continuation exists; short/empty pages do not imply end.
Definition window_source.hpp:60
RowId row
Used for ROW only.
Definition window_source.hpp:69
SourceCursor cursor
Used for CURSOR only.
Definition window_source.hpp:68
SourceAnchorKind kind
Operation to resolve on a worker.
Definition window_source.hpp:67
Immutable navigation capabilities of the delivery channel, not of the complete model.
Definition window_source.hpp:73
std::array< std::uint64_t, 2 > token
Provider-validated gap representation.
Definition window_source.hpp:39
Immutable worker command; maxRows is an upper bound, never an extent.
Definition window_source.hpp:90
SourceAnchor anchor
Latest bounded navigation intent.
Definition window_source.hpp:93
SourceStamp source
Expected session namespace.
Definition window_source.hpp:91
std::uint64_t dataRevision
Exact requested readiness/data revision.
Definition window_source.hpp:92
SourceDirection direction
Traversal direction.
Definition window_source.hpp:94
std::size_t maxRows
Positive remaining demand, capped per page.
Definition window_source.hpp:95
Owning result with fixed metadata; no optional/variant deep copies.
Definition window_source.hpp:212
std::uint64_t observedRevision
PENDING must match the command revision.
Definition window_source.hpp:216