#[non_exhaustive]pub enum Error {
Transport(Error),
Server {
code: u16,
kind: ServerErrorKind,
},
Crypto(CryptoError),
Decode(Error),
Encode(Error),
NotLoggedIn,
PayloadTooLarge {
len: usize,
},
NotHdm {
protocol_version: (u8, u8),
},
}Expand description
All errors the HDM client can produce.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Transport(Error)
Underlying transport (TCP, mock, etc.) failure.
Includes timeouts, connection resets, DNS failures. Recovery: reconnect + retry, possibly with backoff.
Server
HDM returned a non-success response code. See ServerErrorKind for the categorisation.
Fields
kind: ServerErrorKindCategorised kind. ServerErrorKind::Unknown(code) for codes outside the documented set.
Crypto(CryptoError)
3DES decryption or padding validation failed.
In practice this almost always means the session key is stale (server-side session timed out, or sequence numbers drifted). Recovery: re-login.
Decode(Error)
Response payload could not be parsed as JSON, or required fields were missing.
Usually indicates spec drift between the crate and the device, or a corrupted payload that survived decryption. Not recoverable without intervention.
Encode(Error)
Request payload could not be serialised to JSON. Indicates a programming bug — the crate’s request structs are always serialisable by construction.
NotLoggedIn
Operation requires an active session but crate::Client::login has not been called
successfully.
PayloadTooLarge
A request payload exceeded the protocol’s 2-byte length field (65 535 bytes).
NotHdm
crate::identify reached a responsive endpoint, but its reply did not begin with the
HDM protocol version — some other TCP service is listening on that address. Distinct from
Self::Transport (nothing answered) so a discovery sweep can tell “wrong service” from
“unreachable”.
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the same operation with no state change might succeed.
True for transient transport failures (timeout, broken pipe) and a small set of server-side conditions that resolve themselves (e.g. printer-out-of-paper after operator intervention). False for logical errors that need data fixes.
Sourcepub const fn requires_relogin(&self) -> bool
pub const fn requires_relogin(&self) -> bool
Whether the client should drop the current session and call crate::Client::login
again before the next operation.
Sourcepub const fn requires_reconnect(&self) -> bool
pub const fn requires_reconnect(&self) -> bool
Whether the underlying TCP connection is in an unrecoverable state and must be re-established.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()