Skip to main content

ExtensionState

Trait ExtensionState 

Source
pub trait ExtensionState:
    Sized
    + Serialize
    + for<'de> Deserialize<'de> {
    const EXTENSION_NAME: &'static str;
    const VERSION: &'static str;

    // Provided methods
    fn from_value(value: &Value) -> Result<Self> { ... }
    fn to_value(&self) -> Result<Value> { ... }
    fn from_extension_data(extension_data: &ExtensionData) -> Option<Self> { ... }
    fn to_extension_data(
        &self,
        extension_data: &mut ExtensionData,
    ) -> Result<()> { ... }
}
Expand description

Helper trait for extension-specific state management

Required Associated Constants§

Source

const EXTENSION_NAME: &'static str

The name of the extension

Source

const VERSION: &'static str

The version of the extension state format

Provided Methods§

Source

fn from_value(value: &Value) -> Result<Self>

Convert from JSON value

Source

fn to_value(&self) -> Result<Value>

Convert to JSON value

Source

fn from_extension_data(extension_data: &ExtensionData) -> Option<Self>

Get state from extension data

Source

fn to_extension_data(&self, extension_data: &mut ExtensionData) -> Result<()>

Save state to extension data

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl ExtensionState for EnabledExtensionsState

Source§

const EXTENSION_NAME: &'static str = "enabled_extensions"

Source§

const VERSION: &'static str = "v0"

Source§

impl ExtensionState for TodoState

Source§

const EXTENSION_NAME: &'static str = "todo"

Source§

const VERSION: &'static str = "v0"