pub struct PieceTable { /* private fields */ }Expand description
Piece Table - main storage structure
Implementations§
Source§impl PieceTable
impl PieceTable
Sourcepub fn insert(&mut self, offset: usize, text: &str)
pub fn insert(&mut self, offset: usize, text: &str)
Insert text at the specified character offset
Sourcepub fn try_insert(
&mut self,
offset: usize,
text: &str,
) -> Result<(), PieceTableError>
pub fn try_insert( &mut self, offset: usize, text: &str, ) -> Result<(), PieceTableError>
Fallible variant of PieceTable::insert that reports piece-table invariant failures.
Sourcepub fn delete(&mut self, start_offset: usize, length: usize)
pub fn delete(&mut self, start_offset: usize, length: usize)
Delete characters in the specified range
Sourcepub fn try_delete(
&mut self,
start_offset: usize,
length: usize,
) -> Result<(), PieceTableError>
pub fn try_delete( &mut self, start_offset: usize, length: usize, ) -> Result<(), PieceTableError>
Fallible variant of PieceTable::delete that reports piece-table invariant failures.
Sourcepub fn try_get_text(&self) -> Result<String, PieceTableError>
pub fn try_get_text(&self) -> Result<String, PieceTableError>
Fallible variant of PieceTable::get_text that reports invalid piece ranges or UTF-8.
Sourcepub fn get_range(&self, start_offset: usize, length: usize) -> String
pub fn get_range(&self, start_offset: usize, length: usize) -> String
Get text in the specified range
Sourcepub fn try_get_range(
&self,
start_offset: usize,
length: usize,
) -> Result<String, PieceTableError>
pub fn try_get_range( &self, start_offset: usize, length: usize, ) -> Result<String, PieceTableError>
Fallible variant of PieceTable::get_range that reports invalid piece ranges or UTF-8.
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
Get the total character count of the document
Sourcepub fn byte_count(&self) -> usize
pub fn byte_count(&self) -> usize
Get the total byte count of the document
Sourcepub fn add_buffer_size(&self) -> usize
pub fn add_buffer_size(&self) -> usize
Get the size of add_buffer (for memory testing)
Sourcepub fn try_gc(&mut self) -> Result<(), PieceTableError>
pub fn try_gc(&mut self) -> Result<(), PieceTableError>
Fallible variant of PieceTable::gc that reports invalid add-buffer piece ranges.
Sourcepub fn set_gc_threshold(&mut self, threshold: usize)
pub fn set_gc_threshold(&mut self, threshold: usize)
Set GC threshold
Auto Trait Implementations§
impl Forget for PieceTable
impl Freeze for PieceTable
impl Move for PieceTable
impl RefUnwindSafe for PieceTable
impl Send for PieceTablewhere
RawVecInner: Send,
impl Sync for PieceTablewhere
RawVecInner: Sync,
impl Unpin for PieceTable
impl UnsafeUnpin for PieceTablewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Piece>: UnsafeUnpin,
impl UnwindSafe for PieceTablewhere
RawVecInner: UnwindSafe,
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