pub struct PluginIDOwned { /* private fields */ }Expand description
An owned version of PluginID that can be owned and has optional serialization support with
serde.
This type wraps a static string reference and provides implementations for
conversion to/from PluginID, as well as serialization support when the
serde feature is enabled.
This type is particularly useful when working with serialization frameworks, as it allows plugin identifiers to be properly serialized and deserialized.
If you deserialize a string into this datastructure, please note that this uses an internal
leak mechanism (String::leak) to make sure that the actual data of the plugin id will always exist (making it
'static). That means that you may take up more memory than expected if you deserialize huge
amoungs of plugin ids.
§Examples
use steckrs::{PluginIDOwned, PluginID};
let plugin_id: PluginID = "my_plugin";
// Create from owned id
let id = PluginIDOwned::from(plugin_id);
// Convert back to a PluginID
let plugin_id2: PluginID = id.into();
assert_eq!(plugin_id, plugin_id2);§Serialization
When the serde feature is enabled, this type implements Serialize
and Deserialize. Note that deserialization involves a memory leak,
as the string is converted to a &'static str by leaking memory (to make sure it is always
existing in memory).
The leaking is using safe rust with String::leak.
Implementations§
Trait Implementations§
Source§impl Clone for PluginIDOwned
impl Clone for PluginIDOwned
Source§fn clone(&self) -> PluginIDOwned
fn clone(&self) -> PluginIDOwned
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PluginIDOwned
impl Debug for PluginIDOwned
Source§impl<'de> Deserialize<'de> for PluginIDOwned
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PluginIDOwned
serde only.