pub struct Synced { /* private fields */ }Expand description
A document as markdown and as blocks, each kept up with the other.
Every block owns a range of the text. The ranges partition it in block order, each running from where the parser starts its block to where it starts the next, and a block that is not written owns an empty one. Read back, the text gives the blocks with their texts normalized.
Self::set_doc rewrites the text of the blocks that changed and leaves
every other byte as it was. Self::set_text reads again the blocks whose
text changed. Each works on a window of top-level blocks around the change,
read back with the top-level block on either side of it and widened until
those read as they did, up to the whole document.
Implementations§
Source§impl Synced
impl Synced
pub fn new(text: impl Into<String>, marks: &Marks) -> Self
pub fn text(&self) -> &str
pub fn doc(&self) -> &Rc<Doc>
Sourcepub fn ranges(&self) -> &[Range<usize>]
pub fn ranges(&self) -> &[Range<usize>]
Each block’s range of Self::text, in block order.
Sourcepub fn set_doc(&mut self, doc: Rc<Doc>)
pub fn set_doc(&mut self, doc: Rc<Doc>)
The blocks are now doc. The blocks that differ from the ones before
are written again.
Sourcepub fn set_text(&mut self, text: &str)
pub fn set_text(&mut self, text: &str)
The text is now text. The blocks whose text changed are read again.
Sourcepub fn offsets(&mut self, at: &[Cursor]) -> Vec<Option<usize>>
pub fn offsets(&mut self, at: &[Cursor]) -> Vec<Option<usize>>
Where each of at lands in the text, None for one this cannot place.
The top-level blocks holding them are written again, with the positions
in, as crate::serialize_at_many writes a document: a trailing space
with a position after it is no longer trailing, and stays.
Auto Trait Implementations§
impl !Send for Synced
impl !Sync for Synced
impl Freeze for Synced
impl RefUnwindSafe for Synced
impl Unpin for Synced
impl UnsafeUnpin for Synced
impl UnwindSafe for Synced
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more