Skip to main content

Form

Struct Form 

Source
pub struct Form { /* private fields */ }
Expand description

An independent editable form instance using a compiled structure.

Implementations§

Source§

impl Form

Source

pub fn new( template: FormTemplate, data: &Value, options: BindOptions, ) -> FormResult<Self>

Create an instance, prepare default data and evaluate fields.

Source

pub fn template(&self) -> &FormTemplate

Return the shared structure without instance values.

Source

pub fn fields(&self) -> &[Value]

Return the current field models.

Source

pub fn revision(&self) -> u64

Number of successful instance updates.

Source

pub fn get_data(&self) -> Value

Return detached submission data.

Source

pub fn set_data(&mut self, data: &Value) -> FormResult<()>

Replace record data, restart the history and reevaluate the form atomically.

Source

pub fn get_value(&self, path: &str) -> FormResult<Value>

Return a detached value relative to the data root.

Source

pub fn set_value(&mut self, path: &str, value: Value) -> FormResult<()>

Update one data path and reevaluate the form atomically.

Source

pub fn undo(&mut self) -> FormResult<()>

Restore the record before the last data change; the reverted record can be redone (CURT-011).

Source

pub fn redo(&mut self) -> FormResult<()>

Reapply the most recently undone data change (CURT-012).

Source

pub fn can_undo(&self) -> bool

Whether undo can restore an earlier record (CURT-061).

Source

pub fn can_redo(&self) -> bool

Whether redo can reapply a reverted change (CURT-061).

Source

pub fn toggle_row(&mut self, path: &str, key: &str) -> FormResult<()>

Expand a collapsed row or collapse an expanded one; the record and the revision do not change.

Source

pub fn set_all_expanded(&mut self, expanded: bool) -> FormResult<()>

Expand every row, or collapse every collapsible row; the record and the revision do not change.

Source

pub fn add_row( &mut self, path: &str, options: AddRowOptions, ) -> FormResult<String>

Insert a row with supplied data or field defaults.

Source

pub fn copy_row( &mut self, path: &str, key: &str, options: AddRowOptions, ) -> FormResult<String>

Copy current values and generate new identities for nested repeated rows.

Source

pub fn remove_row(&mut self, path: &str, key: &str) -> FormResult<()>

Remove a row while enforcing the minimum count.

Source

pub fn move_row(&mut self, path: &str, key: &str, index: i64) -> FormResult<()>

Move a row without changing its identity or values; index is the position after the move, and a position outside the rows fails.

Source

pub fn rekey_row( &mut self, path: &str, old_key: &str, new_key: &str, ) -> FormResult<()>

Apply a saved sequence key to one row and update its descendant paths.

Trait Implementations§

Source§

impl Clone for Form

Source§

fn clone(&self) -> Form

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 Freeze for Form

§

impl RefUnwindSafe for Form

§

impl Send for Form

§

impl Sync for Form

§

impl Unpin for Form

§

impl UnsafeUnpin for Form

§

impl UnwindSafe for Form

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.