Skip to main content

SignalValue

Trait SignalValue 

Source
pub trait SignalValue: Sized {
    type Surrogate<'a>: Serialize
       where Self: 'a;

    // Required methods
    fn surrogate(&self) -> Self::Surrogate<'_>;
    fn from_value(value: &Value) -> Option<Self>;
}
Expand description

A value that can be sent to the browser and restored from browser state.

Implemented automatically for runtime types whose surrogates support serialization and deserialization.

Required Associated Types§

Source

type Surrogate<'a>: Serialize where Self: 'a

The serializable surrogate of a borrowed value.

Required Methods§

Source

fn surrogate(&self) -> Self::Surrogate<'_>

Borrows the value as its surrogate.

Source

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

Reads a value back from the surrogate a client sent, or None if the surrogate does not fit this type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<T> SignalValue for T

Source§

type Surrogate<'a> = <&'a T as Surrogated>::Surrogate where Self: 'a