#[non_exhaustive]pub enum ExpectError {
Show 20 variants
ScreenNotAttached,
InvalidInput {
api: String,
reason: String,
},
Spawn(SpawnError),
Io(Error),
IoWithContext {
context: String,
source: Error,
},
Timeout {
duration: Duration,
pattern: String,
buffer: String,
},
PatternNotFound {
pattern: String,
buffer: String,
},
ProcessExited {
exit_status: ExitStatus,
buffer: String,
},
Eof {
buffer: String,
},
InvalidPattern {
message: String,
},
Regex(Error),
SessionClosed,
SessionNotFound {
id: usize,
},
NoSessions,
MultiSessionError {
session_id: usize,
error: Box<Self>,
},
NotInteracting,
BufferOverflow {
max_size: usize,
},
Encoding {
message: String,
},
Config {
message: String,
},
Signal {
message: String,
},
}Expand description
The main error type for rust-expect operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ScreenNotAttached
A screen-aware operation was called without a screen attached.
Indicates a programmer error rather than a runtime miss: the caller
invoked expect_screen_contains, wait_screen_not_contains, or
wait_screen_stable without first calling Session::attach_screen.
InvalidInput
Caller-supplied input was rejected before any I/O happened.
Used by APIs that validate their input — for example, send_paste
refuses payloads containing the bracketed-paste end marker because
they would let the receiver drop out of paste mode mid-stream. The
reason is a short human-readable explanation suitable for surfacing
in a test failure or log line.
Fields
Spawn(SpawnError)
Failed to spawn a process.
Io(Error)
An I/O error occurred.
IoWithContext
An I/O error occurred with additional context.
Timeout
Timeout waiting for pattern match.
Fields
PatternNotFound
Pattern was not found before EOF.
Fields
ProcessExited
Process exited unexpectedly.
Fields
exit_status: ExitStatusThe exit status of the process.
Eof
End of file reached.
InvalidPattern
Invalid pattern specification.
Regex(Error)
Invalid regex pattern.
SessionClosed
Session is closed.
SessionNotFound
Session not found.
NoSessions
No sessions available for operation.
MultiSessionError
Error in multi-session operation.
Fields
NotInteracting
Session is not in interact mode.
BufferOverflow
Buffer overflow.
Encoding
Encoding error.
Config
Configuration error.
Signal
Signal error (Unix only).
Implementations§
Source§impl ExpectError
impl ExpectError
Sourcepub fn timeout(
duration: Duration,
pattern: impl Into<String>,
buffer: impl Into<String>,
) -> Self
pub fn timeout( duration: Duration, pattern: impl Into<String>, buffer: impl Into<String>, ) -> Self
Create a timeout error with the given details.
Sourcepub fn pattern_not_found(
pattern: impl Into<String>,
buffer: impl Into<String>,
) -> Self
pub fn pattern_not_found( pattern: impl Into<String>, buffer: impl Into<String>, ) -> Self
Create a pattern not found error.
Sourcepub fn process_exited(
exit_status: ExitStatus,
buffer: impl Into<String>,
) -> Self
pub fn process_exited( exit_status: ExitStatus, buffer: impl Into<String>, ) -> Self
Create a process exited error.
Sourcepub fn invalid_pattern(message: impl Into<String>) -> Self
pub fn invalid_pattern(message: impl Into<String>) -> Self
Create an invalid pattern error.
Sourcepub const fn buffer_overflow(max_size: usize) -> Self
pub const fn buffer_overflow(max_size: usize) -> Self
Create a buffer overflow error.
Sourcepub fn io_context(context: impl Into<String>, source: Error) -> Self
pub fn io_context(context: impl Into<String>, source: Error) -> Self
Create an I/O error with context.
Sourcepub fn with_io_context<T>(
result: Result<T>,
context: impl Into<String>,
) -> Result<T>
pub fn with_io_context<T>( result: Result<T>, context: impl Into<String>, ) -> Result<T>
Wrap an I/O result with context.
Sourcepub const fn is_timeout(&self) -> bool
pub const fn is_timeout(&self) -> bool
Check if this is a timeout error.
Trait Implementations§
Source§impl Debug for ExpectError
impl Debug for ExpectError
Source§impl Display for ExpectError
impl Display for ExpectError
Source§impl Error for ExpectError
impl Error for ExpectError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()