Struct EditorCallBuilder

Source
pub struct EditorCallBuilder { /* private fields */ }

Implementations§

Source§

impl EditorCallBuilder

Source

pub fn new<P: AsRef<Path>>(file_path: P) -> Result<Self, OpenEditorError>

Creates a new EditorCallBuilder with the given file path. You can optionally set the line and column numbers later using the at_line and at_column methods. Finally, you can call the call_editor method to open the editor.

§Errors

This function will return an error if the default editor cannot be found in the environment variables.

Examples found in repository?
examples/independant_editor.rs (line 6)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let filename = "./test";
5
6    EditorCallBuilder::new(filename)?
7        .wait_for_editor(false)
8        .call_editor()?;
9
10    Ok(())
11}
More examples
Hide additional examples
examples/interactive_edit.rs (line 10)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let (filename, line, column) = get_parameters()?;
9
10    EditorCallBuilder::new(filename)?
11        .at_line(line)
12        .at_column(column)
13        .call_editor()?;
14
15    Ok(())
16}
Source

pub fn at_line(self, line: usize) -> Self

Sets the line number for the editor to open at.

Examples found in repository?
examples/interactive_edit.rs (line 11)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let (filename, line, column) = get_parameters()?;
9
10    EditorCallBuilder::new(filename)?
11        .at_line(line)
12        .at_column(column)
13        .call_editor()?;
14
15    Ok(())
16}
Source

pub fn at_column(self, line: usize) -> Self

Sets the column number for the editor to open at.

Examples found in repository?
examples/interactive_edit.rs (line 12)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let (filename, line, column) = get_parameters()?;
9
10    EditorCallBuilder::new(filename)?
11        .at_line(line)
12        .at_column(column)
13        .call_editor()?;
14
15    Ok(())
16}
Source

pub fn wait_for_editor(self, value: bool) -> Self

Whether to wait for the editor to close before returning.

Examples found in repository?
examples/independant_editor.rs (line 7)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let filename = "./test";
5
6    EditorCallBuilder::new(filename)?
7        .wait_for_editor(false)
8        .call_editor()?;
9
10    Ok(())
11}
Source

pub fn call_editor(&self) -> Result<(), OpenEditorError>

Calls the editor with options from the EditorCallBuilder.

§Errors

This function will return an error if the commands fails to execute or if the editor returns a non-zero exit code.

Examples found in repository?
examples/independant_editor.rs (line 8)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let filename = "./test";
5
6    EditorCallBuilder::new(filename)?
7        .wait_for_editor(false)
8        .call_editor()?;
9
10    Ok(())
11}
More examples
Hide additional examples
examples/interactive_edit.rs (line 13)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let (filename, line, column) = get_parameters()?;
9
10    EditorCallBuilder::new(filename)?
11        .at_line(line)
12        .at_column(column)
13        .call_editor()?;
14
15    Ok(())
16}

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.