pub struct Extensions(/* private fields */);Expand description
Undocumented JSON fields found on an OICP object, preserved verbatim.
§Why every object carries one
OICP 2.3 has no extensibility chapter and no version negotiation — but it is edited in place.
Hubject revises the 2.3 documents without bumping the version: IsHubjectCompatible and
IsOpen24Hours were added to PullEvseData this way, and the CDR schema gained a
PartnerProductID clarification in 2026. A partner’s stack that was built against last year’s
snapshot is still expected to forward this year’s payloads intact.
So every wire object in this crate carries an extensions field marked #[serde(flatten)].
A field that arrives, survives and is written back unchanged is the difference between a hub
that can sit between two parties who have agreed on something it knows nothing about, and one
that quietly destroys their data.
Keys are kept in a BTreeMap, so serialisation order is deterministic.
use oicp_kit::types::Extensions;
let json = r#"{"HubjectFutureField":"whatever","acme_note":3}"#;
let extensions: Extensions = serde_json::from_str(json).unwrap();
assert_eq!(extensions.get::<u32>("acme_note").unwrap(), Some(3));
assert_eq!(serde_json::to_string(&extensions).unwrap(), json);In place, on a real object:
let json = r#"{"EvseID":"DE*XYZ*ETEST1","EvseStatus":"Available","HubjectAddedThis":42}"#;
let record: EvseStatusRecord = serde_json::from_str(json).unwrap();
assert_eq!(record.extensions.get::<u32>("HubjectAddedThis").unwrap(), Some(42));
assert_eq!(serde_json::to_string(&record).unwrap(), json);Implementations§
Source§impl Extensions
impl Extensions
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether no undocumented field was present.
Objects skip serialising their extensions field when this is true, so an object that
carried no extensions is written back byte-identically.
Sourcepub fn get_raw(&self, key: &str) -> Option<&Value>
pub fn get_raw(&self, key: &str) -> Option<&Value>
The raw JSON value stored under key, if any.
Sourcepub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>, Error>
pub fn get<T: DeserializeOwned>(&self, key: &str) -> Result<Option<T>, Error>
Deserialises the value stored under key into T.
Returns Ok(None) when the key is absent, and Err when it is present but does not
deserialise into T.
§Errors
Returns the serde_json error when the stored value is not a T.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Whether key is present.
Sourcepub fn insert<T: Serialize>(
&mut self,
key: impl Into<String>,
value: T,
) -> Result<(), Error>
pub fn insert<T: Serialize>( &mut self, key: impl Into<String>, value: T, ) -> Result<(), Error>
Stores value under key, returning what was there before.
§Errors
Returns the serde_json error when value cannot be serialised.
Trait Implementations§
Source§impl Clone for Extensions
impl Clone for Extensions
Source§impl Debug for Extensions
impl Debug for Extensions
Source§impl Default for Extensions
impl Default for Extensions
Source§impl<'de> Deserialize<'de> for Extensions
impl<'de> Deserialize<'de> for Extensions
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 FromIterator<(String, Value)> for Extensions
impl FromIterator<(String, Value)> for Extensions
Source§impl JsonSchema for Extensions
Available on crate feature schema only.
impl JsonSchema for Extensions
schema only.Source§fn json_schema(_g: &mut SchemaGenerator) -> Schema
fn json_schema(_g: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more