#[non_exhaustive]pub enum ErrorCode {
Show 13 variants
FormatViolation,
GenericError,
InternalError,
MessageTypeNotSupported,
NotImplemented,
NotSupported,
OccurrenceConstraintViolation,
PropertyConstraintViolation,
ProtocolError,
RpcFrameworkError,
SecurityError,
TypeConstraintViolation,
Other(String),
}Expand description
An OCPP-J RPC framework error code (2.1 Part 4 Table 9; 1.6J Table 7).
The wire spelling is version-dependent and the differences are not cosmetic:
| Variant | 1.6J | 2.0.1 / 2.1 |
|---|---|---|
FormatViolation | FormationViolation | FormatViolation |
OccurrenceConstraintViolation | OccurenceConstraintViolation (one r, as printed in the specification) | OccurrenceConstraintViolation |
RpcFrameworkError | not defined — sent as GenericError | RpcFrameworkError |
MessageTypeNotSupported | not defined — sent as GenericError | MessageTypeNotSupported (deprecated; never sent) |
Parsing accepts every spelling on every version, because peers mix them up constantly.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
FormatViolation
The payload is syntactically incorrect.
GenericError
Any error not covered by a more specific code.
InternalError
The receiver failed internally while processing the action.
MessageTypeNotSupported
A message type number the receiver does not support (2.x only).
Deprecated by the 2.0.1 edition 4 errata (2026-02): an unknown message type is ignored on every version, so this engine never sends it. Still parsed, because older 2.0.1 peers do.
NotImplemented
The requested action is not known to the receiver.
NotSupported
The action is known but not supported by the receiver.
OccurrenceConstraintViolation
A field violates an occurrence constraint.
PropertyConstraintViolation
A field contains an invalid value.
ProtocolError
The payload does not conform to the action’s PDU structure.
RpcFrameworkError
The message is not a valid RPC request — for example the MessageId could not be
read (2.x only).
SecurityError
A security issue prevented the receiver from completing the action.
TypeConstraintViolation
A field violates a data-type constraint.
Other(String)
A code this crate does not define, kept verbatim.
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub fn as_wire(&self, version: Version) -> &str
pub fn as_wire(&self, version: Version) -> &str
The spelling this code uses on the wire for version.
Codes that a version does not define are downgraded to GenericError, which is the
only code 1.6J offers for “something else went wrong”.
Sourcepub fn is_defined_in(&self, version: Version) -> bool
pub fn is_defined_in(&self, version: Version) -> bool
Whether version defines this code at all.