pub struct StatusCode(/* private fields */);transport only.Expand description
A four-digit OCPI status code.
Modelled as a newtype over u16 rather than an enum because the spec reserves custom ranges
(19xx, 29xx, 39xx, 49xx) that a party may define values in, and because a peer may
send a code from a newer version.
use ocpi_kit::transport::{StatusCode, StatusClass};
assert_eq!(StatusCode::SUCCESS.class(), StatusClass::Success);
assert_eq!(StatusCode::INVALID_PARAMETERS.get(), 2001);
assert!(StatusCode::new(2901).is_custom());Spec: 2.3.0 §status_codes_status_codes
Implementations§
Source§impl StatusCode
impl StatusCode
Sourcepub const CLIENT_ERROR: Self
pub const CLIENT_ERROR: Self
2000 — Generic client error.
Sourcepub const INVALID_PARAMETERS: Self
pub const INVALID_PARAMETERS: Self
2001 — Invalid or missing parameters, e.g. a missing last_updated in a PATCH.
Sourcepub const NOT_ENOUGH_INFORMATION: Self
pub const NOT_ENOUGH_INFORMATION: Self
2002 — Not enough information, e.g. an authorization request with too little information.
Sourcepub const UNKNOWN_LOCATION: Self
pub const UNKNOWN_LOCATION: Self
2003 — Unknown Location, e.g. a START_SESSION with an unknown location.
Sourcepub const UNKNOWN_TOKEN: Self
pub const UNKNOWN_TOKEN: Self
2004 — Unknown Token, e.g. a real-time authorization of an unknown Token.
Sourcepub const SERVER_ERROR: Self
pub const SERVER_ERROR: Self
3000 — Generic server error.
Sourcepub const UNABLE_TO_USE_CLIENT_API: Self
pub const UNABLE_TO_USE_CLIENT_API: Self
3001 — Unable to use the client’s API, e.g. a failed call-back during registration.
Sourcepub const UNSUPPORTED_VERSION: Self
pub const UNSUPPORTED_VERSION: Self
3002 — Unsupported version.
Sourcepub const NO_MATCHING_ENDPOINTS: Self
pub const NO_MATCHING_ENDPOINTS: Self
3003 — No matching endpoints or expected endpoints missing between parties.
Sourcepub const UNKNOWN_RECEIVER: Self
pub const UNKNOWN_RECEIVER: Self
4001 — Unknown receiver: the OCPI-to-* address is unknown.
Sourcepub const TIMEOUT_ON_FORWARDED_REQUEST: Self
pub const TIMEOUT_ON_FORWARDED_REQUEST: Self
4002 — Timeout on a forwarded request.
Sourcepub const CONNECTION_PROBLEM: Self
pub const CONNECTION_PROBLEM: Self
4003 — Connection problem: the receiving party is not connected.
Sourcepub const fn class(self) -> StatusClass
pub const fn class(self) -> StatusClass
Which of the four ranges this code falls in.
Sourcepub const fn is_success(self) -> bool
pub const fn is_success(self) -> bool
Whether this is a success code, so data carries the documented payload.
When the status code is in the success range (1xxx), the
datafield in the response message SHOULD contain the information as specified in the protocol. Otherwise thedatafield is unspecified.
Sourcepub const fn is_custom(self) -> bool
pub const fn is_custom(self) -> bool
Whether the code falls in one of the reserved custom sub-ranges (x900–x999).
Custom status code range values SHALL NOT be used by standard OCPI module … When custom status codes are used, keep in mind that different custom modules could use the same values with a different meaning, as they are not standardized.
Sourcepub const fn description(self) -> Option<&'static str>
pub const fn description(self) -> Option<&'static str>
The description the specification gives for this code, when it defines one.
Trait Implementations§
Source§impl Clone for StatusCode
impl Clone for StatusCode
Source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StatusCode
Source§impl Debug for StatusCode
impl Debug for StatusCode
Source§impl<'de> Deserialize<'de> for StatusCode
impl<'de> Deserialize<'de> for StatusCode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for StatusCode
impl Display for StatusCode
impl Eq for StatusCode
Source§impl From<StatusCode> for u16
impl From<StatusCode> for u16
Source§fn from(value: StatusCode) -> Self
fn from(value: StatusCode) -> Self
Source§impl From<u16> for StatusCode
impl From<u16> for StatusCode
Source§impl Hash for StatusCode
impl Hash for StatusCode
Source§impl JsonSchema for StatusCode
impl JsonSchema for StatusCode
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for StatusCode
impl Ord for StatusCode
Source§fn cmp(&self, other: &StatusCode) -> Ordering
fn cmp(&self, other: &StatusCode) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for StatusCode
impl PartialEq for StatusCode
Source§impl PartialOrd for StatusCode
impl PartialOrd for StatusCode
Source§impl Serialize for StatusCode
impl Serialize for StatusCode
impl StructuralPartialEq for StatusCode
Auto Trait Implementations§
impl Freeze for StatusCode
impl RefUnwindSafe for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Unpin for StatusCode
impl UnsafeUnpin for StatusCode
impl UnwindSafe for StatusCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.