pub struct GapBuffer { /* private fields */ }Expand description
Most people know how Vec<T> works: It has some spare capacity at the end,
so that pushing into it doesn’t reallocate every single time. A gap buffer
is the same thing, but the spare capacity can be anywhere in the buffer.
This variant is optimized for large buffers and uses virtual memory.
Implementations§
Source§impl GapBuffer
impl GapBuffer
pub fn new(small: bool) -> Result<Self>
pub fn len(&self) -> usize
pub fn generation(&self) -> u32
pub fn set_generation(&mut self, generation: u32)
Sourcepub fn allocate_gap(
&mut self,
off: usize,
len: usize,
delete: usize,
) -> &mut [u8] ⓘ
pub fn allocate_gap( &mut self, off: usize, len: usize, delete: usize, ) -> &mut [u8] ⓘ
WARNING: The returned slice must not necessarily be the same length as len (due to OOM).
pub fn commit_gap(&mut self, len: usize)
pub fn replace(&mut self, range: Range<usize>, src: &[u8])
pub fn clear(&mut self)
pub fn extract_raw( &self, range: Range<usize>, out: &mut Vec<u8>, out_off: usize, )
Sourcepub fn copy_from(&mut self, src: &dyn ReadableDocument) -> bool
pub fn copy_from(&mut self, src: &dyn ReadableDocument) -> bool
Replaces the entire buffer contents with the given text.
The method is optimized for the case where the given text already matches
the existing contents. Returns true if the buffer contents were changed.
Sourcepub fn copy_into(&self, dst: &mut dyn WriteableDocument)
pub fn copy_into(&self, dst: &mut dyn WriteableDocument)
Copies the contents of the buffer into a string.
Trait Implementations§
Source§impl ReadableDocument for GapBuffer
impl ReadableDocument for GapBuffer
Auto Trait Implementations§
impl Freeze for GapBuffer
impl RefUnwindSafe for GapBuffer
impl !Send for GapBuffer
impl !Sync for GapBuffer
impl Unpin for GapBuffer
impl UnwindSafe for GapBuffer
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