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
Sourcepub fn load(&self) -> Result<String>
pub fn load(&self) -> Result<String>
A bounded copy of the current text. Returns Error::Contended if
another publication reuses its bank while the copy is in progress.
pub fn len(&self) -> Result<usize>
pub fn is_empty(&self) -> Result<bool>
Sourcepub fn store(&self, text: &str) -> Result<()>
pub fn store(&self, text: &str) -> Result<()>
Replace the text. A live writer causes Error::Contended, not a spin.
Sourcepub fn append(&self, text: &str) -> Result<usize>
pub fn append(&self, text: &str) -> Result<usize>
Append by publishing a complete new bank. A refused write changes neither the committed value nor its revision.
Sourcepub fn release(self) -> Result<()>
pub fn release(self) -> Result<()>
Retire this generation immediately. The physical slot remains pinned until every handle to the old generation has been dropped.
Sourcepub fn version(&self) -> Result<u64>
pub fn version(&self) -> Result<u64>
The full-width committed revision token. Compare for equality; do not truncate it or interpret its bank bit as an in-progress marker.
Sourcepub fn wait_changed(&self, since: u64) -> Result<u64>
pub fn wait_changed(&self, since: u64) -> Result<u64>
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: u64,
interrupt: &AtomicBool,
) -> Result<Option<u64>>
pub fn wait_changed_until( &self, since: u64, interrupt: &AtomicBool, ) -> Result<Option<u64>>
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. The wake advances a separate parking generation;
it does not change the text or its committed revision.
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.