pub enum WrapError {
InvalidColumnWidth(usize),
InputTooLarge(usize, usize),
}Expand description
Comprehensive error types for wrap-ansi operations.
This enum provides detailed error information for various failure modes that can occur during text wrapping operations.
§Examples
use wrap_ansi::{wrap_ansi_checked, WrapError};
// Handle invalid column width
match wrap_ansi_checked("test", 0, None) {
Err(WrapError::InvalidColumnWidth(width)) => {
println!("Column width {} is invalid, must be > 0", width);
}
Ok(result) => println!("Wrapped: {}", result),
_ => {}
}
// Handle input size limits
let huge_input = "x".repeat(20_000_000);
match wrap_ansi_checked(&huge_input, 80, None) {
Err(WrapError::InputTooLarge(size, max_size)) => {
println!("Input {} bytes exceeds limit of {} bytes", size, max_size);
}
Ok(result) => println!("Wrapped successfully"),
_ => {}
}Variants§
InvalidColumnWidth(usize)
Column width must be greater than 0.
This error occurs when attempting to wrap text with a column width of 0, which would be impossible to satisfy.
InputTooLarge(usize, usize)
Input string is too large to process safely.
This error provides protection against potential DoS attacks by limiting
the maximum input size that can be processed.
Trait Implementations§
Source§impl Error for WrapError
impl Error for WrapError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl Eq for WrapError
impl StructuralPartialEq for WrapError
Auto Trait Implementations§
impl Freeze for WrapError
impl RefUnwindSafe for WrapError
impl Send for WrapError
impl Sync for WrapError
impl Unpin for WrapError
impl UnwindSafe for WrapError
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