pub struct MockBufferExt {
BufferExt_expectations: MockBufferExt_BufferExt,
}Expand description
Extension trait for Buffer to provide extra functionalities.
Provides focused helpers for line fetching and text insertion at the current
cursor position while surfacing Nvim errors via notify_error.
Fields§
§BufferExt_expectations: MockBufferExt_BufferExtImplementations§
Source§impl MockBufferExt
impl MockBufferExt
Sourcepub fn checkpoint(&mut self)
pub fn checkpoint(&mut self)
Validate that all current expectations for all methods have been satisfied, and discard them.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new mock object with no expectations.
This method will not be generated if the real struct
already has a new method. However, it will be
generated if the struct implements a trait with a new
method. The trait’s new method can still be called
like <MockX as TraitY>::new
Source§impl MockBufferExt
impl MockBufferExt
Sourcepub fn expect_get_line(&mut self) -> &mut Expectation
pub fn expect_get_line(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_line method
Sourcepub fn expect_get_lines(&mut self) -> &mut Expectation
pub fn expect_get_lines(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_lines method
Sourcepub fn expect_get_text_between(&mut self) -> &mut Expectation
pub fn expect_get_text_between(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_text_between method
Sourcepub fn expect_get_buf_type(&mut self) -> &mut Expectation
pub fn expect_get_buf_type(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_buf_type method
Sourcepub fn expect_get_channel(&mut self) -> &mut Expectation
pub fn expect_get_channel(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_channel method
Sourcepub fn expect_set_text_at_cursor_pos(&mut self) -> &mut Expectation
pub fn expect_set_text_at_cursor_pos(&mut self) -> &mut Expectation
Create an Expectation for mocking the set_text_at_cursor_pos method
Sourcepub fn expect_is_terminal(&mut self) -> &mut Expectation
pub fn expect_is_terminal(&mut self) -> &mut Expectation
Create an Expectation for mocking the is_terminal method
Sourcepub fn expect_send_command(&mut self) -> &mut Expectation
pub fn expect_send_command(&mut self) -> &mut Expectation
Create an Expectation for mocking the send_command method
Sourcepub fn expect_get_pid(&mut self) -> &mut Expectation
pub fn expect_get_pid(&mut self) -> &mut Expectation
Create an Expectation for mocking the get_pid method
Trait Implementations§
Source§impl BufferExt for MockBufferExt
Extension trait for Buffer to provide extra functionalities.
impl BufferExt for MockBufferExt
Extension trait for Buffer to provide extra functionalities.
Provides focused helpers for line fetching and text insertion at the current
cursor position while surfacing Nvim errors via notify_error.
Source§fn get_line(&self, idx: usize) -> Result<String>
fn get_line(&self, idx: usize) -> Result<String>
Fetch a single line from a Buffer by 0-based index.
Returns a color_eyre::Result with the line as nvim_oxi::String.
Errors if the line does not exist at idx.
§Errors
- Fetching the line via
nvim_buf_get_linesfails. - The requested index is out of range (no line returned).
Source§fn get_lines(
&self,
line_range: RangeInclusive<usize>,
strict_indexing: bool,
) -> Result<Box<dyn SuperIterator<String>>, Error>
fn get_lines( &self, line_range: RangeInclusive<usize>, strict_indexing: bool, ) -> Result<Box<dyn SuperIterator<String>>, Error>
Retrieves a range of lines from the buffer.
§Errors
- If
strict_indexingis true and the range is out of bounds. - If the Nvim API call to fetch lines fails.
§Rationale
This is a thin wrapper around nvim_oxi::api::Buffer::get_lines to enable unit testing of the default trait
method BufferExt::get_text_between.
Source§fn get_text_between(
&self,
start: (usize, usize),
end: (usize, usize),
boundary: TextBoundary,
) -> Result<String>
fn get_text_between( &self, start: (usize, usize), end: (usize, usize), boundary: TextBoundary, ) -> Result<String>
Get text from a nvim_oxi::api::Buffer.
Retrieves text from the specified start position to end position, respecting the given boundary.
§Errors
- If substring extraction fails due to invalid indices.
Source§fn get_buf_type(&self) -> Option<String>
fn get_buf_type(&self) -> Option<String>
Retrieves the buffer type via the buftype option.
Queries Nvim for the buffer type option and returns the value.
Errors are handled internally by notifying Nvim and converting to None.
§Rationale
Errors are notified directly to Nvim because this is the behavior wanted in all cases.
Source§fn set_text_at_cursor_pos(&mut self, text: &str)
fn set_text_at_cursor_pos(&mut self, text: &str)
Inserts text at the current cursor position in the active buffer.
Obtains the current CursorPosition, converts the 1-based row to 0-based
for Nvim’s set_text call, and inserts text without replacing existing
content (start_col == end_col). Errors are reported via notify_error.
Silently returns if cursor position cannot be fetched.
Source§fn get_pid(&self) -> Result<String>
fn get_pid(&self) -> Result<String>
Retrieves the process ID associated with the buffer.
§Errors
- If the buffer name cannot be retrieved.
- If the buffer is a terminal but the name format is invalid.
- If the Neovim
getpidfunction call fails.
fn get_channel(&self) -> Option<u32>
fn is_terminal(&self) -> bool
fn send_command(&self, cmd: &str) -> Option<()>
Source§impl Debug for MockBufferExt
impl Debug for MockBufferExt
Auto Trait Implementations§
impl Freeze for MockBufferExt
impl RefUnwindSafe for MockBufferExt
impl Send for MockBufferExt
impl Sync for MockBufferExt
impl Unpin for MockBufferExt
impl UnwindSafe for MockBufferExt
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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> ⓘ
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§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§type Error = Infallible
type Error = Infallible
Result.§fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
Result.§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more