pub struct Text { /* private fields */ }Expand description
One text cell. Cheap to clone; every clone is the same place.
Implementations§
Source§impl Text
impl Text
pub fn id(&self) -> TextId
pub fn len(&self) -> Result<usize>
pub fn is_empty(&self) -> Result<bool>
Sourcepub fn append(&self, text: &str) -> Result<usize>
pub fn append(&self, text: &str) -> Result<usize>
Append to the text, atomically with respect to every other writer; refused whole, never cut, when the result would not fit.
Sourcepub fn release(self) -> Result<()>
pub fn release(self) -> Result<()>
Give the cell back; this and every other handle to it go stale.
Sourcepub fn version(&self) -> Result<u32>
pub fn version(&self) -> Result<u32>
The seqlock sequence at rest, the thing Self::wait_changed waits
on. Take it before Self::load and the wait misses nothing.
Sourcepub fn wait_changed(&self, since: u32) -> Result<u32>
pub fn wait_changed(&self, since: u32) -> Result<u32>
Park until the text has been written since since, then return the
sequence now. A released cell wakes every waiter with
Error::StaleText. Blocking; an async runtime wraps it.
Sourcepub fn wait_changed_until(
&self,
since: u32,
interrupt: &AtomicBool,
) -> Result<Option<u32>>
pub fn wait_changed_until( &self, since: u32, interrupt: &AtomicBool, ) -> Result<Option<u32>>
Self::wait_changed, but a second word can end it. Ok(None)
means the interrupt arrived, not that time ran out — nothing here
measures time. The canceller sets interrupt, then calls
Self::wake_waiters.
Sourcepub fn wake_waiters(&self) -> Result<()>
pub fn wake_waiters(&self) -> Result<()>
Wake everyone parked on this text cell without appending to it. Only useful after the word the waiter also watches has been set.