Skip to main content

RecordAction

Struct RecordAction 

Source
#[non_exhaustive]
pub struct RecordAction { pub caption: String, pub id: Option<String>, pub selection: Selection, pub enabled: Option<String>, pub set: String, pub confirm: Option<String>, }
Expand description

An action of an entity that sets fields of the records selected.

use ravenrs_app::{EntityInfo, FieldInfo, FieldKind, RecordAction};

let task = EntityInfo::new("Task")
    .field(FieldInfo::new("id", FieldKind::Integer).key())
    .field(FieldInfo::new("state", FieldKind::Text))
    .action(
        RecordAction::new("Finish")
            .enabled("[state] <> 'done'")
            .set("state = 'done'")
            .confirm("Finish the tasks?"),
    );
assert!(task.check().is_ok());

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§caption: String

What its button says.

§id: Option<String>

Its id; Entity.Caption unless given.

§selection: Selection

How many records it takes: one or more unless given.

§enabled: Option<String>

An expression every record selected has to meet for it to be on.

§set: String

What it sets: field = expression; ..., each read from the record as it was.

§confirm: Option<String>

The question asked before it runs.

Implementations§

Source§

impl RecordAction

Source

pub fn new(caption: impl Into<String>) -> Self

An action with this caption, on one record or more, that sets nothing yet.

Source

pub fn id(self, id: impl Into<String>) -> Self

Gives it an id of its own.

Source

pub fn selection(self, selection: Selection) -> Self

How many records it takes.

Source

pub fn enabled(self, expression: impl Into<String>) -> Self

On only while every record selected meets this expression.

Source

pub fn set(self, assignments: impl Into<String>) -> Self

What it sets, as field = expression; ....

Source

pub fn confirm(self, question: impl Into<String>) -> Self

Asks this before it runs.

Source

pub fn id_on(&self, entity: &EntityInfo) -> String

Its id on this entity.

Source

pub fn to_action(&self, entity: &EntityInfo) -> Action

The action that does it on this entity.

Trait Implementations§

Source§

impl Clone for RecordAction

Source§

fn clone(&self) -> RecordAction

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
Source§

impl Debug for RecordAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RecordAction

Source§

impl PartialEq for RecordAction

Source§

fn eq(&self, other: &RecordAction) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RecordAction

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.