5#include <portals/window_source.hpp>
27 static std::expected<ModelResource, SourceError>
create();
76 : resource_(std::exchange(other.resource_, {})), position_(std::exchange(other.position_, {})),
77 metadata_(std::move(other.metadata_)), metadataSize_(std::exchange(other.metadataSize_, 0)) {
84 std::swap(resource_, other.resource_);
85 std::swap(position_, other.position_);
86 std::swap(metadata_, other.metadata_);
87 std::swap(metadataSize_, other.metadataSize_);
99 std::span<const std::byte>
metadata = {},
106 std::span<const std::
byte>
metadata() const noexcept;
118 std::shared_ptr<const std::byte[]> metadata_;
119 std::size_t metadataSize_{};
171 std::stop_token stop = {})
const = 0;
235 std::uint64_t beforeCount,
236 std::span<const PositionChange> changes,
239 explicit operator bool() const noexcept;
253 std::shared_ptr<const Data> data_;
273 virtual std::expected<PositionHistoryReply, SourceError>
changesFrom(std::uint64_t revision)
const = 0;
Copyable bookmark owning metadata only; never retains model, snapshot, view or page....
Definition model_position.hpp:66
static std::expected< ModelBookmark, SourceError > create(ModelResource resource, ModelPosition position, std::span< const std::byte > metadata={}, BookmarkOptions options={})
std::size_t storageBytes() const noexcept
std::span< const std::byte > metadata() const noexcept
ModelPosition position() const noexcept
ModelBookmark & operator=(ModelBookmark other) noexcept
Definition model_position.hpp:83
static constexpr std::uint32_t FORMAT_VERSION
Version of this in-memory bookmark schema.
Definition model_position.hpp:68
constexpr std::uint32_t formatVersion() const noexcept
Definition model_position.hpp:111
ModelBookmark(ModelBookmark &&other) noexcept
Definition model_position.hpp:75
ModelBookmark()=default
Empty invalid bookmark; constructing it allocates no memory.
ModelBookmark(const ModelBookmark &other)=default
ModelResource resource() const noexcept
Optional immutable bounded ordering history owned only by supporting providers. No rows,...
Definition model_position.hpp:267
virtual std::expected< PositionHistoryReply, SourceError > changesFrom(std::uint64_t revision) const =0
Immutable bounded provider proof between two revisions of a finite order. The provider must report al...
Definition model_position.hpp:224
static std::expected< PositionChangeMap, SourceError > create(std::uint64_t fromRevision, std::uint64_t toRevision, std::uint64_t beforeCount, std::span< const PositionChange > changes, PositionMapOptions options={})
std::uint64_t toRevision() const noexcept
std::uint64_t afterCount() const noexcept
std::expected< PositionMapping, SourceError > map(ModelPosition position) const noexcept
PositionChangeMap()=default
No proof; does not allocate.
std::uint64_t fromRevision() const noexcept
Bounded provider extension independent of views, schedulers, and total extent. Implementations must n...
Definition model_position.hpp:163
virtual ~PositionResolver()=default
Release only the resolver's own bounded metadata.
virtual std::expected< PositionReply, SourceError > resolve(const PositionRequest &request, std::stop_token stop={}) const =0
Public Portals API.
Definition action.hpp:8
@ PENDING
Complete or abandon the owning session before submitting another frame.
Definition diff.hpp:108
PositionAffinity
Preferred surviving side when a position is deleted or text is inserted beside a mark.
Definition model_position.hpp:42
@ BACKWARD
Prefer the preceding item; an entry boundary falls back to the following item.
Definition model_position.hpp:44
@ FORWARD
Prefer the following item; an end boundary falls back to the preceding item.
Definition model_position.hpp:43
@ TEXT
Text category without content.
Definition diagnostics.hpp:64
PositionChangeKind
Operation in a provider-declared finite ordering change map.
Definition model_position.hpp:175
@ SPLICE
Remove a contiguous range, then insert rows at that boundary.
Definition model_position.hpp:176
@ MOVE
Move a range to an index in the sequence after removing that range.
Definition model_position.hpp:177
@ EMPTY
Successful content has zero logical rows.
Definition data_presentation.hpp:14
PositionKind
Position interpretation; a row, a gap, and a text mark are not interchangeable.
Definition model_position.hpp:35
@ ITEM
Full RowId with a version-qualified ordinal hint.
Definition model_position.hpp:36
@ GAP
Boundary between rows, including the entry and end gaps.
Definition model_position.hpp:37
@ MOVE
Pointer motion, with a reported button or MouseButton::NO_BUTTON.
Definition input.hpp:252
PositionResolution
Successful protocol outcomes; absence of support differs from missing history.
Definition model_position.hpp:123
@ UNSUPPORTED
The provider does not implement the requested kind or identity capability.
Definition model_position.hpp:128
@ INCOMPATIBLE
Resource, lineage or change proof cannot identify this position safely.
Definition model_position.hpp:129
@ NEAREST
The original item was removed; a declared surviving neighbor was selected.
Definition model_position.hpp:125
@ PENDING
Provider has not materialized the required bounded data yet.
Definition model_position.hpp:127
@ UNAVAILABLE
A hosted session requires a borrowed executor.
Definition background_options.hpp:13
bool positionReplyMatches(const PositionRequest &request, const PositionReply &reply) noexcept
@ UNSUPPORTED
The application explicitly excludes this annotated phase.
Definition key_binding.hpp:44
SourceError
Source protocol and admission failures, independent of a provider's storage format.
Definition source_budget.hpp:14
Checked bookmark capacity, independent of logical source length.
Definition model_position.hpp:57
std::size_t maxBytes
Header, opaque bytes and conservative payload-allocation allowance.
Definition model_position.hpp:58
Owning scalar position; offset is meaningful only in the declared data revision.
Definition model_position.hpp:48
std::uint64_t revision
Positive revision in which the hint was captured.
Definition model_position.hpp:52
std::uint64_t offset
Ordinal/gap/text hint, never a pointer.
Definition model_position.hpp:51
PositionAffinity affinity
Explicit insertion/deletion preference.
Definition model_position.hpp:53
PositionKind kind
Provider operation to resolve.
Definition model_position.hpp:49
RowId row
Full item identity; empty for GAP/TEXT.
Definition model_position.hpp:50
Logical resource namespace, distinct from its current delivery session. Reuse an existing SourceStamp...
Definition model_position.hpp:21
std::uint64_t lineage
Nonzero provider-maintained compatible-history generation.
Definition model_position.hpp:23
SourceStamp identity
Existing origin namespace; both fields must be nonzero.
Definition model_position.hpp:22
bool operator==(const ModelResource &other) const noexcept=default
static std::expected< ModelResource, SourceError > create()
Scalar ordering operation; payload and row identities remain in the model.
Definition model_position.hpp:181
std::uint64_t destination
MOVE destination after removing the range.
Definition model_position.hpp:186
PositionChangeKind kind
Operation interpretation.
Definition model_position.hpp:182
static constexpr PositionChange splice(std::uint64_t first, std::uint64_t removed, std::uint64_t inserted) noexcept
Definition model_position.hpp:193
std::uint64_t inserted
New count for SPLICE; zero for MOVE.
Definition model_position.hpp:185
std::uint64_t first
Range start in the preceding operation's result.
Definition model_position.hpp:183
std::uint64_t removed
Removed or moved row count.
Definition model_position.hpp:184
static constexpr PositionChange move(std::uint64_t first, std::uint64_t count, std::uint64_t destination) noexcept
Definition model_position.hpp:202
Qualified metadata-only proof result; expired history is an observable outcome.
Definition model_position.hpp:257
PositionChangeMap changes
Complete suffix for the requested revision, when available.
Definition model_position.hpp:258
std::uint64_t proofFloor
Earliest revision whose ordering proof remains retained.
Definition model_position.hpp:259
PositionResolution state
EXACT proof or UNAVAILABLE retained-history gap.
Definition model_position.hpp:260
Bounded change-proof admission options; no model rows are retained.
Definition model_position.hpp:208
std::size_t maxChanges
Maximum scalar operations in one retained map.
Definition model_position.hpp:209
Proven mapped ordinal or gap; removed items become a gap with the requested affinity.
Definition model_position.hpp:213
bool removed
The original item was removed by the declared operations.
Definition model_position.hpp:215
std::uint64_t offset
Current item ordinal, or gap when removed is true.
Definition model_position.hpp:214
Owning resolution receipt; meaningful only for its matching live request.
Definition model_position.hpp:142
ModelPosition position
Meaningful for EXACT/NEAREST, empty for EMPTY.
Definition model_position.hpp:148
ModelResource resource
Logical resource qualified by the request.
Definition model_position.hpp:143
std::uint64_t sequence
Original positive request generation.
Definition model_position.hpp:146
PositionResolution state
Outcome, not an inferred row count.
Definition model_position.hpp:147
SourceStamp session
Delivery session that resolved the request.
Definition model_position.hpp:144
std::uint64_t revision
Exact target data revision.
Definition model_position.hpp:145
Immutable qualified navigation request; does not start work by itself.
Definition model_position.hpp:134
std::uint64_t sequence
Positive request generation assigned by the existing caller.
Definition model_position.hpp:137
std::uint64_t revision
Exact target data revision.
Definition model_position.hpp:136
ModelBookmark bookmark
Owning source position, independent of the originating view.
Definition model_position.hpp:138
SourceStamp session
Current delivery session, not the bookmark origin.
Definition model_position.hpp:135
Provider-assigned row identity, independent of position; increment generation on reuse.
Definition row_id.hpp:9
Immutable source namespace; replacement sessions must share their old budget root.
Definition window_source.hpp:27