Skip to main content

SerializableExt

Trait SerializableExt 

Source
pub trait SerializableExt: IsA<Serializable> + 'static {
    // Provided methods
    fn default_deserialize_property(
        &self,
        property_name: &str,
        value: &mut Value,
        pspec: impl AsRef<ParamSpec>,
        property_node: &Node,
    ) -> bool { ... }
    fn default_serialize_property(
        &self,
        property_name: &str,
        value: &Value,
        pspec: impl AsRef<ParamSpec>,
    ) -> Option<Node> { ... }
    fn deserialize_property(
        &self,
        property_name: &str,
        pspec: impl AsRef<ParamSpec>,
        property_node: &Node,
    ) -> Option<Value> { ... }
    fn find_property(&self, name: &str) -> Option<ParamSpec> { ... }
    fn property(&self, pspec: impl AsRef<ParamSpec>) -> Value { ... }
    fn list_properties(&self) -> Vec<ParamSpec> { ... }
    fn serialize_property(
        &self,
        property_name: &str,
        value: &Value,
        pspec: impl AsRef<ParamSpec>,
    ) -> Option<Node> { ... }
    fn set_property(&self, pspec: impl AsRef<ParamSpec>, value: &Value) { ... }
}
Expand description

Trait containing all Serializable methods.

§Implementors

Serializable

Provided Methods§

Source

fn default_deserialize_property( &self, property_name: &str, value: &mut Value, pspec: impl AsRef<ParamSpec>, property_node: &Node, ) -> bool

Calls the default implementation of the vfunc::Json::Serializable::deserialize_property virtual function.

This function can be used inside a custom implementation of the deserialize_property() virtual function in lieu of calling the default implementation through g_type_default_interface_peek():

⚠️ The following code is in c ⚠️

JsonSerializable *iface;
gboolean res;

iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
res = iface->deserialize_property (serializable, property_name,
                                   value,
                                   pspec,
                                   property_node);
§property_name

the name of the property to deserialize

§value

a pointer to an uninitialized value

§pspec

a property description

§property_node

the JSON node containing the serialized property

§Returns

TRUE if the property was successfully deserialized

Source

fn default_serialize_property( &self, property_name: &str, value: &Value, pspec: impl AsRef<ParamSpec>, ) -> Option<Node>

Calls the default implementation of the vfunc::Json::Serializable::serialize_property virtual function.

This function can be used inside a custom implementation of the serialize_property() virtual function in lieu of calling the default implementation through g_type_default_interface_peek():

⚠️ The following code is in c ⚠️

JsonSerializable *iface;
JsonNode *node;

iface = g_type_default_interface_peek (JSON_TYPE_SERIALIZABLE);
node = iface->serialize_property (serializable, property_name,
                                  value,
                                  pspec);

This function will return NULL if the property could not be serialized.

§property_name

the name of the property to serialize

§value

the value of the property to serialize

§pspec

a property description

§Returns

a node containing the serialized property

Source

fn deserialize_property( &self, property_name: &str, pspec: impl AsRef<ParamSpec>, property_node: &Node, ) -> Option<Value>

Asks a JsonSerializable implementation to deserialize the property contained inside property_node and place its value into value.

The value can be:

  • an empty GValue initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property by using the given property description (since JSON-GLib 1.6)
  • a GValue initialized with the expected type of the property

This function will not be called for properties that are marked as as G_PARAM_CONSTRUCT_ONLY.

§property_name

the name of the property to serialize

§pspec

a property description

§property_node

the JSON node containing the serialized property

§Returns

TRUE if the property was successfully deserialized

§value

a pointer to an uninitialized value

Source

fn find_property(&self, name: &str) -> Option<ParamSpec>

Calls the vfunc::Json::Serializable::find_property implementation on the JsonSerializable instance, which will return the property description for the given name.

§name

the name of the property

§Returns

the property description

Source

fn property(&self, pspec: impl AsRef<ParamSpec>) -> Value

Calls the vfunc::Json::Serializable::get_property implementation on the JsonSerializable instance, which will get the value of the given property.

§pspec

a property description

§Returns
§value

return location for the property value

Source

fn list_properties(&self) -> Vec<ParamSpec>

Calls the vfunc::Json::Serializable::list_properties implementation on the JsonSerializable instance, which will return the list of serializable properties.

§Returns

the serializable properties of the object

Source

fn serialize_property( &self, property_name: &str, value: &Value, pspec: impl AsRef<ParamSpec>, ) -> Option<Node>

Asks a JsonSerializable implementation to serialize an object property into a JSON node.

§property_name

the name of the property to serialize

§value

the value of the property to serialize

§pspec

a property description

§Returns

a node containing the serialized property

Source

fn set_property(&self, pspec: impl AsRef<ParamSpec>, value: &Value)

Calls the vfunc::Json::Serializable::set_property implementation on the JsonSerializable instance, which will set the property with the given value.

§pspec

a property description

§value

the property value to set

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§