pub enum Error {
Show 25 variants
InvalidMessage(String),
InvalidPayload(String),
InvalidParameter(String),
UnsupportedVersion(u8),
UnsupportedExchangeType(u8),
NoProposalChosen,
InvalidProposal(String),
AuthenticationFailed(String),
SaNotFound(String),
CryptoError(String),
ReplayDetected(u64),
InvalidLength {
expected: usize,
actual: usize,
},
BufferTooShort {
required: usize,
available: usize,
},
MessageTooLarge(u32),
InvalidSpi(u32),
InvalidSequence(u64),
InvalidState(String),
InvalidStateTransition {
from: String,
to: String,
},
MissingPayload(String),
InvalidExchangeType,
InvalidMessageId {
expected: u32,
received: u32,
},
InvalidKeyLength {
expected: usize,
actual: usize,
},
InvalidIvLength {
expected: usize,
actual: usize,
},
Io(String),
Internal(String),
}Expand description
IPSec protocol errors
Variants§
InvalidMessage(String)
Invalid IKEv2 message format
InvalidPayload(String)
Invalid IKEv2 payload
InvalidParameter(String)
Invalid parameter value
UnsupportedVersion(u8)
Unsupported protocol version
UnsupportedExchangeType(u8)
Unsupported exchange type
NoProposalChosen
No acceptable proposal found
InvalidProposal(String)
Invalid proposal
AuthenticationFailed(String)
Authentication failed
SaNotFound(String)
Security Association not found
CryptoError(String)
Cryptographic operation failed
ReplayDetected(u64)
Replay attack detected
InvalidLength
Invalid packet length
BufferTooShort
Buffer too short for operation
MessageTooLarge(u32)
Message too large
InvalidSpi(u32)
Invalid Security Parameter Index
InvalidSequence(u64)
Invalid sequence number
InvalidState(String)
State machine error
InvalidStateTransition
Invalid state transition
MissingPayload(String)
Missing required payload
InvalidExchangeType
Invalid exchange type
InvalidMessageId
Invalid message ID
InvalidKeyLength
Invalid key length
InvalidIvLength
Invalid IV length
Io(String)
I/O error
Internal(String)
Internal error (should not happen)
Implementations§
Source§impl Error
impl Error
Sourcepub fn code(&self) -> Option<ErrorCode>
pub fn code(&self) -> Option<ErrorCode>
Get error code for programmatic handling
Returns a stable error code that can be used for:
- Programmatic error handling
- Monitoring and alerting
- Error categorization
§Returns
Some(ErrorCode) if this error has a defined code, None otherwise.
Sourcepub fn with_context(self, context: &str) -> Self
pub fn with_context(self, context: &str) -> Self
Add context to error message
Wraps the error with additional context information. Useful for adding operation context to errors propagated from lower layers.
§Arguments
context- Context description
§Returns
New error with context prepended to the message.
§Example
use fynx_proto::ipsec::error::Error;
let err = Error::CryptoError("invalid key".to_string());
let err_with_context = err.with_context("ESP encryption");
assert_eq!(
err_with_context.to_string(),
"Cryptographic error: ESP encryption: invalid key"
);Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if error is retryable
Returns true if this error represents a transient condition
that may succeed on retry.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · 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()