pub struct Document { /* private fields */ }Expand description
A whole document, the unit of persistence and of the clipboard, see the README for its JSON shape.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(root: Vec<NodeDoc>) -> Self
pub fn new(root: Vec<NodeDoc>) -> Self
Build a document holding root in the current format version.
Sourcepub fn validate(&self) -> Result<(), DocumentError>
pub fn validate(&self) -> Result<(), DocumentError>
Check every structural rule that deserialization enforces.
Sourcepub fn visit(&self, f: impl FnMut(&NodeDoc))
pub fn visit(&self, f: impl FnMut(&NodeDoc))
Call f on every node in document order, parents before their slots.
Sourcepub fn repair(&mut self) -> Vec<Repair>
pub fn repair(&mut self) -> Vec<Repair>
Fix everything Document::validate rejects and report each change, in document order.
Sourcepub fn visit_mut(&mut self, f: impl FnMut(&mut NodeDoc))
pub fn visit_mut(&mut self, f: impl FnMut(&mut NodeDoc))
Call f on every node in document order, Document::validate tells whether the result is still valid.
Sourcepub fn host_tokens(&self) -> BTreeSet<u32>
pub fn host_tokens(&self) -> BTreeSet<u32>
Every host box token in the document.
Sourcepub fn map_host_tokens(&mut self, f: impl FnMut(u32) -> u32)
pub fn map_host_tokens(&mut self, f: impl FnMut(u32) -> u32)
Rewrite every host box token, for example after minting fresh tokens on paste.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Document
impl StructuralPartialEq for Document
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