Struct TodoFile

Source
pub struct TodoFile { /* private fields */ }
Expand description

Represents a rebase file.

Implementations§

Source§

impl TodoFile

Source

pub fn new<Path: AsRef<Path>>( path: Path, undo_limit: u32, comment_char: &str, ) -> Self

Create a new instance.

Source

pub fn set_lines(&mut self, lines: Vec<Line>)

Set the rebase lines.

Source

pub fn load_file(&mut self) -> Result<(), IoError>

Load the rebase file from disk.

§Errors

Returns error if the file cannot be read.

Source

pub fn write_file(&self) -> Result<(), IoError>

Write the rebase file to disk.

§Errors

Returns error if the file cannot be written.

Source

pub fn set_selected_line_index(&mut self, selected_line_index: usize) -> usize

Set the selected line index returning the new index based after ensuring within range.

Source

pub fn swap_range_up(&mut self, start_index: usize, end_index: usize) -> bool

Swap a range of lines up.

Source

pub fn swap_range_down(&mut self, start_index: usize, end_index: usize) -> bool

Swap a range of lines down.

Source

pub fn add_line(&mut self, index: usize, line: Line)

Add a new line.

Source

pub fn remove_lines(&mut self, start_index: usize, end_index: usize)

Remove a range of lines.

Source

pub fn update_range( &mut self, start_index: usize, end_index: usize, edit_context: &EditContext, )

Update a range of lines.

Source

pub fn undo(&mut self) -> Option<(usize, usize)>

Undo the last modification.

Source

pub fn redo(&mut self) -> Option<(usize, usize)>

Redo the last undone modification.

Source

pub const fn version(&self) -> &Version

Get the current version

Source

pub fn get_selected_line(&self) -> Option<&Line>

Get the selected line.

Source

pub fn get_max_selected_line_index(&self) -> usize

Get the index of the last line that can be selected.

Source

pub const fn get_selected_line_index(&self) -> usize

Get the selected line index

Source

pub fn get_filepath(&self) -> &Path

Get the file path to the rebase file.

Source

pub fn get_line(&self, index: usize) -> Option<&Line>

Get a line by index.

Source

pub fn get_lines_owned(&self) -> Vec<Line>

Get an owned copy of the lines.

Source

pub const fn is_noop(&self) -> bool

Is the rebase file a noop.

Source

pub fn lines_iter(&self) -> Iter<'_, Line>

Get an iterator over the lines.

Source

pub fn is_empty(&self) -> bool

Does the rebase file contain no lines.

Trait Implementations§

Source§

impl Debug for TodoFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V