pub trait Primitive: Sized {
// Required methods
fn value_json(&self) -> Result<Option<Value>, EncodeError>;
fn element_json(&self) -> Result<Option<Value>, EncodeError>;
fn from_json_parts(
value: Option<&Value>,
element: Option<&Value>,
path: &mut Path,
) -> Result<Self, DecodeError>;
fn has_value(&self) -> bool;
fn has_element(&self) -> bool;
fn serialize_value<S: Serializer>(
&self,
serializer: S,
) -> Result<S::Ok, S::Error>;
fn serialize_element<S: Serializer>(
&self,
serializer: S,
) -> Result<S::Ok, S::Error>;
}Expand description
A FHIR primitive: a JSON value plus an optional element object.
Required Methods§
Sourcefn value_json(&self) -> Result<Option<Value>, EncodeError>
fn value_json(&self) -> Result<Option<Value>, EncodeError>
The JSON value, None when only id or extension are present.
§Errors
Returns EncodeError when the held value has no JSON form.
Sourcefn element_json(&self) -> Result<Option<Value>, EncodeError>
fn element_json(&self) -> Result<Option<Value>, EncodeError>
The _name object, None when the primitive has no id or extension.
§Errors
Returns EncodeError when an extension value has no JSON form.
Sourcefn from_json_parts(
value: Option<&Value>,
element: Option<&Value>,
path: &mut Path,
) -> Result<Self, DecodeError>
fn from_json_parts( value: Option<&Value>, element: Option<&Value>, path: &mut Path, ) -> Result<Self, DecodeError>
Decodes the value and its _name sibling.
§Errors
Returns DecodeError when both parts are absent or either is malformed.
Sourcefn has_element(&self) -> bool
fn has_element(&self) -> bool
Whether the primitive carries an id or an extension.
Sourcefn serialize_value<S: Serializer>(
&self,
serializer: S,
) -> Result<S::Ok, S::Error>
fn serialize_value<S: Serializer>( &self, serializer: S, ) -> Result<S::Ok, S::Error>
Writes the value, null when the primitive carries none.
§Errors
Returns the serializer’s error, which for a decimal includes a lexical form that is no JSON number.
Sourcefn serialize_element<S: Serializer>(
&self,
serializer: S,
) -> Result<S::Ok, S::Error>
fn serialize_element<S: Serializer>( &self, serializer: S, ) -> Result<S::Ok, S::Error>
Writes the _name object, null when the primitive carries no id
and no extension.
§Errors
Returns the serializer’s error.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".