Document
struct · ferroui-designer-core · v0.5.0
struct Document
An owned source buffer with a last-valid syntax snapshot and bounded history. Runtime acceptance is deliberately separate: the host may keep an older live tree when compilation fails, while authored and syntactically valid XAML stays available for correction.
Members
newsourcevalid_sourcerevisionsnapshot_without_historyadvance_revision_toastast_snapshotdiagnosticsis_validis_dirtymark_savedmark_saved_snapshotcan_undocan_redoundo_labelredo_labelset_history_limitapplyapply_attransactapply_text_patchesupdate_sourcetry_update_sourceupdate_source_atundoredo
new
fn new(source: impl Into<String>) -> Result<Self, DesignerError>
source
fn source(self: &Self) -> &str
valid_source
fn valid_source(self: &Self) -> &str
revision
fn revision(self: &Self) -> u64
snapshot_without_history
fn snapshot_without_history(self: &Self) -> Self
Capture the exact current buffer, accepted syntax identity and saved state without copying its undo/redo history. Preview hosts can retain this cheap snapshot without retaining every authoring transaction. Subsequent edits to either document are independent; new edits use the same history limit.
advance_revision_to
fn advance_revision_to(self: &mut Self, minimum: u64) -> Result<(), DesignerError>
Rebase a restored tab onto its host's monotonic revision sequence without altering source, stable node IDs, dirty state or history. Reserve the next revision for editing.
ast
fn ast(self: &Self) -> &Ast
ast_snapshot
fn ast_snapshot(self: &Self) -> Arc<Ast>
Share the exact immutable syntax snapshot without copying its nodes.
A gesture can retain this handle together with a revision to reject a
command prepared for a different document, even if its local IDs match.
Invalid source returns the last-valid syntax, like ast().
diagnostics
fn diagnostics(self: &Self) -> &[Diagnostic]
is_valid
fn is_valid(self: &Self) -> bool
is_dirty
fn is_dirty(self: &Self) -> bool
mark_saved
fn mark_saved(self: &mut Self)
mark_saved_snapshot
fn mark_saved_snapshot(self: &mut Self, source: impl Into<String>)
Acknowledge the exact snapshot written by an asynchronous storage provider. The current buffer may already contain newer edits; revision and history are unchanged.
can_undo
fn can_undo(self: &Self) -> bool
can_redo
fn can_redo(self: &Self) -> bool
undo_label
fn undo_label(self: &Self) -> Option<&str>
redo_label
fn redo_label(self: &Self) -> Option<&str>
set_history_limit
fn set_history_limit(self: &mut Self, limit: usize)
apply
fn apply(self: &mut Self, label: impl Into<String>, edits: Vec<Edit>) -> Result<ChangeSet, DesignerError>
apply_at
fn apply_at(self: &mut Self, expected_revision: u64, label: impl Into<String>, edits: Vec<Edit>) -> Result<ChangeSet, DesignerError>
transact
fn transact(self: &mut Self, transaction: Transaction) -> Result<ChangeSet, DesignerError>
apply_text_patches
fn apply_text_patches(self: &mut Self, expected_revision: u64, label: impl Into<String>, patches: Vec<TextPatch>) -> Result<ChangeSet, DesignerError>
Apply disjoint editor patches atomically. All spans refer to the current authored source; UTF-8 boundaries and overlap are checked before mutation.
update_source
fn update_source(self: &mut Self, label: impl Into<String>, source: impl Into<String>) -> SourceUpdate
Source editors may temporarily contain invalid XML. The raw buffer and diagnostics enter history, while the AST/preview source remain the last valid snapshot. A subsequent valid source update reconciles node IDs.
try_update_source
fn try_update_source(self: &mut Self, label: impl Into<String>, source: impl Into<String>) -> Result<SourceUpdate, DesignerError>
Fallible source editing for hosts that must distinguish a rejected write from an accepted but temporarily invalid XML buffer. Revision exhaustion cannot alter source, node identity, history or saved-state tracking.
update_source_at
fn update_source_at(self: &mut Self, expected_revision: u64, label: impl Into<String>, source: impl Into<String>) -> Result<SourceUpdate, DesignerError>
undo
fn undo(self: &mut Self) -> Result<ChangeSet, DesignerError>
redo
fn redo(self: &mut Self) -> Result<ChangeSet, DesignerError>
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedClone
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.