pub struct PartyRef {
pub country_code: CountryCode,
pub party_id: PartyId,
}Expand description
The country_code + party_id pair that identifies one OCPI party.
This is the pair that appears in the OCPI-to-* and OCPI-from-* routing headers, in the
URL of every client-owned object, and in the roles of a Credentials object. Because
CiString compares case-insensitively, NL/TNM and nl/tnm are the same party.
use ocpi_kit::types::PartyRef;
let a: PartyRef = "NL/TNM".parse().unwrap();
let b = PartyRef::new("nl", "tnm").unwrap();
assert_eq!(a, b);
assert_eq!(a.to_string(), "NL/TNM");Spec: 2.3.0 §transport_and_format_message_routing
Fields§
§country_code: CountryCodeISO-3166 alpha-2 country code of the party.
party_id: PartyIdThe party’s ID.
Implementations§
Source§impl PartyRef
impl PartyRef
Sourcepub fn new(
country_code: impl Into<String>,
party_id: impl Into<String>,
) -> Result<Self, InvalidString>
pub fn new( country_code: impl Into<String>, party_id: impl Into<String>, ) -> Result<Self, InvalidString>
Creates a party reference.
§Errors
Returns InvalidString if either part is not printable ASCII of the right length.
Sourcepub fn to_hub_party_id(&self) -> CiString<5>
pub fn to_hub_party_id(&self) -> CiString<5>
The five-character concatenation used by Credentials.hub_party_id.
Spec: 2.3.0 §credentials_credentials_object — “The two-letter country code and three-character party ID are concatenated together in this field as one five-character string.”
Sourcepub fn from_hub_party_id(value: &CiString<5>) -> Result<Self, InvalidString>
pub fn from_hub_party_id(value: &CiString<5>) -> Result<Self, InvalidString>
Splits a five-character hub_party_id back into its country code and party ID.
§Errors
Returns InvalidString if the value is not exactly five printable ASCII characters.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PartyRef
impl<'de> Deserialize<'de> for PartyRef
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>,
impl Eq for PartyRef
Source§impl JsonSchema for PartyRef
Available on crate feature schema only.
impl JsonSchema for PartyRef
schema only.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 PartyRef
impl Ord for PartyRef
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 PartialOrd for PartyRef
impl PartialOrd for PartyRef
impl StructuralPartialEq for PartyRef
Auto Trait Implementations§
impl Freeze for PartyRef
impl RefUnwindSafe for PartyRef
impl Send for PartyRef
impl Sync for PartyRef
impl Unpin for PartyRef
impl UnsafeUnpin for PartyRef
impl UnwindSafe for PartyRef
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.