pub struct Data {
original: Vec<u8>,
parts: Vec<Span>,
}
Expand description
A container that allows easily replacing chunks of its data.
Fields§
§original: Vec<u8>
Original data.
parts: Vec<Span>
Span
s covering the full range of the original data.
Important: it’s expected that the underlying implementation maintains this in order,
sorted ascending by start position.
Implementations§
Source§impl Data
impl Data
Sourcepub fn to_vec(&self) -> Vec<u8>
pub fn to_vec(&self) -> Vec<u8>
Merge the original data with changes, including uncommitted changes.
See the module-level documentation for more information on why uncommitted changes are included.
Sourcepub fn replace_range(
&mut self,
range: Range<usize>,
data: &[u8],
) -> Result<(), Error>
pub fn replace_range( &mut self, range: Range<usize>, data: &[u8], ) -> Result<(), Error>
Record a provisional change.
If committed, the original data in the given range
will be replaced by the given data.
If there already exist changes for data in the given range (committed or not),
this method will return an error.
It will also return an error if the beginning of the range comes before its end,
or if the range is outside that of the original data.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Data
impl RefUnwindSafe for Data
impl !Send for Data
impl !Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes