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 a signal can hold: one of the runtime’s vocabulary types, which can be serialized into the page for the browser to pick up and read back from what the browser sends.

Implemented for every type whose surrogate serializes and deserializes; there is nothing to implement by hand.

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