Trait glean_core::traits::ObjectSerialize
source · pub trait ObjectSerialize {
// Required methods
fn from_str(obj: &str) -> Result<Self, ObjectError>
where Self: Sized;
fn into_serialized_object(self) -> Result<JsonValue, ObjectError>;
}
Expand description
An object that can be serialized into JSON.
Objects are defined by their structure in the metrics definition.
This is essentially a wrapper around serde’s Serialize
/Deserialize
,
but in a way we can name it for our JSON (de)serialization.
Required Methods§
sourcefn from_str(obj: &str) -> Result<Self, ObjectError>where
Self: Sized,
fn from_str(obj: &str) -> Result<Self, ObjectError>where
Self: Sized,
Deserialize the object from its JSON representation.
Returns an error if deserialization fails. This should not happen for glean_parser-generated and later serialized objects.
sourcefn into_serialized_object(self) -> Result<JsonValue, ObjectError>
fn into_serialized_object(self) -> Result<JsonValue, ObjectError>
Serialize this object into a JSON string.