pub struct Buffer {
pub path: PathBuf,
pub lines: Vec<String>,
pub dirty: bool,
pub trailing_newline: bool,
pub last_disk_mtime: Option<SystemTime>,
pub disk_changed: bool,
pub disk_deleted: bool,
}Fields§
§path: PathBuf§lines: Vec<String>§dirty: bool§trailing_newline: boolWhether the source file ended with \n. Tracked so content() and
write() can reproduce the file byte-for-byte and avoid spurious
“no newline at end of file” diff noise.
last_disk_mtime: Option<SystemTime>§disk_changed: bool§disk_deleted: boolImplementations§
Source§impl Buffer
impl Buffer
pub fn from_file(path: &Path) -> Result<Self>
pub fn empty(path: &Path) -> Self
pub fn line_count(&self) -> usize
pub fn content(&self) -> String
pub fn set_line(&mut self, index: usize, text: String)
pub fn insert_line(&mut self, index: usize, text: String)
pub fn remove_line(&mut self, index: usize) -> Option<String>
pub fn replace_range( &mut self, start: usize, end: usize, replacement: Vec<String>, )
pub fn record_disk_mtime(&mut self)
pub fn write(&mut self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more