FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    DocumentReplica

    struct · ferroui-designer-collaboration · v0.5.0

    struct DocumentReplica
    

    Ordered operation-set replication of a lossless XAML document. Property writes are last-writer wins in Lamport order; structural conflicts are explicit and resolved in that same order. A transaction arriving before its inserted-node dependency is retained and retried when the dependency arrives. No server order or wall-clock synchronization is required.

    This is not a character-level text CRDT: arbitrary source replacements use exact-source CAS. Replay from the baseline provides deterministic structure even for concurrent cyclic moves.

    View source

    Members

    new

    fn new(actor: impl Into<String>, document_id: impl Into<String>, source: impl Into<String>) -> Result<Self>
    

    Source

    actor

    fn actor(self: &Self) -> &str
    

    Source

    document_id

    fn document_id(self: &Self) -> &str
    

    Source

    baseline_hash

    fn baseline_hash(self: &Self) -> &str
    

    Source

    message

    fn message(self: &Self, operations: Vec<Operation>) -> SyncMessage
    

    Source

    document

    fn document(self: &Self) -> &Document
    

    Source

    source

    fn source(self: &Self) -> &str
    

    Source

    conflicts

    fn conflicts(self: &Self) -> &[Conflict]
    

    Source

    operations

    fn operations(self: &Self) -> impl Iterator<Item = &Operation>
    

    Source

    resolve

    fn resolve(self: &Self, node: &SharedNodeId) -> Option<NodeId>
    

    Source

    shared_id

    fn shared_id(self: &Self, node: NodeId) -> Option<SharedNodeId>
    

    Source

    root

    fn root(self: &Self) -> SharedNodeId
    

    Source

    version

    fn version(self: &Self) -> VersionVector
    

    Source

    has_sequence_gaps

    fn has_sequence_gaps(self: &Self) -> bool
    

    A contiguous vector is a complete checkpoint precondition only when every received operation is represented by it. A later operation beyond a hole must never be discarded merely because the visible contiguous prefix has not advanced.

    Source

    pending_operation_count

    fn pending_operation_count(self: &Self, version: &VersionVector, actor: &str) -> usize
    

    Count an actor's outstanding writes without cloning source payloads into a wire message.

    Source

    changes_since

    fn changes_since(self: &Self, version: &VersionVector) -> SyncMessage
    

    Source

    changes_since_bounded

    fn changes_since_bounded(self: &Self, version: &VersionVector, actor: Option<&str>, max_bytes: usize) -> Result<SyncMessage>
    

    Return one wire-sized page. Filter the writer before paging when uploading an outbox; otherwise other actors' already-acknowledged operations could consume the page. Continue with the receiving replica's updated version until no new operations remain. Only complete sender prefixes are paged: repeatedly sending a sequence beyond a hole could otherwise fill every page without advancing the receiver's vector.

    Source

    snapshot

    fn snapshot(self: &Self) -> Snapshot
    

    Source

    from_snapshot

    fn from_snapshot(actor: impl Into<String>, snapshot: Snapshot) -> Result<Self>
    

    Source

    merge_snapshot

    fn merge_snapshot(self: &mut Self, snapshot: Snapshot) -> Result<MergeReport>
    

    Source

    submit

    fn submit(self: &mut Self, label: impl Into<String>, edits: Vec<SharedEdit>) -> Result<Operation>
    

    Submit an atomic local transaction, rejecting edits that cannot currently be applied. Hosts broadcast the returned operation; the new source is available via source().

    Source

    set_attribute

    fn set_attribute(self: &mut Self, node: SharedNodeId, name: impl Into<String>, value: impl Into<String>) -> Result<Operation>
    

    Source

    shared_id_in

    fn shared_id_in(self: &Self, document: &Document, node: NodeId) -> Result<SharedNodeId>
    

    Resolve a node from an independently hosted document with byte-identical source. The host's local AST IDs may differ after undo or preview history; spans provide the bridge.

    Source

    submit_document_edits

    fn submit_document_edits(self: &mut Self, document: &Document, label: impl Into<String>, edits: Vec<Edit>) -> Result<Operation>
    

    Convert existing designer commands to shared operations. Text-coordinate or whole-source edits intentionally become one source CAS operation; structured property/layout tools keep their fine-grained conflict semantics. Apply replica.source() to the host after success.

    Source

    undo_property

    fn undo_property(self: &mut Self, operation: &OperationId) -> Result<Operation>
    

    Undo is a new causally later write. Conditional compensation refuses to overwrite another actor's change since the original operation. Structural undo can be supplied explicitly through submit(); no hidden mutation of the replicated operation log is allowed.

    Source

    merge

    fn merge(self: &mut Self, message: SyncMessage) -> Result<MergeReport>
    

    Validates every envelope entry before changing the replica. Duplicate identity with different bytes is rejected as equivocation, never resolved by delivery order.

    Source

    receive_presence

    fn receive_presence(self: &mut Self, presence: Presence, now_millis: u64) -> Result<bool>
    

    Source

    presence

    fn presence(self: &Self, now_millis: u64, ttl_millis: u64) -> Vec<&Presence>
    

    The receiving host's monotonic clock governs expiry, avoiding remote-clock assumptions.

    Source

    prune_presence

    fn prune_presence(self: &mut Self, now_millis: u64, ttl_millis: u64)
    

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • Same
    • Clone

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.