pub struct Document { /* private fields */ }Expand description
A .flow file open for editing. The text is the source of truth; the
graph is a view of it.
use flow_runner::{Document, Edit};
let mut doc = Document::parse("edition 2026\nflow f\nentry a\n\nnode a = { \"ok\": true }\n");
doc.apply(Edit::RenameNode { from: "a".into(), to: "start".into() }).unwrap();
assert_eq!(doc.text(), "edition 2026\nflow f\nentry start\n\nnode start = { \"ok\": true }\n");
assert!(doc.diagnostics().is_empty());Implementations§
Source§impl Document
impl Document
Sourcepub fn parse(text: impl Into<String>) -> Document
pub fn parse(text: impl Into<String>) -> Document
Open a file. Never fails: problems are in
diagnostics, and the graph shows every
declaration that parsed. A file over MAX_SOURCE_BYTES isn’t read
at all.
Sourcepub fn diagnostics(&self) -> &Diagnostics
pub fn diagnostics(&self) -> &Diagnostics
Every error and warning, as Flow::check
reports them.
Sourcepub fn apply(&mut self, edit: Edit) -> Result<(), EditError>
pub fn apply(&mut self, edit: Edit) -> Result<(), EditError>
Apply one edit. On error the document is unchanged. An edit that parses but leaves the flow wrong, such as removing a node others jump to, is applied, and the problem shows in the diagnostics. An edit that would change more of the file than it asks for is refused.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more