#[non_exhaustive]pub enum ObjectKind {
Location,
Evse,
Connector,
Session,
Cdr,
Tariff,
Token,
AuthorizationInfo,
Credentials,
ClientInfo,
StartSession,
ReserveNow,
}convert only.Expand description
An OCPI object whose wire format changed between the versions this crate bridges.
Objects that are byte-identical across versions are deliberately absent: there is nothing to
do to them, and ObjectKind::for_endpoint returns None for the endpoints that carry them
so a caller can forward the bytes untouched.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Location
Location, which gained parking_places and help_phone in 2.3.0.
Evse
EVSE, which gained parking and accepted_service_providers.
Connector
Connector, which gained capabilities.
Session
Session, whose total_cost is a Price.
Cdr
CDR, whose costs are Prices and whose tariffs are Tariffs.
Tariff
Tariff, which gained tax_included and replaced Price limits with PriceLimit.
Token
Token, whose TokenType was opened and gained EMAID.
AuthorizationInfo
AuthorizationInfo, which embeds a Token.
Credentials
Credentials, which gained hub_party_id and lost the HUB role.
ClientInfo
ClientInfo, which carries a Role.
StartSession
The START_SESSION command body, which embeds a Token.
ReserveNow
The RESERVE_NOW command body, which embeds a Token.
Implementations§
Source§impl ObjectKind
impl ObjectKind
Sourcepub fn bridge(
self,
from: &VersionNumber,
to: &VersionNumber,
value: Value,
) -> Result<Converted<Value>, BridgeError>
pub fn bridge( self, from: &VersionNumber, to: &VersionNumber, value: Value, ) -> Result<Converted<Value>, BridgeError>
Translates one object, or a whole page of them, from from to to.
An array is translated element by element with each element’s losses reported under its own
index (/17/help_phone). A null — an envelope with no data — is returned unchanged.
§Errors
Returns BridgeError::Unsupported when this build has no conversions between the two
versions, and BridgeError::Decode when the document is not the object the endpoint is
supposed to carry.
Sourcepub const fn divergent_fields(self) -> &'static [&'static str]
pub const fn divergent_fields(self) -> &'static [&'static str]
The top-level fields of this object whose shape or presence differs between the versions.
Everything else is byte-identical, which is what makes a merge patch translatable: a
patch is not an object, so it cannot go through bridge, but one writing
only fields outside this list means the same thing in both versions and crosses unchanged.
Checked against the fixture corpus: every 2.2.1 spec example is carried to 2.3.0 and back, and no field outside its object’s list may move.
Sourcepub fn patch_crosses_unchanged(self, fields: &[&str]) -> bool
pub fn patch_crosses_unchanged(self, fields: &[&str]) -> bool
Whether a merge patch written against one version means the same thing in the other.
See divergent_fields.
Sourcepub fn for_endpoint(
module: &ModuleId,
interface: InterfaceRole,
path: &str,
payload: Payload,
) -> Option<Self>
pub fn for_endpoint( module: &ModuleId, interface: InterfaceRole, path: &str, payload: Payload, ) -> Option<Self>
The object an endpoint carries, or None when it is the same in both versions.
path is what follows the module’s endpoint URL, with or without surrounding slashes and
without a query string — LOC1/3256 on a Locations Sender interface, NL/TNM/LOC1 on the
Receiver one. None means “nothing to do”: either the endpoint carries an object that did
not change between the versions, or it carries no object at all.
Spec: 2.3.0 §mod_locations, §mod_sessions, §mod_cdrs, §mod_tariffs, §mod_tokens, §mod_commands, §credentials, §mod_hub_client_info
Trait Implementations§
Source§impl Clone for ObjectKind
impl Clone for ObjectKind
Source§fn clone(&self) -> ObjectKind
fn clone(&self) -> ObjectKind
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 ObjectKind
Source§impl Debug for ObjectKind
impl Debug for ObjectKind
Source§impl Display for ObjectKind
impl Display for ObjectKind
impl Eq for ObjectKind
Source§impl Hash for ObjectKind
impl Hash for ObjectKind
Source§impl PartialEq for ObjectKind
impl PartialEq for ObjectKind
impl StructuralPartialEq for ObjectKind
Auto Trait Implementations§
impl Freeze for ObjectKind
impl RefUnwindSafe for ObjectKind
impl Send for ObjectKind
impl Sync for ObjectKind
impl Unpin for ObjectKind
impl UnsafeUnpin for ObjectKind
impl UnwindSafe for ObjectKind
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> 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.