pub enum ExpectError {
Show 18 variants
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§
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.