# DocumentReplica

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-designer-collaboration/struct-documentreplica/

**struct** · [`ferroui-designer-collaboration`](/docs/0.5.0/api/ferroui-designer-collaboration/) · v0.5.0

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L48)

## Members

- [`new`](#function-new)
- [`actor`](#function-actor)
- [`document_id`](#function-document_id)
- [`baseline_hash`](#function-baseline_hash)
- [`message`](#function-message)
- [`document`](#function-document)
- [`source`](#function-source)
- [`conflicts`](#function-conflicts)
- [`operations`](#function-operations)
- [`resolve`](#function-resolve)
- [`shared_id`](#function-shared_id)
- [`root`](#function-root)
- [`version`](#function-version)
- [`has_sequence_gaps`](#function-has_sequence_gaps)
- [`pending_operation_count`](#function-pending_operation_count)
- [`changes_since`](#function-changes_since)
- [`changes_since_bounded`](#function-changes_since_bounded)
- [`snapshot`](#function-snapshot)
- [`from_snapshot`](#function-from_snapshot)
- [`merge_snapshot`](#function-merge_snapshot)
- [`submit`](#function-submit)
- [`set_attribute`](#function-set_attribute)
- [`shared_id_in`](#function-shared_id_in)
- [`submit_document_edits`](#function-submit_document_edits)
- [`undo_property`](#function-undo_property)
- [`merge`](#function-merge)
- [`receive_presence`](#function-receive_presence)
- [`presence`](#function-presence)
- [`prune_presence`](#function-prune_presence)

<a id="function-new"></a>

### new

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L69)

<a id="function-actor"></a>

### actor

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L127)

<a id="function-document_id"></a>

### document_id

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L130)

<a id="function-baseline_hash"></a>

### baseline_hash

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L133)

<a id="function-message"></a>

### message

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L136)

<a id="function-document"></a>

### document

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L144)

<a id="function-source"></a>

### source

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L147)

<a id="function-conflicts"></a>

### conflicts

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L150)

<a id="function-operations"></a>

### operations

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L153)

<a id="function-resolve"></a>

### resolve

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L156)

<a id="function-shared_id"></a>

### shared_id

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L162)

<a id="function-root"></a>

### root

```rust
fn root(self: &Self) -> SharedNodeId
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L167)

<a id="function-version"></a>

### version

```rust
fn version(self: &Self) -> VersionVector
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L171)

<a id="function-has_sequence_gaps"></a>

### has_sequence_gaps

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L177)

<a id="function-pending_operation_count"></a>

### pending_operation_count

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L181)

<a id="function-changes_since"></a>

### changes_since

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L190)

<a id="function-changes_since_bounded"></a>

### changes_since_bounded

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L208)

<a id="function-snapshot"></a>

### snapshot

```rust
fn snapshot(self: &Self) -> Snapshot
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L236)

<a id="function-from_snapshot"></a>

### from_snapshot

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L244)

<a id="function-merge_snapshot"></a>

### merge_snapshot

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L254)

<a id="function-submit"></a>

### submit

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L268)

<a id="function-set_attribute"></a>

### set_attribute

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L301)

<a id="function-shared_id_in"></a>

### shared_id_in

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L318)

<a id="function-submit_document_edits"></a>

### submit_document_edits

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L341)

<a id="function-undo_property"></a>

### undo_property

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L409)

<a id="function-merge"></a>

### merge

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L473)

<a id="function-receive_presence"></a>

### receive_presence

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L662)

<a id="function-presence"></a>

### presence

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L701)

<a id="function-prune_presence"></a>

### prune_presence

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Collaboration/document.rs#L708)

## 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](/docs/0.5.0/api/).
