Skip to main content

StateValueConfig

Struct StateValueConfig 

Source
pub struct StateValueConfig<V> {
    pub parse: Rc<dyn Fn(&Value) -> V>,
    pub unparse: Rc<dyn Fn(&V) -> Value>,
    pub is_equal: StateIsEqual<V>,
    pub reset_on_copy_node: bool,
    pub derived: bool,
    pub schema: Option<SerializationSchema>,
}
Expand description

StateValueConfig: how a state’s value parses from JSON (parse, which gives the default for undefined), writes back (unparse) and compares (isEqual), whether $copyNode resets it (resetOnCopyNode), whether the node’s own code recomputes it (derived, @experimental), and the schema parse was given as (StateConfig.schema), when it was one.

Fields§

§parse: Rc<dyn Fn(&Value) -> V>§unparse: Rc<dyn Fn(&V) -> Value>§is_equal: StateIsEqual<V>§reset_on_copy_node: bool§derived: bool§schema: Option<SerializationSchema>

Implementations§

Source§

impl<V: StateValue> StateValueConfig<V>

Source

pub fn new(parse: impl Fn(&Value) -> V + 'static) -> Self

{parse}, with JS’s defaults for the rest: the value as JSON, Object.is, and kept by a copy.

Source§

impl<V: SchemaValue + 'static> StateValueConfig<V>

Source

pub fn from_schema(schema: SerializationSchema) -> Self

{parse: schema}: a state whose value schema describes, which also gives it its equality (isSchemaEqual) and default, written back as the value it parsed to. V holds the values the schema parses to (Value holds any).

Trait Implementations§

Source§

impl<V> Clone for StateValueConfig<V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<V> !RefUnwindSafe for StateValueConfig<V>

§

impl<V> !Send for StateValueConfig<V>

§

impl<V> !Sync for StateValueConfig<V>

§

impl<V> !UnwindSafe for StateValueConfig<V>

§

impl<V> Forget for StateValueConfig<V>

§

impl<V> Freeze for StateValueConfig<V>
where Rc<dyn Fn(&Value) -> V>: Freeze, Rc<dyn Fn(&V) -> Value>: Freeze, Rc<dyn Fn(&V, &V) -> bool>: Freeze,

§

impl<V> Move for StateValueConfig<V>

§

impl<V> Unpin for StateValueConfig<V>
where Rc<dyn Fn(&Value) -> V>: Unpin, Rc<dyn Fn(&V) -> Value>: Unpin, Rc<dyn Fn(&V, &V) -> bool>: Unpin,

§

impl<V> UnsafeUnpin for StateValueConfig<V>
where Rc<dyn Fn(&Value) -> V>: UnsafeUnpin, Rc<dyn Fn(&V) -> Value>: UnsafeUnpin, Rc<dyn Fn(&V, &V) -> bool>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.